name: Build mobile android concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true on: workflow_dispatch: inputs: tag: description: "Tag to build (e.g., v1.0.0)" required: true submit_to_store_review: description: "Submit the uploaded build for store review" type: boolean default: false permissions: {} jobs: build_android: runs-on: ubuntu-latest timeout-minutes: 60 permissions: contents: read actions: write steps: - name: Setup Node.js uses: actions/setup-node@v6 with: node-version: 24.x - name: Checkout uses: actions/checkout@v6 with: ref: ${{ github.event.inputs.tag }} - name: Validate tag # Ask the remote for this one tag instead of fetching every branch and tag # (`git fetch --all --tags` took ~4 minutes on this repository). env: TAG: ${{ github.event.inputs.tag }} run: | if ! git ls-remote --exit-code --tags origin "refs/tags/${TAG}" > /dev/null; then echo "Error: Tag ${TAG} does not exist." exit 1 fi - name: Setup bun uses: oven-sh/setup-bun@v2 with: bun-version: latest - name: Install dependencies # Force bun's hoisted (flat) node_modules layout. The monorepo defaults to # bun's isolated linker (node_modules/.bun/@+ + symlinks), # which Capacitor's Gradle subprojects can't resolve (../node_modules/@capacitor/ # /android), producing "No variants exist". Hoisted lays real folders. run: bun install --frozen-lockfile --linker=hoisted - name: Prepare mobile project # Use `cap sync android` instead of build:mobile's `cap copy`. `cap copy` # only pushes web assets + config; `cap sync` also runs `cap update`, which # regenerates the cordova plugins subproject including # android/capacitor-cordova-android-plugins/cordova.variables.gradle. # That dir is gitignored, so the remote builder never receives it unless we # regenerate it here before `capgo build request` uploads the workspace. run: | bun run build bash scripts/vendor-workspace-native-plugins.sh bunx cap sync android - name: Add Firebase config for push notifications # google-services.json is gitignored. Without it the google-services Gradle # plugin is skipped and FCM (Capgo update pushes) cannot start on Android. env: GOOGLE_SERVICES_JSON: ${{ secrets.GOOGLE_SERVICES_JSON }} run: | if [ -n "$GOOGLE_SERVICES_JSON" ]; then printf '%s' "$GOOGLE_SERVICES_JSON" > android/app/google-services.json else echo "::warning::GOOGLE_SERVICES_JSON secret is missing; Android push notifications are disabled in this build" fi - name: Request Android build through Capgo CLI env: CAPGO_TOKEN: ${{ secrets.CAPGO_TOKEN }} ANDROID_KEYSTORE_FILE: ${{ secrets.ANDROID_KEYSTORE_FILE }} PLAY_CONFIG_JSON: ${{ secrets.PLAY_CONFIG_JSON }} KEYSTORE_KEY_ALIAS: ${{ secrets.KEYSTORE_KEY_ALIAS }} KEYSTORE_KEY_PASSWORD: ${{ secrets.KEYSTORE_KEY_PASSWORD }} KEYSTORE_STORE_PASSWORD: ${{ secrets.KEYSTORE_STORE_PASSWORD }} BUILD_OUTPUT_UPLOAD_ENABLED: "true" BUILD_OUTPUT_RETENTION_SECONDS: "604800" SUBMIT_TO_STORE_REVIEW: ${{ github.event.inputs.submit_to_store_review }} run: | submit_args=() if [ "$SUBMIT_TO_STORE_REVIEW" = "true" ]; then submit_args=(--submit-to-store-review --store-release-notes "Bug fixes and performance improvements.") fi bunx @capgo/cli@latest build request --platform android --path . --sync-android-version --ai-analytics "${submit_args[@]}"