name: Build Windows on: push: branches: [ main, master ] pull_request: branches: [ main, master ] workflow_dispatch: jobs: # 先编译 libcore build-libcore: name: 编译 libcore (Windows) runs-on: ubuntu-latest steps: - name: 📥 Checkout 代码 uses: actions/checkout@v4 with: submodules: recursive fetch-depth: 0 - name: 🔧 设置 Go 环境 uses: actions/setup-go@v5 with: go-version: '1.23' cache: true cache-dependency-path: libcore/go.sum - name: 🔧 设置 Node.js uses: actions/setup-node@v4 with: node-version: '20' - name: 🔧 安装 MinGW run: | sudo apt-get update sudo apt-get install -y mingw-w64 - name: 📦 编译 libcore.dll working-directory: libcore run: | echo "🚀 开始编译 Windows libcore..." make windows-amd64 if [ -f "bin/libcore.dll" ] && [ -f "bin/HiddifyCli.exe" ]; then echo "✅ Windows libcore 编译成功" ls -lh bin/ else echo "❌ Windows libcore 编译失败" exit 1 fi - name: 📤 上传 Windows libcore uses: actions/upload-artifact@v4 with: name: libcore-windows path: | libcore/bin/libcore.dll libcore/bin/HiddifyCli.exe libcore/bin/webui/** retention-days: 7 # 构建 Windows 应用 build: runs-on: windows-latest needs: build-libcore steps: - name: 📥 Checkout 代码 uses: actions/checkout@v4 - name: 📥 下载 libcore uses: actions/download-artifact@v4 with: name: libcore-windows path: . - name: 🔧 复制 libcore 文件到正确位置并重命名 run: | echo "📋 复制 libcore 文件..." if (Test-Path "HiddifyCli.exe") { Write-Host "✅ 找到 HiddifyCli.exe,重命名为 BearVPNCli.exe" Copy-Item HiddifyCli.exe libcore\bin\BearVPNCli.exe } if (Test-Path "libcore.dll") { Write-Host "✅ 找到 libcore.dll" New-Item -ItemType Directory -Force -Path libcore\bin Copy-Item libcore.dll libcore\bin\ } Write-Host "📄 验证文件..." Get-ChildItem libcore\bin\ -ErrorAction SilentlyContinue | Format-Table - name: Setup Flutter uses: subosito/flutter-action@v2 with: flutter-version: '3.24.5' channel: 'stable' - name: Enable Windows desktop run: flutter config --enable-windows-desktop - name: Get dependencies run: flutter pub get - name: Generate code run: dart run build_runner build --delete-conflicting-outputs - name: Build Windows Debug run: flutter build windows - name: Build Windows Release run: flutter build windows --release - name: Upload Debug build artifacts uses: actions/upload-artifact@v4 with: name: windows-debug-build path: build/windows/runner/Debug/ - name: Upload Release build artifacts uses: actions/upload-artifact@v4 with: name: windows-release-build path: build/windows/runner/Release/