name: Build Android Apk # Only a release built through "Releases -> New Release" starts a build. A tag # pushed with plain git does not publish a release and is therefore ignored. on: release: types: - published env: # Keep in sync with the other workflows and with `ac_web/Dockerfile`. FLUTTER_VERSION: '3.44.9' # The project produces java 17 bytecode (`android/app/build.gradle.kts`), but # gradle 9.1 and the android gradle plugin 9 need a newer jdk to run on. JAVA_VERSION: '21' jobs: android: runs-on: ubuntu-latest container: image: catthehacker/ubuntu:act-latest # The flutter project lives in a sub directory of the repository. defaults: run: working-directory: ac_web steps: - name: Checkout uses: https://github.com/actions/checkout@v4 # The flutter tool runs git inside the workspace and inside its own sdk, # and git refuses to work in directories it considers to belong to # somebody else. - name: Trust the workspace run: git config --global --add safe.directory '*' # Everything the flutter download below needs. - name: Install the download tools run: | apt-get update apt-get install -y --no-install-recommends ca-certificates curl xz-utils - name: Set up Java uses: https://github.com/actions/setup-java@v4 with: distribution: temurin java-version: ${{ env.JAVA_VERSION }} # Installs the command line tools and accepts the sdk licenses. The # platform, the build tools and the ndk pinned by the flutter sdk are # then downloaded by gradle itself, which is what makes this job slow on # a cold runner. - name: Set up the Android sdk uses: https://github.com/android-actions/setup-android@v3 # `subosito/flutter-action` cannot be used: it caches the sdk through # `actions/cache@v5`, and the act-runner of this gitea instance only # supports actions up to node20 ("runs.using ... got node24"). Unpacking # the official archive does the same thing and pins the version exactly, # just like `ac_web/Dockerfile` does. - name: Set up Flutter run: | curl -fsSL "https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_${{ env.FLUTTER_VERSION }}-stable.tar.xz" \ | tar -xJ -C /opt echo "/opt/flutter/bin" >> "$GITHUB_PATH" - name: Show the flutter version run: flutter --version - name: Install dependencies run: flutter pub get - name: Run tests run: flutter test # One apk for all abis. `--split-per-abi` would produce three smaller # ones instead, at the cost of having to pick the right one manually. # # The release build is signed with a debug key, because # `android/app/build.gradle.kts` has no release signing config yet. To # ship the apk, add a keystore as a secret, write it into # `android/key.properties` here and reference it from the gradle file. - name: Build the apk run: flutter build apk --release # Gradle always writes the same file name, so the release the apk belongs # to would not be visible after downloading it. - name: Name the apk after the release run: mv build/app/outputs/flutter-apk/app-release.apk ac_web-${{ github.ref_name }}.apk # @v3 on purpose: `upload-artifact@v4` bundles `@actions/artifact` v2, # which refuses to run as soon as `GITHUB_SERVER_URL` is not github.com # ("GHESNotSupportedError") -- and on this instance it is the gitea host. # The check happens in the action itself, before any request, so it # cannot be fixed on the gitea side. @v3 talks to the older artifact api # gitea implements and still runs on node20, which the act-runner allows. - name: Upload the apk uses: https://github.com/actions/upload-artifact@v3 with: name: ac_web-android-${{ github.ref_name }} # Artifact paths are relative to the repository, not to the # working-directory above. path: ac_web/ac_web-${{ github.ref_name }}.apk if-no-files-found: error