name: Android

on:
  workflow_dispatch:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        config: [debug, release]
        include:
          - config: debug
            target: assembleDebug
            apkname: espeak-debug.apk
          - config: release
            target: assembleRelease
            apkname: espeak-release-unsigned.apk
    name: Build ${{ matrix.config }} APK
    steps:
      - uses: actions/checkout@v3
      - name: Set up JDK 17
        uses: actions/setup-java@v3
        with:
          distribution: 'temurin'
          java-version: 17
          cache: gradle
      - name: make
        run: cd android && ./gradlew ${{ matrix.target }} --no-daemon
      - name: upload
        uses: actions/upload-artifact@v3
        with:
          name: android-${{ matrix.config }}.apk
          path: android/build/outputs/apk/${{ matrix.config }}/${{ matrix.apkname }}
          retention-days: 5
