name: Deploy APK on GitHub

on:
  release:
    types:
      - created

env:
  GRADLE_FILE: "mobile/build.gradle"

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: Bump version
        run: |
          # Get and bump version code
          VERSION_CODE=$(grep 'versionCode' $GRADLE_FILE | sed -r 's/(.*) (.*)$/\2/')
          let VERSION_CODE++

          # Remove "-release$" and and "^refs/tags/" from version name
          TAG_NAME="${GITHUB_REF##*/}"
          VERSION_NAME="${TAG_NAME%-release}"

          echo "Replace versionCode with $VERSION_CODE"
          sed --in-place -r "s/versionCode (.*)/versionCode ${VERSION_CODE}/" $GRADLE_FILE
          echo "Replace versionName with $VERSION_NAME"
          sed --in-place -r "s/versionName \"(.*)\"/versionName \"${VERSION_NAME}\"/" $GRADLE_FILE
          
      - name: Select flavor
        run: |
          if $(echo "$GITHUB_REF" | grep -q "beta")
          then
              echo "releaseFlavor=Beta"   >> $GITHUB_ENV
          else
              echo "releaseFlavor=Stable" >> $GITHUB_ENV
          fi
          echo "Use $releaseFlavor"
          
      - name: Build APK
        run: bash gradlew :mobile:assembleFull${releaseFlavor}Release
        
      - uses: r0adkll/sign-android-release@v1
        name: Sign APK
        id: sign_app
        with:
          releaseDirectory: mobile/build/outputs/apk/full${{ env.releaseFlavor }}/release
          signingKeyBase64: ${{ secrets.SIGNING_KEY }}
          alias: "sign"
          keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
          keyPassword: ${{ secrets.KEY_STORE_PASSWORD }}
          
      - uses: actions/upload-artifact@v2
        with:
          name: APK
          path: ${{steps.sign_app.outputs.signedReleaseFile}}

Add workflow for signing and deploying APK
Add workflow for signing and deploying APK

Signed-off-by: mueller-ma <fac07b9175991ebb2e15926da5ff5c758acad074@users.noreply.github.com>