name: Build & Release APK on: push: branches: [main] jobs: build: # Builds on Marcus's MacBook: runner label `macos`, host mode (no container), # using the Node, JDK 21 and Android SDK set in the runner's config.yaml. # Jobs queue while the laptop is asleep or offline. # (Was `desktop` + a Linux container until 2026-11-24.) runs-on: macos steps: - name: Checkout run: | git init -q . git fetch -q --depth 1 "https://git.rehbock.xyz/${{ github.repository }}.git" "${{ github.sha }}" git checkout -q FETCH_HEAD - name: Toolchain run: | node --version java -version 2>&1 | head -1 test -d "$ANDROID_HOME/platforms" && echo "Android SDK: $ANDROID_HOME" - name: npm ci run: npm ci --no-audit --no-fund - name: Decode signing keystore env: KEYSTORE_B64: ${{ secrets.KEYSTORE_B64 }} run: echo "$KEYSTORE_B64" | base64 -d > "$PWD/.release.jks" - name: Prebuild android project env: VERSION_CODE: ${{ github.run_number }} VERSION_NAME: 1.0.${{ github.run_number }} run: npx expo prebuild --platform android --no-install - name: Build signed release APK (arm64) env: KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} KEY_ALIAS: health VERSION_CODE: ${{ github.run_number }} VERSION_NAME: 1.0.${{ github.run_number }} run: | export HEALTH_KEYSTORE="$PWD/.release.jks" echo "sdk.dir=$ANDROID_HOME" > android/local.properties cd android && ./gradlew assembleRelease -PreactNativeArchitectures=arm64-v8a \ --no-daemon --console=plain - name: Publish Gitea release with APK env: TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | API="https://git.rehbock.xyz/api/v1/repos/${{ github.repository }}" TAG="v1.0.${{ github.run_number }}" APK=android/app/build/outputs/apk/release/app-release.apk test -f "$APK" curl -sf -X POST "$API/releases" \ -H "Authorization: token $TOKEN" -H "Content-Type: application/json" \ -d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\",\"body\":\"Automated build of commit ${{ github.sha }}\",\"target_commitish\":\"${{ github.sha }}\"}" \ > "$PWD/.release.json" RID=$(grep -o '"id":[0-9]*' "$PWD/.release.json" | head -1 | cut -d: -f2) echo "release id: $RID" curl -sf -X POST "$API/releases/$RID/assets?name=health-app-$TAG-arm64.apk" \ -H "Authorization: token $TOKEN" \ -F "attachment=@$APK;type=application/vnd.android.package-archive" >/dev/null echo "published $TAG"