| 1 | # Builds the phone app for Android on EAS, to install from a link or a QR |
| 2 | # code before it is in Google Play. Nothing is published: the run's summary |
| 3 | # links the build's page on expo.dev, which shows the QR code, and the APK. |
| 4 | # |
| 5 | # - `preview` (default): g1t (beta), sh.g1t.app.preview, a standalone signed |
| 6 | # APK that needs no computer: what testers install, from the build page's |
| 7 | # QR code. Code changes reach it over the air (`eas update --channel |
| 8 | # preview`), so it is built again only when the native side changes; on |
| 9 | # main that happens by itself (the paths below). mobile-release.yml |
| 10 | # publishes these on g1t.sh/download. |
| 11 | # - `development`: g1t (dev), sh.g1t.app.dev, with expo-dev-client. It loads |
| 12 | # the app's code from `npx expo start` on your computer. |
| 13 | # |
| 14 | # Needs the repository secret EXPO_TOKEN (an Expo access token with access |
| 15 | # to @flagon-io/g1t). |
| 16 | name: Mobile build |
| 17 | |
| 18 | on: |
| 19 | push: |
| 20 | branches: [main] |
| 21 | paths: |
| 22 | - apps/mobile/app.config.ts |
| 23 | - apps/mobile/eas.json |
| 24 | - apps/mobile/package.json |
| 25 | - apps/mobile/assets/images/** |
| 26 | workflow_dispatch: |
| 27 | inputs: |
| 28 | profile: |
| 29 | description: "The EAS build profile" |
| 30 | type: choice |
| 31 | options: [preview, development] |
| 32 | default: preview |
| 33 | |
| 34 | permissions: |
| 35 | contents: read |
| 36 | |
| 37 | concurrency: |
| 38 | group: mobile-build-${{ inputs.profile || 'preview' }} |
| 39 | cancel-in-progress: true |
| 40 | |
| 41 | jobs: |
| 42 | build: |
| 43 | name: Build Android (${{ inputs.profile || 'preview' }}) on EAS |
| 44 | runs-on: ubuntu-latest |
| 45 | timeout-minutes: 60 |
| 46 | env: |
| 47 | PROFILE: ${{ inputs.profile || 'preview' }} |
| 48 | steps: |
| 49 | - uses: actions/checkout@v5 |
| 50 | - name: Cache npm's downloads |
| 51 | uses: actions/cache/restore@v4 |
| 52 | with: |
| 53 | path: ~/.npm |
| 54 | key: npm-full-${{ runner.os }}-${{ hashFiles('package-lock.json') }} |
| 55 | restore-keys: npm-full-${{ runner.os }}- |
| 56 | # EAS reads app.config.ts through the app's own `expo`. |
| 57 | - name: Install the app's dependencies |
| 58 | run: node scripts/deploy/npm-ci.mjs --prefer-offline --no-audit --no-fund -w @g1t/mobile |
| 59 | - name: Build on EAS |
| 60 | working-directory: apps/mobile |
| 61 | env: |
| 62 | EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }} |
| 63 | run: | |
| 64 | # A token pasted with a newline breaks the request's header. |
| 65 | export EXPO_TOKEN="$(printf %s "$EXPO_TOKEN" | tr -d '[:space:]')" |
| 66 | npx --yes eas-cli@24.12.1 whoami |
| 67 | npx --yes eas-cli@24.12.1 build --platform android --profile "$PROFILE" \ |
| 68 | --non-interactive --wait --json > build.json |
| 69 | node -e ' |
| 70 | const [build] = JSON.parse(require("fs").readFileSync("build.json", "utf8")); |
| 71 | const page = `https://expo.dev/accounts/flagon-io/projects/g1t/builds/${build.id}`; |
| 72 | const lines = [ |
| 73 | `### g1t for Android, ${process.env.PROFILE} build`, |
| 74 | "", |
| 75 | `- Status: ${build.status}`, |
| 76 | `- Version: ${build.appVersion} (versionCode ${build.appBuildVersion})`, |
| 77 | `- Install: open [the build on expo.dev](${page}) and scan its QR code with the phone`, |
| 78 | build.artifacts?.buildUrl ? `- APK: ${build.artifacts.buildUrl}` : "", |
| 79 | ]; |
| 80 | console.log(lines.join("\n")); |
| 81 | require("fs").appendFileSync(process.env.GITHUB_STEP_SUMMARY, lines.join("\n") + "\n"); |
| 82 | if (build.status !== "FINISHED") process.exit(1); |
| 83 | ' |