name: build-release-debugsign

on:
  push:
    paths-ignore:
      - assets/**
      - README.md
      - LICENSE
    branches:
      - master
      - release/*
  pull_request:
    paths-ignore:
      - assets/**
      - README.md
      - LICENSE
    branches:
      - master

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          submodules: recursive
      - run: |
          rm submodules/ExoPlayer/gradle/wrapper/gradle-wrapper.jar
      - uses: actions/setup-node@v2
        with:
          node-version: '14'
          cache: 'yarn'
      - run: |
          yarn install
      - run: |
          yarn lint --max-warnings 0
      - run: |
          yarn license
      - run: |
          scripts/prepare-exoplayer-ffmpeg.sh
      - uses: gradle/wrapper-validation-action@v1
      - uses: gradle/gradle-build-action@v1
        with:
          distributions-cache-enabled: true
          dependencies-cache-enabled: true
          configuration-cache-enabled: true
          build-root-directory: android
          arguments: assembleRelease -PsignReleaseWithDebug=true
      - run: |
          mkdir bin
      - run: >
          mv android/app/build/outputs/apk/release/app-release.apk
          bin/subtracks-${GITHUB_SHA}.apk
      - uses: actions/upload-artifact@v2
        with:
          name: subtracks-testing
          path: bin/*
