From deac0adabd17ac1a02cd103301a2f9278af91a97 Mon Sep 17 00:00:00 2001 From: shanshanzhong Date: Sat, 8 Nov 2025 22:01:00 -0800 Subject: [PATCH] =?UTF-8?q?feat(CI):=20=E6=B7=BB=E5=8A=A0Flutter=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E8=84=9A=E6=9C=AC=E5=B9=B6=E6=94=B9=E8=BF=9BWindows?= =?UTF-8?q?=E6=9E=84=E5=BB=BA=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加install_flutter_simple.bat脚本用于在Windows上自动安装Flutter 改进docker.yml中的Windows构建步骤,增加Flutter路径检测和powershell支持 --- .gitea/workflows/docker.yml | 42 ++++++++++++++++++++++++++++++----- install_flutter_simple.bat | 44 +++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 5 deletions(-) create mode 100644 install_flutter_simple.bat diff --git a/.gitea/workflows/docker.yml b/.gitea/workflows/docker.yml index 91b8550..b09263a 100644 --- a/.gitea/workflows/docker.yml +++ b/.gitea/workflows/docker.yml @@ -189,19 +189,51 @@ jobs: } - name: Enable Windows desktop - run: flutter config --enable-windows-desktop + shell: powershell + run: | + $flutterPath = Get-Command flutter -ErrorAction SilentlyContinue + if (-not $flutterPath) { + Write-Host "Flutter not found, checking common locations..." + $commonPaths = @( + "C:\flutter\bin\flutter.exe", + "C:\tools\flutter\bin\flutter.exe", + "${env:USERPROFILE}\flutter\bin\flutter.exe" + ) + $flutterFound = $false + foreach ($path in $commonPaths) { + if (Test-Path $path) { + Write-Host "Found Flutter at: $path" + $env:PATH = "$(Split-Path $path);$env:PATH" + $flutterFound = $true + break + } + } + if (-not $flutterFound) { + Write-Host "ERROR: Flutter not found. Please install Flutter first." + exit 1 + } + } + flutter config --enable-windows-desktop - name: Get dependencies - run: flutter pub get + shell: powershell + run: | + flutter pub get - name: Generate code - run: dart run build_runner build --delete-conflicting-outputs + shell: powershell + run: | + dart run build_runner build --delete-conflicting-outputs - name: Build Windows Debug - run: flutter build windows + shell: powershell + run: | + flutter build windows - name: Build Windows Release - run: flutter build windows --release + shell: powershell + run: | + flutter build windows --release - name: Upload Debug build artifacts uses: actions/upload-artifact@v3 diff --git a/install_flutter_simple.bat b/install_flutter_simple.bat new file mode 100644 index 0000000..5b8fac8 --- /dev/null +++ b/install_flutter_simple.bat @@ -0,0 +1,44 @@ +@echo off +REM Simple Flutter installer for Windows Gitea Runner + +echo Installing Flutter for Windows... + +REM Create flutter directory +mkdir C:\flutter 2>nul + +REM Download Flutter stable version +echo Downloading Flutter... +powershell -Command "(New-Object Net.WebClient).DownloadFile('https://storage.googleapis.com/flutter_infra_release/releases/stable/windows/flutter_windows_3.24.5-stable.zip', 'C:\flutter.zip')" + +if %errorlevel% neq 0 ( + echo Download failed, trying alternative... + powershell -Command "Invoke-WebRequest -Uri 'https://storage.googleapis.com/flutter_infra_release/releases/stable/windows/flutter_windows_3.24.5-stable.zip' -OutFile 'C:\flutter.zip'" +) + +REM Extract Flutter +echo Extracting Flutter... +powershell -Command "Expand-Archive -Path 'C:\flutter.zip' -DestinationPath 'C:\' -Force" + +REM Set PATH +echo Setting PATH... +set PATH=C:\flutter\bin;%PATH% +setx PATH "C:\flutter\bin;%PATH%" + +REM Clean up +del C:\flutter.zip + +REM Verify installation +echo Verifying Flutter installation... +C:\flutter\bin\flutter --version + +if %errorlevel% equ 0 ( + echo SUCCESS: Flutter installed successfully + echo Running flutter doctor... + C:\flutter\bin\flutter doctor +) else ( + echo ERROR: Flutter installation failed + exit /b 1 +) + +echo Flutter installation complete! +pause \ No newline at end of file