|
| 1 | +# When a GitHub Release is published (e.g. by club-calendar-version.yml), build Android on EAS and upload the APK. |
| 2 | +# |
| 3 | +# Prerequisites (one-time): |
| 4 | +# 1. expo.dev → Access tokens → create token → repo secret EXPO_TOKEN |
| 5 | +# 2. Locally: npx eas-cli login && npx eas-cli build -p android --profile github-apk |
| 6 | +# (completes EAS project link, credentials, and writes extra.eas.projectId into app config) |
| 7 | +# 3. Commit eas.json and any app.json / app.config.js changes EAS produced. |
| 8 | +# |
| 9 | +# Private git submodules: if checkout fails, add actions/checkout `token` using a PAT with |
| 10 | +# repo access, or switch submodule URLs to HTTPS. |
| 11 | + |
| 12 | +name: Release Android to GitHub |
| 13 | + |
| 14 | +on: |
| 15 | + release: |
| 16 | + types: [published] |
| 17 | + |
| 18 | +permissions: |
| 19 | + contents: write |
| 20 | + |
| 21 | +jobs: |
| 22 | + eas-android-apk: |
| 23 | + if: ${{ !github.event.release.draft }} |
| 24 | + runs-on: ubuntu-latest |
| 25 | + steps: |
| 26 | + - name: Checkout (with submodules) |
| 27 | + uses: actions/checkout@v4 |
| 28 | + with: |
| 29 | + ref: ${{ github.event.release.tag_name }} |
| 30 | + fetch-depth: 0 |
| 31 | + submodules: recursive |
| 32 | + |
| 33 | + - name: Setup Node.js |
| 34 | + uses: actions/setup-node@v4 |
| 35 | + with: |
| 36 | + node-version: "20.x" |
| 37 | + cache: npm |
| 38 | + |
| 39 | + - name: Install dependencies |
| 40 | + run: npm ci |
| 41 | + |
| 42 | + - name: Setup EAS |
| 43 | + uses: expo/expo-github-action@v8 |
| 44 | + with: |
| 45 | + eas-version: latest |
| 46 | + token: ${{ secrets.EXPO_TOKEN }} |
| 47 | + |
| 48 | + - name: EAS Build (Android APK, wait for completion) |
| 49 | + id: eas |
| 50 | + run: | |
| 51 | + set -euo pipefail |
| 52 | + BUILD_JSON=$(eas build \ |
| 53 | + --platform android \ |
| 54 | + --profile github-apk \ |
| 55 | + --non-interactive \ |
| 56 | + --wait \ |
| 57 | + --json) |
| 58 | + echo "$BUILD_JSON" | tee eas-build.json |
| 59 | + URL=$(echo "$BUILD_JSON" | jq -r ' |
| 60 | + if type == "array" then .[] else . end |
| 61 | + | .artifacts.applicationArchiveUrl // empty |
| 62 | + ' | head -1) |
| 63 | + if [ -z "$URL" ] || [ "$URL" = "null" ]; then |
| 64 | + echo "Could not read applicationArchiveUrl from EAS output" |
| 65 | + cat eas-build.json |
| 66 | + exit 1 |
| 67 | + fi |
| 68 | + echo "url=$URL" >> "$GITHUB_OUTPUT" |
| 69 | +
|
| 70 | + - name: Download APK |
| 71 | + env: |
| 72 | + URL: ${{ steps.eas.outputs.url }} |
| 73 | + run: | |
| 74 | + set -euo pipefail |
| 75 | + TAG="${{ github.event.release.tag_name }}" |
| 76 | + OUT="BSR-SolarCar2-${TAG}.apk" |
| 77 | + curl -fL --retry 3 -o "$OUT" "$URL" |
| 78 | + ls -la "$OUT" |
| 79 | +
|
| 80 | + - name: Upload APK to release |
| 81 | + env: |
| 82 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 83 | + run: | |
| 84 | + TAG="${{ github.event.release.tag_name }}" |
| 85 | + gh release upload "$TAG" "BSR-SolarCar2-${TAG}.apk" --clobber |
0 commit comments