name: Android release build

on:
  workflow_dispatch:
    inputs:
      versionName:
        description: 'User-facing release version name'
        required: true
        default: ""
      versionCode:
        description: 'versionCode or build number'
        required: true
        default: ''

jobs:
  signed-build:
    runs-on: ubuntu-latest
    steps:
      - name: Setup build environment
        uses: msfjarvis/compose-lobsters/.github/reusable-workflows/setup-gradle@main
        with:
          cache-read-only: true

      - name: Build release app
        run: |
          ./scripts/setup-age.sh
          ./scripts/signing-setup.sh "$AGE_SECRET_KEY"
          ./gradlew --no-configuration-cache --stacktrace -PenableSentry collectReleaseBundle
          ./scripts/signing-cleanup.sh
        env:
          AGE_SECRET_KEY: ${{ secrets.AGE_SECRET_KEY }}
          SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
          SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
          ORG_GRADLE_PROJECT_VERSION_NAME: ${{ github.event.inputs.versionName }}
          ORG_GRADLE_PROJECT_VERSION_CODE: ${{ github.event.inputs.versionCode }}

      - name: Upload app bundle
        uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
        with:
          name: release-aab
          path: android/build/outputs/bundle/release/android-release.aab
