From a164914ca2c064debbc5ddec22e7a8b788640366 Mon Sep 17 00:00:00 2001 From: Michael Hollister Date: Thu, 10 Jul 2025 16:06:33 -0500 Subject: [PATCH] Android: Updated CI infrastructure --- receivers/android/.gitlab-ci.yml | 45 +++++++++++++++++++++++++++++--- receivers/android/Dockerfile | 19 ++++++++++++++ receivers/android/deploy.sh | 32 ----------------------- 3 files changed, 60 insertions(+), 36 deletions(-) create mode 100644 receivers/android/Dockerfile delete mode 100644 receivers/android/deploy.sh diff --git a/receivers/android/.gitlab-ci.yml b/receivers/android/.gitlab-ci.yml index 1a6bef5..899e807 100644 --- a/receivers/android/.gitlab-ci.yml +++ b/receivers/android/.gitlab-ci.yml @@ -1,7 +1,44 @@ -buildAndDeployAndroid: - stage: buildAndDeployAndroid + +buildAndroidDockerContainer: + stage: buildDockerContainers + image: docker:20.10.16 + services: + - docker:20.10.16-dind + tags: + - fcast-instance-runner before_script: - cd receivers/android script: - - sh deploy.sh - when: manual \ No newline at end of file + - echo "$CI_REGISTRY_PASSWORD" | docker login $CI_REGISTRY -u $CI_REGISTRY_USER --password-stdin + - docker build -t $CI_REGISTRY/videostreaming/fcast/receiver-android-dev:latest . + - docker push $CI_REGISTRY/videostreaming/fcast/receiver-android-dev:latest + when: manual + +buildAndDeployAndroid: + stage: buildAndDeployAndroid + image: gitlab.futo.org:5050/videostreaming/fcast/receiver-android-dev:latest + tags: + - fcast-instance-runner + variables: + ANDROID_VERSION_NAME: "1" + ANDROID_VERSION_CODE: "1" + before_script: + - cd receivers/android + script: + - echo "Building content..." + - ./gradlew --stacktrace assembleRelease -PversionName=$ANDROID_VERSION_NAME -PversionCode=$ANDROID_VERSION_CODE + - ./gradlew --stacktrace bundlePlaystoreRelease -PversionName=$ANDROID_VERSION_NAME -PversionCode=$ANDROID_VERSION_CODE + - echo $ANDROID_VERSION_CODE > ./fcast-version.txt + - mkdir /artifacts/$ANDROID_VERSION_CODE + - cp -rf out/make/app/defaultFlavor/release/app-defaultFlavor-release.apk /artifacts/$ANDROID_VERSION_CODE/fcast-release.apk + - cp -rf out/make/app/playstore/release/app-playstore-release.aab /artifacts/$ANDROID_VERSION_CODE/fcast-playstore-release.aab + - cp -rf ./fcast-version.txt /artifacts/fcast-version.txt + artifacts: + untracked: false + when: on_success + access: all + expire_in: "30 days" + paths: + - /artifacts/$ANDROID_VERSION_CODE/fcast-release.apk + - /artifacts/$ANDROID_VERSION_CODE/fcast-playstore-release.aab + when: manual diff --git a/receivers/android/Dockerfile b/receivers/android/Dockerfile new file mode 100644 index 0000000..c0143c5 --- /dev/null +++ b/receivers/android/Dockerfile @@ -0,0 +1,19 @@ +FROM ubuntu:24.04 + +# TZ +ARG DEBIAN_FRONTEND=noninteractive + +ENV ANDROID_HOME=/Android/Sdk +ENV TZ=Etc/UTC + +RUN apt update +RUN apt install -y zip wget tzdata + +RUN apt install -y openjdk-21-jdk +RUN wget https://dl.google.com/android/repository/commandlinetools-linux-13114758_latest.zip +RUN unzip commandlinetools-linux-13114758_latest.zip +RUN mkdir -p $ANDROID_HOME +RUN mv /cmdline-tools $ANDROID_HOME + +RUN yes | $ANDROID_HOME/cmdline-tools/bin/sdkmanager --sdk_root=$ANDROID_HOME --licenses +RUN $ANDROID_HOME/cmdline-tools/bin/sdkmanager --sdk_root=$ANDROID_HOME --install "platforms;android-36" diff --git a/receivers/android/deploy.sh b/receivers/android/deploy.sh deleted file mode 100644 index c6f08ae..0000000 --- a/receivers/android/deploy.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -if [ -z "$ANDROID_VERSION_NAME" ] || [ -z "$ANDROID_VERSION_CODE" ]; then echo "Version name or code not specified. Skipping build."; exit 0; fi - -DOCUMENT_ROOT=/var/www/html - -# Build content -echo "Building content..." -./gradlew --stacktrace assembleRelease -PversionName=$ANDROID_VERSION_NAME -PversionCode=$ANDROID_VERSION_CODE -./gradlew --stacktrace bundlePlaystoreRelease -PversionName=$ANDROID_VERSION_NAME -PversionCode=$ANDROID_VERSION_CODE - -# Take site offline -echo "Taking site offline..." -touch $DOCUMENT_ROOT/maintenance.file - -# Swap over the content -echo "Deploying content..." -echo $ANDROID_VERSION_CODE > /var/www/html/fcast-version.txt -cp ./app/build/outputs/apk/defaultFlavor/release/app-defaultFlavor-release.apk /var/www/html/fcast-release.apk -cp ./app/build/outputs/bundle/playstoreRelease/app-playstore-release.aab /var/www/html/fcast-playstore-release.aab - -# Notify Cloudflare to wipe the CDN cache -echo "Purging Cloudflare cache..." -curl -X POST "https://api.cloudflare.com/client/v4/zones/ff904f7348b9513064b23e852e328abb/purge_cache" \ - -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \ - -H "Content-Type: application/json" \ - --data '{"purge_everything":true}' - -sleep 30 - -# Take site back online -echo "Bringing site back online..." -rm $DOCUMENT_ROOT/maintenance.file