name: Deploy App Play Store

on:
  push:
#     branches: 
#     - master
    tags: 
      - 'v*'

jobs:
  build:
    runs-on: ubuntu-latest
    steps:

      - uses: actions/checkout@v4
    
      - name: Setting up project
        uses: ./.github/actions/setup

      - name: Build with Gradle
        id: build
        run: ./gradlew build

      - name: Build Release AAB
        id: buildRelease
        run: ./gradlew bundleRelease

      - name: Sign AAB
        id: sign
        uses: r0adkll/sign-android-release@fix/bundle-signing
        with:
          releaseDirectory: app/build/outputs/bundle/release
          signingKeyBase64: ${{ secrets.SIGNING_KEY }}
          alias: ${{ secrets.ALIAS }}
          keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
          keyPassword: ${{ secrets.KEY_PASSWORD }}

      - name: Create service_account.json
        id: createServiceAccount
        run: echo '${{ secrets.SERVICE_ACCOUNT_JSON }}' > service_account.json


          
      - name: Deploy to Play Store (PROD)
        id: deployProd
        uses: r0adkll/upload-google-play@v1.1.3
        with:
          serviceAccountJson: service_account.json
          packageName: com.yogeshpaliyal.keypass
          releaseFiles: app/build/outputs/bundle/release/*.aab
          track: production
          userFraction: 0.01
          status: inProgress
          whatsNewDirectory: whatsnew/
