diff --git a/.claude/skills/android-generate/SKILL.md b/.claude/skills/android-generate/SKILL.md index 12e8538084..41ae7d4269 100644 --- a/.claude/skills/android-generate/SKILL.md +++ b/.claude/skills/android-generate/SKILL.md @@ -7,6 +7,30 @@ description: Build the Android APK for the mobile app by running npm run android Runs the project's existing Android APK release command. +The APK bakes in `EXPO_PUBLIC_API_BASE` at prebuild time, so the API the build targets is decided by the environment present when the script runs. Default (no env set) builds against prod (`https://api.useorbit.org`). + ## Steps +### Prod (default) + 1. From the repo root, run `npm run android:apk -w @orbit/mobile`. The `android:apk` script is defined in the `apps/mobile` workspace (`node scripts/android-release-apk.js`), not at the root, so it must be targeted with `-w @orbit/mobile`. + +### QA + +Build against the QA API instead of prod by exporting the QA base (and forcing AdMob test IDs so the QA build never serves live ads) before running the same command. The QA API base is the public QA endpoint `https://api-qa.useorbit.org`. + +- PowerShell: + + ```powershell + $env:EXPO_PUBLIC_API_BASE = "https://api-qa.useorbit.org" + $env:EXPO_PUBLIC_ADMOB_USE_TEST_IDS = "true" + npm run android:apk -w @orbit/mobile + ``` + +- bash: + + ```bash + EXPO_PUBLIC_API_BASE="https://api-qa.useorbit.org" \ + EXPO_PUBLIC_ADMOB_USE_TEST_IDS="true" \ + npm run android:apk -w @orbit/mobile + ``` diff --git a/.github/workflows/android-release.yml b/.github/workflows/android-release.yml index b33e4a1063..9c6a74b0cc 100644 --- a/.github/workflows/android-release.yml +++ b/.github/workflows/android-release.yml @@ -185,7 +185,33 @@ jobs: ${{ secrets.GOOGLE_PLAY_SERVICE_ACCOUNT_JSON }} EOF + - name: Resolve build target (prod vs QA) + shell: bash + env: + RELEASE_TRACK: ${{ inputs.track }} + QA_API_BASE: ${{ vars.QA_API_BASE }} + PROD_API_BASE: https://api.useorbit.org + run: | + set -euo pipefail + + if [ "${RELEASE_TRACK}" = "internal" ]; then + if [ -z "${QA_API_BASE}" ]; then + echo "::error::The internal track builds against QA, but vars.QA_API_BASE is not set. Configure it under repo Settings → Secrets and variables → Actions → Variables." >&2 + exit 1 + fi + echo "BUILD_API_BASE=${QA_API_BASE}" >> "${GITHUB_ENV}" + echo "BUILD_ADMOB_USE_TEST_IDS=true" >> "${GITHUB_ENV}" + echo "BUILD_EAS_PROFILE=qa" >> "${GITHUB_ENV}" + echo "Build target: QA (api_base=${QA_API_BASE}, test AdMob IDs)" + else + echo "BUILD_API_BASE=${PROD_API_BASE}" >> "${GITHUB_ENV}" + echo "BUILD_ADMOB_USE_TEST_IDS=false" >> "${GITHUB_ENV}" + echo "BUILD_EAS_PROFILE=production" >> "${GITHUB_ENV}" + echo "Build target: PROD (api_base=${PROD_API_BASE}, real AdMob IDs)" + fi + - name: Validate Expo config resolves production AdMob IDs + if: ${{ inputs.track != 'internal' }} working-directory: ${{ env.RELEASE_WORKDIR }}/apps/mobile shell: bash env: @@ -204,12 +230,19 @@ jobs: env: CI: "1" EXPO_NO_TELEMETRY: "1" + EAS_BUILD_PROFILE: ${{ env.BUILD_EAS_PROFILE }} + EXPO_PUBLIC_API_BASE: ${{ env.BUILD_API_BASE }} + EXPO_PUBLIC_ADMOB_USE_TEST_IDS: ${{ env.BUILD_ADMOB_USE_TEST_IDS }} run: | set -euo pipefail + echo "Prebuild API base: ${EXPO_PUBLIC_API_BASE}" + echo "Prebuild AdMob test IDs: ${EXPO_PUBLIC_ADMOB_USE_TEST_IDS}" + npx expo prebuild --platform android --no-install - name: Validate generated Android project does not contain sample AdMob IDs + if: ${{ inputs.track != 'internal' }} working-directory: ${{ env.RELEASE_WORKDIR }}/apps/mobile shell: bash run: | @@ -259,6 +292,9 @@ jobs: shell: bash env: CLEAR_CACHE: ${{ inputs.clear_cache }} + EAS_BUILD_PROFILE: ${{ env.BUILD_EAS_PROFILE }} + EXPO_PUBLIC_API_BASE: ${{ env.BUILD_API_BASE }} + EXPO_PUBLIC_ADMOB_USE_TEST_IDS: ${{ env.BUILD_ADMOB_USE_TEST_IDS }} run: | set -euo pipefail @@ -271,6 +307,7 @@ jobs: ./gradlew --no-daemon bundleRelease - name: Verify shipped AAB embeds production AdMob IDs + if: ${{ inputs.track != 'internal' }} working-directory: ${{ env.RELEASE_WORKDIR }}/apps/mobile shell: bash run: | diff --git a/apps/mobile/eas.json b/apps/mobile/eas.json index 9a866a3fb0..744cb7a4cd 100644 --- a/apps/mobile/eas.json +++ b/apps/mobile/eas.json @@ -25,6 +25,16 @@ "EXPO_PUBLIC_ADMOB_USE_TEST_IDS": "true" } }, + "qa": { + "distribution": "internal", + "android": { + "buildType": "apk" + }, + "env": { + "EXPO_PUBLIC_API_BASE": "https://api-qa.useorbit.org", + "EXPO_PUBLIC_ADMOB_USE_TEST_IDS": "true" + } + }, "production": { "distribution": "store", "android": { @@ -47,6 +57,13 @@ "releaseStatus": "completed" } }, + "qa": { + "android": { + "serviceAccountKeyPath": "./play-service-account.json", + "track": "internal", + "releaseStatus": "completed" + } + }, "closed": { "android": { "serviceAccountKeyPath": "./play-service-account.json",