name: build-flutter

on:
  push:
    branches: ['main']
  pull_request:
    branches: ['main']

jobs:
  build-apk:
    runs-on: ubuntu-22.04
    steps:
      - uses: actions/checkout@v3

      - uses: subosito/flutter-action@v2
        with:
          flutter-version: '3.7.11'
          channel: 'stable'
          cache: true

      - run: cp .env.example .env
      - run: flutter pub get
      - run: flutter analyze
      - run: flutter build apk

      - run: mv build/app/outputs/flutter-apk/app-release.apk subtracks-$(git rev-parse --short HEAD).apk
      - uses: actions/upload-artifact@v3
        with:
          name: subtracks-testing
          path: subtracks-*.apk
