name: Generate APK Debug

on:
  # Triggers the workflow on push or pull request events but only for default and protected branches
  push:
    branches:
      - master
  pull_request:
    branches: 
      - master
jobs:
  build:

    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v3

      - name: Set Up JDK
        uses: actions/setup-java@v3
        with:
          distribution: 'zulu'
          java-version: '11'

      - name: Change wrapper permissions
        run: chmod +x ./gradlew

      - name: Run tests
        run: ./gradlew test

      # Create APK Debug
      - name: Build apk debug
        run: ./gradlew app:assembleDefaultDebug

      - name: Build apk fdroid-debug
        run: ./gradlew app:assembleFdroidDebug

      # Upload Artifact Build
      # Noted For Output [module-name]/build/outputs/apk
      - name: Upload apk debug
        uses: actions/upload-artifact@v3
        with:
          name: FoxMmm-debug
          path: app/build/outputs/apk/default/debug/app-default-debug.apk

      - name: Upload apk fdroid-debug
        uses: actions/upload-artifact@v3
        with:
          name: FoxMmm-fdroid-debug
          path: app/build/outputs/apk/fdroid/debug/app-fdroid-debug.apk
