mirror of
https://github.com/actions/runner-images.git
synced 2025-12-20 06:35:47 +00:00
[Windows] Implement new directories hierarchy (#8616)
This commit is contained in:
committed by
GitHub
parent
84a7deae24
commit
d1f2c9a3be
58
images/windows/scripts/build/Install-Toolset.ps1
Normal file
58
images/windows/scripts/build/Install-Toolset.ps1
Normal file
@@ -0,0 +1,58 @@
|
||||
################################################################################
|
||||
## File: Install-Toolset.ps1
|
||||
## Team: CI-Build
|
||||
## Desc: Install toolset
|
||||
################################################################################
|
||||
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 -bor [Net.SecurityProtocolType]::Tls13
|
||||
|
||||
Function Install-Asset {
|
||||
param(
|
||||
[Parameter(Mandatory=$true)]
|
||||
[object] $ReleaseAsset
|
||||
)
|
||||
|
||||
$releaseAssetName = [System.IO.Path]::GetFileNameWithoutExtension($ReleaseAsset.filename)
|
||||
$assetFolderPath = Join-Path $env:TEMP $releaseAssetName
|
||||
$assetArchivePath = Start-DownloadWithRetry -Url $ReleaseAsset.download_url -Name $ReleaseAsset.filename
|
||||
|
||||
Write-Host "Extract $($ReleaseAsset.filename) content..."
|
||||
if ($assetArchivePath.EndsWith(".tar.gz")) {
|
||||
$assetTarPath = $assetArchivePath.TrimEnd(".tar.gz")
|
||||
Extract-7Zip -Path $assetArchivePath -DestinationPath $assetTarPath
|
||||
Extract-7Zip -Path $assetTarPath -DestinationPath $assetFolderPath
|
||||
} else {
|
||||
Extract-7Zip -Path $assetArchivePath -DestinationPath $assetFolderPath
|
||||
}
|
||||
|
||||
Write-Host "Invoke installation script..."
|
||||
Push-Location -Path $assetFolderPath
|
||||
Invoke-Expression .\setup.ps1
|
||||
Pop-Location
|
||||
}
|
||||
|
||||
# Get toolcache content from toolset
|
||||
$ToolsToInstall = @("Python", "Node", "Go")
|
||||
|
||||
$tools = Get-ToolsetContent | Select-Object -ExpandProperty toolcache | Where-Object { $ToolsToInstall -contains $_.Name }
|
||||
|
||||
foreach ($tool in $tools) {
|
||||
# Get versions manifest for current tool
|
||||
$assets = Invoke-SBWithRetry -Command { Invoke-RestMethod $tool.url }
|
||||
|
||||
# Get github release asset for each version
|
||||
foreach ($toolVersion in $tool.versions) {
|
||||
$asset = $assets | Where-Object version -like $toolVersion `
|
||||
| Select-Object -ExpandProperty files `
|
||||
| Where-Object { ($_.platform -eq $tool.platform) -and ($_.arch -eq $tool.arch) -and ($_.toolset -eq $tool.toolset) } `
|
||||
| Select-Object -First 1
|
||||
|
||||
Write-Host "Installing $($tool.name) $toolVersion $($tool.arch)..."
|
||||
if ($null -ne $asset) {
|
||||
Install-Asset -ReleaseAsset $asset
|
||||
} else {
|
||||
Write-Host "Asset was not found in versions manifest"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user