feat(ci): enhance download process in release workflow with multiple URLs
- Updated the release workflow to support multiple download URLs for packages, improving reliability in fetching dependencies. - Implemented a fallback mechanism to attempt downloads from alternative sources if the primary URL fails, enhancing robustness. - Added logic to check for the presence of `pkg-config.exe` in multiple candidate directories, ensuring better integration with system binaries. Benefits: - Increases the likelihood of successful downloads, reducing build failures due to unavailable resources. - Streamlines the CI process by ensuring necessary tools are available, improving overall build environment setup.
This commit is contained in:
69
.github/workflows/release.yml
vendored
69
.github/workflows/release.yml
vendored
@@ -210,18 +210,44 @@ jobs:
|
||||
$downloads = Join-Path "${{ github.workspace }}" "vcpkg/downloads"
|
||||
New-Item -ItemType Directory -Force -Path $downloads | Out-Null
|
||||
$packages = @(
|
||||
@{ Name = "msys2-runtime-3.4.10-4-x86_64.pkg.tar.zst"; Url = "https://github.com/msys2/MSYS2-packages/releases/download/msys2-runtime-3.4.10-4/msys2-runtime-3.4.10-4-x86_64.pkg.tar.zst" },
|
||||
@{ Name = "msys2-runtime-3.4.10-4-x86_64.pkg.tar.zst.sig"; Url = "https://github.com/msys2/MSYS2-packages/releases/download/msys2-runtime-3.4.10-4/msys2-runtime-3.4.10-4-x86_64.pkg.tar.zst.sig" }
|
||||
@{ Name = "msys2-runtime-3.4.10-4-x86_64.pkg.tar.zst"; Urls = @(
|
||||
"https://mirror.msys2.org/msys/x86_64/msys2-runtime-3.4.10-4-x86_64.pkg.tar.zst",
|
||||
"https://github.com/msys2/MSYS2-packages/releases/download/msys2-runtime-3.4.10-4/msys2-runtime-3.4.10-4-x86_64.pkg.tar.zst"
|
||||
) },
|
||||
@{ Name = "msys2-runtime-3.4.10-4-x86_64.pkg.tar.zst.sig"; Urls = @(
|
||||
"https://mirror.msys2.org/msys/x86_64/msys2-runtime-3.4.10-4-x86_64.pkg.tar.zst.sig",
|
||||
"https://github.com/msys2/MSYS2-packages/releases/download/msys2-runtime-3.4.10-4/msys2-runtime-3.4.10-4-x86_64.pkg.tar.zst.sig"
|
||||
) }
|
||||
)
|
||||
foreach ($pkg in $packages) {
|
||||
$destination = Join-Path $downloads $pkg.Name
|
||||
if (-not (Test-Path $destination)) {
|
||||
Write-Host "Downloading $($pkg.Name)"
|
||||
try {
|
||||
Invoke-WebRequest -Uri $pkg.Url -OutFile $destination -Headers @{ "Accept" = "application/octet-stream" }
|
||||
} catch {
|
||||
Write-Host "Invoke-WebRequest failed, retrying with curl.exe"
|
||||
& curl.exe -L $pkg.Url -o $destination
|
||||
$downloaded = $false
|
||||
foreach ($url in $pkg.Urls) {
|
||||
Write-Host "Attempting download of $($pkg.Name) from $url"
|
||||
try {
|
||||
Invoke-WebRequest -Uri $url -OutFile $destination -Headers @{ "Accept" = "application/octet-stream" }
|
||||
$downloaded = $true
|
||||
break
|
||||
} catch {
|
||||
Write-Host "Invoke-WebRequest failed for $url"
|
||||
}
|
||||
}
|
||||
if (-not $downloaded) {
|
||||
Write-Host "Falling back to curl for $($pkg.Name)"
|
||||
foreach ($url in $pkg.Urls) {
|
||||
try {
|
||||
& curl.exe -L $url -o $destination
|
||||
$downloaded = $true
|
||||
break
|
||||
} catch {
|
||||
Write-Host "curl.exe failed for $url"
|
||||
}
|
||||
}
|
||||
}
|
||||
if (-not $downloaded) {
|
||||
Write-Host "::error::Unable to download $($pkg.Name) from any mirror"
|
||||
exit 1
|
||||
}
|
||||
} else {
|
||||
Write-Host "$($pkg.Name) already present, skipping download"
|
||||
@@ -331,12 +357,27 @@ jobs:
|
||||
if: runner.os == 'Windows'
|
||||
shell: pwsh
|
||||
run: |
|
||||
$pkgPath = 'C:\msys64\usr\bin'
|
||||
if (Test-Path $pkgPath) {
|
||||
$pkgPath | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
||||
Write-Host "Added $pkgPath to PATH"
|
||||
} else {
|
||||
Write-Host "::warning::pkg-config not found at $pkgPath"
|
||||
$candidateDirs = @(
|
||||
'C:\msys64\usr\bin',
|
||||
(Join-Path "${{ github.workspace }}" 'vcpkg/downloads/tools')
|
||||
)
|
||||
|
||||
$added = $false
|
||||
foreach ($dir in $candidateDirs) {
|
||||
if (-not (Test-Path $dir)) { continue }
|
||||
|
||||
$pkg = Get-ChildItem -Path $dir -Recurse -Filter 'pkg-config.exe' -ErrorAction SilentlyContinue | Select-Object -First 1
|
||||
if ($pkg) {
|
||||
$pkgDir = $pkg.Directory.FullName
|
||||
$pkgDir | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
||||
Write-Host "Added $pkgDir to PATH"
|
||||
$added = $true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $added) {
|
||||
Write-Host "::warning::pkg-config.exe not located; vcpkg may retry its own acquisition."
|
||||
}
|
||||
|
||||
- name: "Free Disk Space (Linux)"
|
||||
|
||||
Reference in New Issue
Block a user