BigBrainParking/.forgejo/workflows/build-apk.yml
Hank 5d269bf2a3
All checks were successful
build-apk / build (push) Successful in 35m3s
Fix release signing in CI: anchor plugin regex to buildTypes release block
The signing plugin added a release{} inside signingConfigs{}, so the debug-line
replacement matched that block instead of the release BUILD TYPE — CI produced
debug-signed APKs (would break Obtainium updates vs the release-signed v0.1.0).
Anchor on `buildTypes { ... release {`. Verified locally: release buildType now
uses the release key when BBP_UPLOAD_* is set. Also unify keystore path via
github.workspace in both steps.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-07 19:49:37 -07:00

75 lines
3.4 KiB
YAML

# Build a signed release APK and publish it as a Forgejo release on every v* tag.
# Obtainium then tracks releases and offers the update.
#
# Requires:
# - A Forgejo Actions RUNNER registered to this repo/instance (see docs/DISTRIBUTION.md),
# with a label this job's `runs-on` matches (adjust below to your runner's labels).
# - Repo Actions secrets: ANDROID_KEYSTORE_B64, ANDROID_KEYSTORE_PASSWORD,
# ANDROID_KEY_ALIAS, ANDROID_KEY_PASSWORD (already set).
#
# Release: bump `expo.version` in app/app.json, then: git tag v0.1.1 && git push origin v0.1.1
name: build-apk
on:
push:
tags:
- 'v*'
jobs:
build:
# Match this to a label your runner registered with (commonly "docker" or "ubuntu-latest").
runs-on: docker
# A purpose-built RN Android image (Android SDK + NDK + Node). Runner needs Docker.
container:
image: reactnativecommunity/react-native-android:latest
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: npm install
- name: Build the API client
run: npm run build --workspace parksmarter-client
# RN 0.79 wants a specific NDK; install it if the image doesn't ship it (best-effort).
- name: Ensure NDK
run: |
yes | sdkmanager --licenses >/dev/null 2>&1 || true
sdkmanager "ndk;27.1.12297006" >/dev/null 2>&1 || true
- name: Restore signing keystore
run: echo "${{ secrets.ANDROID_KEYSTORE_B64 }}" | base64 -d > "${{ github.workspace }}/app/release.keystore"
- name: Expo prebuild (generate android/)
working-directory: app
run: CI=1 npx expo prebuild --platform android --no-install
- name: Assemble signed release
working-directory: app/android
env:
BBP_UPLOAD_STORE_FILE: ${{ github.workspace }}/app/release.keystore
BBP_UPLOAD_STORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
BBP_UPLOAD_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }}
BBP_UPLOAD_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
# Force IPv4: the runner's container has no IPv6 route, so dl.google.com
# (Google Maven) is "Network is unreachable" over its default AAAA record.
GRADLE_OPTS: "-Djava.net.preferIPv4Stack=true -Dorg.gradle.jvmargs=-Djava.net.preferIPv4Stack=true"
run: ./gradlew :app:assembleRelease -PreactNativeArchitectures=arm64-v8a --no-daemon -Djava.net.preferIPv4Stack=true
# Self-contained publish via the Forgejo API (no external action to fetch).
- name: Publish release + upload APK
env:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -e
TAG="${GITHUB_REF_NAME}"
APK="$(ls app/android/app/build/outputs/apk/release/*.apk | head -1)"
ASSET="BigBrainParking-${TAG}.apk"
API="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}"
REL="$(curl -sf -X POST "$API/releases" -H "Authorization: token $TOKEN" \
-H "Content-Type: application/json" \
-d "{\"tag_name\":\"$TAG\",\"target_commitish\":\"main\",\"name\":\"BigBrainParking $TAG\",\"body\":\"Install/update via Obtainium.\"}")"
ID="$(printf '%s' "$REL" | node -e "let s='';process.stdin.on('data',d=>s+=d).on('end',()=>console.log(JSON.parse(s).id))")"
curl -sf -X POST "$API/releases/$ID/assets?name=$ASSET" \
-H "Authorization: token $TOKEN" -F "attachment=@$APK"
echo "Published $TAG"