mirror of
https://github.com/actions/runner-images.git
synced 2025-12-20 06:35:47 +00:00
[ubuntu] Refactor PowerShell build scripts (#9064)
* [ubuntu] Refactor PowerShell build scripts * Add Module import * Add Invoke-DownloadWithRetry function * Fix temp download dir * Update function to Add-GlobalEnvironmentVariable
This commit is contained in:
committed by
GitHub
parent
62aeae3a20
commit
e9057a22fc
@@ -4,19 +4,21 @@
|
||||
## Desc: Install toolset
|
||||
################################################################################
|
||||
|
||||
Function Install-Asset {
|
||||
Import-Module "$env:HELPER_SCRIPTS/../tests/Helpers.psm1"
|
||||
|
||||
function Install-Asset {
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[object] $ReleaseAsset
|
||||
)
|
||||
|
||||
Write-Host "Download $($ReleaseAsset.filename)"
|
||||
wget $ReleaseAsset.download_url -nv --retry-connrefused --tries=10
|
||||
$assetArchivePath = Invoke-DownloadWithRetry $ReleaseAsset.download_url
|
||||
|
||||
Write-Host "Extract $($ReleaseAsset.filename) content..."
|
||||
$assetFolderPath = Join-Path "/tmp" $($ReleaseAsset.filename)
|
||||
New-Item -ItemType Directory -Path $assetFolderPath
|
||||
tar -xzf $ReleaseAsset.filename -C $assetFolderPath
|
||||
$assetFolderPath = Join-Path "/tmp" "$($ReleaseAsset.filename)-temp-dir"
|
||||
New-Item -ItemType Directory -Path $assetFolderPath | Out-Null
|
||||
tar -xzf $assetArchivePath -C $assetFolderPath
|
||||
|
||||
Write-Host "Invoke installation script..."
|
||||
Push-Location -Path $assetFolderPath
|
||||
@@ -26,10 +28,8 @@ Function Install-Asset {
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
# Get toolset content
|
||||
$toolset = Get-Content -Path "$env:INSTALLER_SCRIPT_FOLDER/toolset.json" -Raw
|
||||
|
||||
$tools = ConvertFrom-Json -InputObject $toolset | Select-Object -ExpandProperty toolcache | Where-Object {$_.url -ne $null }
|
||||
# Get toolcache content from toolset
|
||||
$tools = (Get-ToolsetContent).toolcache | Where-Object { $_.url -ne $null }
|
||||
|
||||
foreach ($tool in $tools) {
|
||||
# Get versions manifest for current tool
|
||||
@@ -38,17 +38,18 @@ foreach ($tool in $tools) {
|
||||
# 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 ($_.platform_version -eq $tool.platform_version)} `
|
||||
| Select-Object -First 1
|
||||
| Select-Object -ExpandProperty files `
|
||||
| Where-Object { ($_.platform -eq $tool.platform) -and ($_.platform_version -eq $tool.platform_version)} `
|
||||
| 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"
|
||||
if (-not $asset) {
|
||||
Write-Host "Asset for $($tool.name) $toolVersion $($tool.arch) not found in versions manifest"
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "Installing $($tool.name) $toolVersion $($tool.arch)..."
|
||||
Install-Asset -ReleaseAsset $asset
|
||||
}
|
||||
|
||||
chown -R "$($env:SUDO_USER):$($env:SUDO_USER)" "/opt/hostedtoolcache/$($tool.name)"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user