ci(workflow): 优化Windows构建流程中的Flutter路径配置
简化Flutter路径的配置逻辑,直接使用固定路径C:\flutter\bin 在关键步骤前确保Flutter路径已正确设置
This commit is contained in:
parent
deac0adabd
commit
50f4237c74
@ -188,51 +188,57 @@ jobs:
|
|||||||
exit 1
|
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
|
- name: Enable Windows desktop
|
||||||
shell: powershell
|
shell: powershell
|
||||||
run: |
|
run: |
|
||||||
$flutterPath = Get-Command flutter -ErrorAction SilentlyContinue
|
$env:PATH = "C:\flutter\bin;$env:PATH"
|
||||||
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
|
flutter config --enable-windows-desktop
|
||||||
|
|
||||||
- name: Get dependencies
|
- name: Get dependencies
|
||||||
shell: powershell
|
shell: powershell
|
||||||
run: |
|
run: |
|
||||||
|
$env:PATH = "C:\flutter\bin;$env:PATH"
|
||||||
flutter pub get
|
flutter pub get
|
||||||
|
|
||||||
- name: Generate code
|
- name: Generate code
|
||||||
shell: powershell
|
shell: powershell
|
||||||
run: |
|
run: |
|
||||||
|
$env:PATH = "C:\flutter\bin;$env:PATH"
|
||||||
dart run build_runner build --delete-conflicting-outputs
|
dart run build_runner build --delete-conflicting-outputs
|
||||||
|
|
||||||
- name: Build Windows Debug
|
- name: Build Windows Debug
|
||||||
shell: powershell
|
shell: powershell
|
||||||
run: |
|
run: |
|
||||||
|
$env:PATH = "C:\flutter\bin;$env:PATH"
|
||||||
flutter build windows
|
flutter build windows
|
||||||
|
|
||||||
- name: Build Windows Release
|
- name: Build Windows Release
|
||||||
shell: powershell
|
shell: powershell
|
||||||
run: |
|
run: |
|
||||||
|
$env:PATH = "C:\flutter\bin;$env:PATH"
|
||||||
flutter build windows --release
|
flutter build windows --release
|
||||||
|
|
||||||
- name: Upload Debug build artifacts
|
- name: Upload Debug build artifacts
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user