name: Android Release

on:
  workflow_dispatch:

jobs:
  android:
    runs-on: ubuntu-latest

    steps:
      - name: 代码迁出
        uses: actions/checkout@v3

      - name: 构建Java环境
        uses: actions/setup-java@v3
        with:
          distribution: "zulu"
          java-version: "17"

      - name: 检查缓存
        uses: actions/cache@v2
        id: cache-flutter
        with:
          path: /root/flutter-sdk # Flutter SDK 的路径
          key: ${{ runner.os }}-flutter-${{ hashFiles('**/pubspec.lock') }}

      - name: 安装Flutter
        if: steps.cache-flutter.outputs.cache-hit != 'true'
        uses: subosito/flutter-action@v2
        with:
          flutter-version: 3.24.0
          channel: any

      - name: 下载项目依赖
        run: flutter pub get

      - name: flutter build apk
        run: flutter build apk --release --target-platform=android-arm64

      - name: 上传
        uses: actions/upload-artifact@v3
        with:
          name: Pilipala-Release
          path: |
            build/app/outputs/flutter-apk/*.apk
