name: pulsebridge-app publish

on:
  push:
    tags:
      - v*.*.*

env:
  ANDROID_KEY_ALIAS: key0
  ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }}
  ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
  ANDROID_KEYSTORE_PATH: pulsebridge.jks

jobs:
  deploy:
    name: Build
    runs-on: ubuntu-22.04
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-java@v2
        with:
          distribution: 'temurin'
          java-version: '17'
      - uses: android-actions/setup-android@v2
      - run: yes | sdkmanager 'platforms;android-28'
    #  - name: Decrypt keystore
    #    run: openssl aes-256-cbc -K ${{ secrets.ANDROID_KEYSTORE_SSL_KEY }} -iv ${{ secrets.ANDROID_KEYSTORE_SSL_IV }} -in pulsebridge.jks.enc -out pulsebridge.jks -d
      - name: Make gradlew executable
        run: chmod +x ./gradlew
      - run: make assemble-release
        env:
          GIT_TAG: ${{ github.ref_name }}
      - name: GitHub release
        uses: softprops/action-gh-release@v1
        if: startsWith(github.ref, 'refs/tags/')
        with:
          draft: true
          files: ./build/outputs/apk/**/release/*.apk