name: Flutter Schmutter

on:
  push:
    branches:
      - master

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: checkout code
        uses: actions/checkout@v4
      
      - name: set up jdk
        uses: actions/setup-java@v3
        with:
          java-version: '21'
      
      - name: install android sdk
        run: |
          sudo apt update
          sudo apt install -y wget unzip
          wget https://dl.google.com/android/repository/commandlinetools-linux-7583922_latest.zip
          mkdir -p $HOME/android/sdk/cmdline-tools
          unzip commandlinetools-linux-7583922_latest.zip -d $HOME/android/sdk/cmdline-tools
          yes | $HOME/android/sdk/cmdline-tools/bin/sdkmanager --sdk_root=$HOME/android/sdk --licenses
          $HOME/android/sdk/cmdline-tools/bin/sdkmanager --sdk_root=$HOME/android/sdk "platform-tools" "platforms;android-35"

      - name: set ANDROID_HOME
        run: echo "ANDROID_HOME=$HOME/android/sdk" >> $GITEA_ENV
      
      - name: setup flutter
        uses: subosito/flutter-action@v2
        with:
          flutter-version: 3.33.0-0.2.pre
          channel: master

      - name: install deps
        run: flutter pub get
        env:
          TAR_OPTIONS: --no-same-owner
      
      - name: build apk
        run: flutter build apk --release
