Add fallback in PHP build cache in Windows

This commit is contained in:
Shivam Mathur 2022-12-19 07:19:21 +05:30
parent 04b2ed5b3e
commit b3a12ce01e
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A

View File

@ -217,6 +217,7 @@ Function Add-PhpConfig {
# Function to get PHP from GitHub releases cache
Function Set-PhpCache {
try {
try {
$release = Invoke-RestMethod https://api.github.com/repos/shivammathur/php-builder-windows/releases/tags/php$version
$asset = $release.assets | ForEach-Object {
@ -224,6 +225,17 @@ Function Set-PhpCache {
return $_.name
}
}
if($null -eq $asset) {
throw "Asset not found"
}
} catch {
$release = Invoke-WebRequest $php_builder/releases/expanded_assets/php$version
$asset = $release.links.href | ForEach-Object {
if($_ -match "php-$version.[0-9]+$env:PHPTS-Win32-.*-$arch.zip") {
return $_.split('/')[-1]
}
}
}
Invoke-WebRequest -UseBasicParsing -Uri $php_builder/releases/download/php$version/$asset -OutFile $php_dir\$asset
Set-PhpDownloadCache -Path $php_dir CurrentUser
} catch { }