name: Android CI Release
permissions:
  contents: read

on:
  workflow_dispatch:
  push:
    branches: [ "release/*"]

env:
  KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
  RELEASE_SIGN_KEY_ALIAS: ${{ secrets.RELEASE_SIGN_KEY_ALIAS }}
  RELEASE_SIGN_KEY_PASSWORD: ${{ secrets.RELEASE_SIGN_KEY_PASSWORD }}

jobs:
  create_release:
    runs-on: ubuntu-24.04
    name: Build artifacts
    steps:
      - name: Checkout
        uses: actions/checkout@v5

      - name: set up JDK 21
        uses: actions/setup-java@v5
        with:
          java-version: '21'
          distribution: 'temurin'
          cache: gradle

      - name: Grant execute permission for gradlew
        run: chmod +x gradlew

      - name: Build and sign release APK
        run: ./gradlew assembleRelease

      - name: Upload release APK
        uses: actions/upload-artifact@v7
        with:
          name: app-release.apk
          path: app/build/outputs/apk/release/app-release.apk

      - name: Build and sign release Bundle
        run: ./gradlew bundleRelease

      - name: Upload release Bundle
        uses: actions/upload-artifact@v7
        with:
          name: app-release.aab
          path: app/build/outputs/bundle/release/app-release.aab
