name: Release

on:
  release:
    types: [released]

jobs:

  release:
    runs-on: ubuntu-latest

    steps:

      - uses: actions/checkout@v2

      - uses: actions/setup-java@v1
        with:
          java-version: 11

      - run: |
          chmod +x ./gradlew
          ./gradlew :app:bundleBlueRelease

      - uses: r0adkll/sign-android-release@v1
        with:
          releaseDirectory: app/build/outputs/bundle/blueRelease
          signingKeyBase64: ${{ secrets.SIGNING_KEY }}
          alias: ${{ secrets.ALIAS }}
          keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
          keyPassword: ${{ secrets.KEY_PASSWORD }}

      - uses: r0adkll/upload-google-play@v1.0.17
        with:
          serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }}
          packageName: net.accelf.yuito
          releaseFile: ${{ env.SIGNED_RELEASE_FILE }}
          track: production
          whatsNewDirectory: changelogs/${{ github.event.release.tag_name }}
