name: Dart and Flutter Build

on:
  workflow_dispatch:  # 手动触发

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      # 安装 Flutter
      - name: Install Flutter
        run: |
          git clone https://github.com/flutter/flutter.git -b stable
          echo "$(pwd)/flutter/bin" >> $GITHUB_PATH

      # 安装 Flutter 依赖
      - name: Install Flutter dependencies
        run: flutter pub get

      # 分析项目源代码
      - name: Analyze project source
        run: flutter analyze

      # 运行测试
      - name: Run tests
        run: flutter test

      # 编译 Flutter Windows 应用
      - name: Build Flutter Windows Release
        run: flutter build windows --release
