name: Publish Android # Android apps are published for every new release and nightly schedule defaults: run: shell: bash on: schedule: - cron: '0 1 * * *' release: types: [published] workflow_dispatch: concurrency: group: build-android-release queue: max cancel-in-progress: false permissions: contents: read jobs: build-android-release: runs-on: depot-macos-latest environment: release permissions: contents: read id-token: write timeout-minutes: 60 env: ANDROID_HOME: /Users/runner/Library/Android/sdk ANDROID_SDK_ROOT: /Users/runner/Library/Android/sdk steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: persist-credentials: false - name: Set up environment uses: ./.github/actions/setup with: cache: 'false' - name: Build mobile web app run: yarn build:browser --mobile # Secrets (all in the `release` environment): # # - ANDROID_KEYSTORE_BASE64 / ANDROID_KEYSTORE_PASSWORD: a signing # keystore. Generate once with: # keytool -genkeypair -keystore actual-android.jks -storetype JKS \ # -alias actual -keyalg RSA -keysize 2048 -validity 10000 # Press Enter at the key-password prompt to reuse the keystore password. # The secret is `base64 -i actual-android.jks` and the keystore password. # Back up the key securely and supply it when enrolling in Play App Signing. - name: Build and verify signed Android release env: ANDROID_KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }} ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }} ANDROID_KEY_ALIAS: actual ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }} run: | umask 077 export ANDROID_KEYSTORE_PATH="$RUNNER_TEMP/actual-android-upload.jks" trap 'rm -f "$ANDROID_KEYSTORE_PATH"' EXIT printf '%s' "$ANDROID_KEYSTORE_BASE64" | base64 --decode > "$ANDROID_KEYSTORE_PATH" export PATH="$ANDROID_HOME/build-tools/36.0.0:$PATH" # Compute once for both artifacts, with the same minute precision as iOS. export ANDROID_VERSION_CODE=$(( $(date -u +%s) / 60 )) # The AAB command uses SHA-256 after cap build's SHA-1 signing. # Related upstream issue: https://github.com/ionic-team/capacitor/issues/8428 yarn workspace mobile-client release:android apksigner verify packages/mobile-client/build/app-release-signed.apk jarsigner -verify -strict -keystore "$ANDROID_KEYSTORE_PATH" -storepass:env ANDROID_KEYSTORE_PASSWORD packages/mobile-client/build/app-release-signed.aab "$ANDROID_KEY_ALIAS" - name: Upload signed Android artifacts uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: name: actual-android-release path: | packages/mobile-client/build/app-release-signed.apk packages/mobile-client/build/app-release-signed.aab - name: Install Fastlane run: | export GEM_HOME="$RUNNER_TEMP/fastlane-gems" echo "GEM_HOME=$GEM_HOME" >> "$GITHUB_ENV" gem install fastlane --version 2.241.2 --no-document # Secrets in the `release` environment: GOOGLE_PLAY_WIF_PROVIDER is the # full Workload Identity Provider resource name; GOOGLE_PLAY_SERVICE_ACCOUNT # is the email of the service account with testing and production release # access and Manage store presence permission for org.actualbudget. # Federation trust is restricted to this workflow # and the release environment. Requires the Google Play Android Developer API. # Setup: https://docs.cloud.google.com/iam/docs/workload-identity-federation-with-deployment-pipelines#impersonation - name: Authenticate to Google Play uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3 with: workload_identity_provider: ${{ secrets.GOOGLE_PLAY_WIF_PROVIDER }} service_account: ${{ secrets.GOOGLE_PLAY_SERVICE_ACCOUNT }} # Automatic publication after approval requires managed publishing to be off. - name: Upload to Google Play env: TRACK: ${{ github.event_name == 'release' && !github.event.release.prerelease && 'production' || 'alpha' }} # The store listing is shared across tracks; update it only for stable releases. SKIP_UPLOAD_LISTING: ${{ github.event_name != 'release' || github.event.release.prerelease }} FASTLANE_SKIP_UPDATE_CHECK: '1' FASTLANE_OPT_OUT_USAGE: '1' run: | "$GEM_HOME/bin/fastlane" supply \ --json_key "$GOOGLE_APPLICATION_CREDENTIALS" \ --package_name org.actualbudget \ --aab packages/mobile-client/build/app-release-signed.aab \ --track "$TRACK" \ --metadata_path packages/mobile-client/android/fastlane/metadata \ --skip_upload_metadata "$SKIP_UPLOAD_LISTING" \ --skip_upload_images "$SKIP_UPLOAD_LISTING" --skip_upload_screenshots "$SKIP_UPLOAD_LISTING" \ --rescue_changes_not_sent_for_review false