# Release automation for git.comunes.org (Forgejo Actions). # # Pushing a tag `v*` runs two independent jobs: # play - build the signed AAB and ship it to Google Play (production, 100%). # fdroid_reference- build the per-ABI reference APKs the SAME way F-Droid will # (fdroid build inside the fdroidserver buildserver image), # sign them with the tane-upload key, and attach them to the # Forgejo release. F-Droid re-runs `fdroid build` on the same # commit+recipe+image, gets byte-identical output, verifies our # signature (AllowedAPKSigningKeys) and publishes OUR APK — so # F-Droid and Play share the same signing key. # # All credentials come from repo secrets (Settings > Actions > Secrets): # TANE_KEYSTORE_BASE64 base64 of the dedicated tane-upload.jks # TANE_KEYSTORE_PASSWORD store password # TANE_KEY_ALIAS tane-upload # TANE_KEY_PASSWORD key password # SUPPLY_JSON_KEY_DATA Google Play service-account JSON # # NOTE: `runs-on` must match a label your Forgejo runner registered with. # fdroid_reference runs as a 3-way ABI matrix (not one job building all 3 # sequentially): each ABI needs its own NDK/tesseract-native/flutter compile # from a cold cache, which triggered the runner's max-job-runtime kill when # done back-to-back in a single job. One ABI per job fits comfortably. name: release on: push: tags: - 'v*' # Manual trigger to test the fdroid_reference job on a branch without cutting a # tag or deploying to Play (the play job below is guarded to tags only). workflow_dispatch: jobs: play: if: ${{ startsWith(github.ref, 'refs/tags/') }} runs-on: docker container: image: ghcr.io/cirruslabs/flutter:3.41.9 steps: # Manual git checkout (no Node): the flutter image has no node, so JS # actions like actions/checkout@v4 fail with "exec: node: not found". - name: Checkout env: TOKEN: ${{ github.token }} run: | git config --global --add safe.directory '*' git init -q . git remote add origin "http://x-access-token:${TOKEN}@forgejo:3000/${GITHUB_REPOSITORY}.git" git fetch -q --depth 1 origin "${GITHUB_SHA}" git checkout -q FETCH_HEAD - name: Generate code (i18n + Drift) working-directory: apps/app_seeds run: | flutter pub get dart run slang dart run build_runner build --delete-conflicting-outputs - name: Materialize signing material from secrets working-directory: apps/app_seeds env: TANE_KEYSTORE_BASE64: ${{ secrets.TANE_KEYSTORE_BASE64 }} TANE_KEYSTORE_PASSWORD: ${{ secrets.TANE_KEYSTORE_PASSWORD }} TANE_KEY_ALIAS: ${{ secrets.TANE_KEY_ALIAS }} TANE_KEY_PASSWORD: ${{ secrets.TANE_KEY_PASSWORD }} run: | echo "$TANE_KEYSTORE_BASE64" | base64 -d > "$GITHUB_WORKSPACE/tane-upload.jks" cat > android/key.properties <&2 tail -n 80 logs/*.log 2>/dev/null || true exit 1 fi # 6) Sign the unsigned APK with tane-upload and attach it to the Forgejo release. apksigner=$(find "$ANDROID_HOME" -name apksigner -type f 2>/dev/null | sort -V | tail -1) if [ -z "$apksigner" ]; then yes | sdkmanager "build-tools;34.0.0" >/dev/null 2>&1 || true apksigner=$(find "$ANDROID_HOME" -name apksigner -type f 2>/dev/null | sort -V | tail -1) fi echo "$TANE_KEYSTORE_BASE64" | base64 -d > /tmp/ks.jks out="/tmp/app-${ABI}-release.apk" "$apksigner" sign --ks /tmp/ks.jks --ks-key-alias "$TANE_KEY_ALIAS" \ --ks-pass "pass:$TANE_KEYSTORE_PASSWORD" --key-pass "pass:$TANE_KEY_PASSWORD" \ --out "$out" "$f" # Prove the signer cert matches AllowedAPKSigningKeys. "$apksigner" verify --print-certs "$out" | grep -i 'SHA-256' || true rm -f /tmp/ks.jks api="http://forgejo:3000/api/v1/repos/${GITHUB_REPOSITORY}" tag="${GITHUB_REF_NAME}" if [ "${GITHUB_REF_TYPE:-}" = tag ]; then curl -sf -X POST "$api/releases" \ -H "Authorization: token ${TOKEN}" -H 'Content-Type: application/json' \ -d "{\"tag_name\":\"${tag}\",\"name\":\"${tag}\"}" >/dev/null || true rid=$(curl -sf -H "Authorization: token ${TOKEN}" "$api/releases/tags/${tag}" \ | python3 -c 'import sys,json;print(json.load(sys.stdin)["id"])') curl -sf -X POST "$api/releases/${rid}/assets?name=app-${ABI}-release.apk" \ -H "Authorization: token ${TOKEN}" \ -F "attachment=@${out};type=application/vnd.android.package-archive" echo "uploaded app-${ABI}-release.apk (from ${f##*/})" else echo "built+signed app-${ABI}-release.apk (dispatch: upload skipped)" fi