refactor(ci): enhance download process in CI and release workflows
- Updated the download logic in both ci.yml and release.yml to include error handling for Invoke-WebRequest. - Added a fallback to curl.exe for downloading packages if the initial request fails, improving reliability in package retrieval. Benefits: - Increases robustness of the CI and release workflows by ensuring successful downloads even in case of network issues. - Enhances maintainability by centralizing download logic and error handling in the workflow scripts.
This commit is contained in:
7
.github/workflows/ci.yml
vendored
7
.github/workflows/ci.yml
vendored
@@ -142,7 +142,12 @@ jobs:
|
||||
$destination = Join-Path $downloads $pkg.Name
|
||||
if (-not (Test-Path $destination)) {
|
||||
Write-Host "Downloading $($pkg.Name)"
|
||||
Invoke-WebRequest -Uri $pkg.Url -OutFile $destination
|
||||
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
|
||||
}
|
||||
} else {
|
||||
Write-Host "$($pkg.Name) already present, skipping download"
|
||||
}
|
||||
|
||||
7
.github/workflows/release.yml
vendored
7
.github/workflows/release.yml
vendored
@@ -216,7 +216,12 @@ jobs:
|
||||
$destination = Join-Path $downloads $pkg.Name
|
||||
if (-not (Test-Path $destination)) {
|
||||
Write-Host "Downloading $($pkg.Name)"
|
||||
Invoke-WebRequest -Uri $pkg.Url -OutFile $destination
|
||||
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
|
||||
}
|
||||
} else {
|
||||
Write-Host "$($pkg.Name) already present, skipping download"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user