name: "Build Android"

on:
  workflow_call:
    inputs:
      build-number:
        required: true
        type: string

    secrets:
      KEY_JKS:
        required: true
      KEY_PROPERTIES:
        required: true

jobs:
  build-playstore-package:
    name: Play Store
    runs-on: ubuntu-latest
    steps:
      - name: Setup Environment
        uses: JagandeepBrar/lunasea/.github/actions/prepare_for_build@master
        with:
          platform: android
          android-key-jks: ${{ secrets.KEY_JKS }}
          android-key-properties: ${{ secrets.KEY_PROPERTIES }}

      - name: Build LunaSea
        working-directory: ${{ github.workspace }}/android
        run: bundle exec fastlane build_aab build_number:${{ inputs.build-number }}

      - name: Upload Artifact
        uses: actions/upload-artifact@v4
        with:
          name: android-playstore-package
          path: ${{ github.workspace }}/output

  build-app-package:
    name: App Package
    runs-on: ubuntu-latest
    steps:
      - name: Setup Environment
        uses: JagandeepBrar/lunasea/.github/actions/prepare_for_build@master
        with:
          platform: android
          android-key-jks: ${{ secrets.KEY_JKS }}
          android-key-properties: ${{ secrets.KEY_PROPERTIES }}

      - name: Build LunaSea
        working-directory: ${{ github.workspace }}/android
        run: bundle exec fastlane build_apk build_number:${{ inputs.build-number }}

      - name: Upload Artifact
        uses: actions/upload-artifact@v4
        with:
          name: android-app-package
          path: ${{ github.workspace }}/output
