mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 20:01:06 +07:00
Add fallback in PHP build cache in Windows
This commit is contained in:
parent
04b2ed5b3e
commit
b3a12ce01e
@ -217,6 +217,7 @@ Function Add-PhpConfig {
|
|||||||
|
|
||||||
# Function to get PHP from GitHub releases cache
|
# Function to get PHP from GitHub releases cache
|
||||||
Function Set-PhpCache {
|
Function Set-PhpCache {
|
||||||
|
try {
|
||||||
try {
|
try {
|
||||||
$release = Invoke-RestMethod https://api.github.com/repos/shivammathur/php-builder-windows/releases/tags/php$version
|
$release = Invoke-RestMethod https://api.github.com/repos/shivammathur/php-builder-windows/releases/tags/php$version
|
||||||
$asset = $release.assets | ForEach-Object {
|
$asset = $release.assets | ForEach-Object {
|
||||||
@ -224,6 +225,17 @@ Function Set-PhpCache {
|
|||||||
return $_.name
|
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
|
Invoke-WebRequest -UseBasicParsing -Uri $php_builder/releases/download/php$version/$asset -OutFile $php_dir\$asset
|
||||||
Set-PhpDownloadCache -Path $php_dir CurrentUser
|
Set-PhpDownloadCache -Path $php_dir CurrentUser
|
||||||
} catch { }
|
} catch { }
|
||||||
|
Loading…
Reference in New Issue
Block a user