ci(workflow): 优化Windows构建流程中的Flutter路径配置
Some checks failed
Build Windows / 编译 libcore (Windows) (20.15.1) (push) Successful in 19m42s
Build Windows / build (push) Failing after 7h2m38s

简化Flutter路径的配置逻辑,直接使用固定路径C:\flutter\bin
在关键步骤前确保Flutter路径已正确设置
This commit is contained in:
shanshanzhong 2025-11-08 23:01:24 -08:00
parent deac0adabd
commit 50f4237c74

View File

@ -188,51 +188,57 @@ jobs:
exit 1
}
- name: Add Flutter to PATH
shell: powershell
run: |
# Add Flutter to PATH for current session and GitHub Actions
$flutterPath = "C:\flutter\bin"
if (Test-Path $flutterPath) {
Write-Host "Adding Flutter to PATH: $flutterPath"
$env:PATH = "$flutterPath;$env:PATH"
Add-Content -Path $env:GITHUB_PATH -Value $flutterPath
# Verify Flutter is accessible
$flutterVersion = flutter --version 2>&1
if ($LASTEXITCODE -eq 0) {
Write-Host "Flutter verified: $flutterVersion"
} else {
Write-Host "Flutter not found at $flutterPath"
exit 1
}
} else {
Write-Host "ERROR: Flutter not found at C:\flutter\bin"
exit 1
}
- name: 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
}
}
$env:PATH = "C:\flutter\bin;$env:PATH"
flutter config --enable-windows-desktop
- name: Get dependencies
shell: powershell
shell: powershell
run: |
$env:PATH = "C:\flutter\bin;$env:PATH"
flutter pub get
- name: Generate code
shell: powershell
run: |
$env:PATH = "C:\flutter\bin;$env:PATH"
dart run build_runner build --delete-conflicting-outputs
- name: Build Windows Debug
shell: powershell
run: |
$env:PATH = "C:\flutter\bin;$env:PATH"
flutter build windows
- name: Build Windows Release
shell: powershell
run: |
$env:PATH = "C:\flutter\bin;$env:PATH"
flutter build windows --release
- name: Upload Debug build artifacts