name: Create Release

on:
  push:
    tags:
      - '*'

jobs:
  build:
    name: Create Release
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: set up JDK 17
        uses: actions/setup-java@v1
        with:
          java-version: 17

      - name: Create release.keystore
        env:
          AUTH: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
        run: echo $AUTH | base64 --decode > /tmp/release.keystore
        shell: bash

      - name: Setup Ruby
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: '2.7.2'

      - name: Publish to Google Play
        uses: maierj/fastlane-action@v3.1.0
        env:
          APP_SIGN_KEYSTORE_PATH: /tmp/release.keystore
          APP_SIGN_STORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
          APP_SIGN_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
          APP_SIGN_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }}
          APP_VERSION_NAME: ${{ github.ref }}
          APP_VERSION_CODE: ${{ github.GITHUB_RUN_ID }}
          SUPPLY_JSON_KEY_DATA: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_KEY }}
        with:
          lane: deploy
          subdirectory: fastlane
