mirror of
https://github.com/actions/runner-images.git
synced 2025-12-14 13:17:54 +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
@@ -6,18 +6,17 @@
|
||||
$ErrorActionPreference = "Stop"
|
||||
$ProgressPreference = "SilentlyContinue"
|
||||
|
||||
Import-Module "$env:HELPER_SCRIPTS/../tests/Helpers.psm1" -DisableNameChecking
|
||||
Import-Module "$env:HELPER_SCRIPTS/../tests/Helpers.psm1"
|
||||
|
||||
# Get modules content from toolset
|
||||
$modules = (Get-ToolsetContent).azureModules
|
||||
$installPSModulePath = "/usr/share"
|
||||
|
||||
foreach ($module in $modules)
|
||||
{
|
||||
foreach ($module in $modules) {
|
||||
$moduleName = $module.name
|
||||
|
||||
Write-Host "Installing ${moduleName} to the ${installPSModulePath} path..."
|
||||
foreach ($version in $module.versions)
|
||||
{
|
||||
foreach ($version in $module.versions) {
|
||||
$modulePath = Join-Path -Path $installPSModulePath -ChildPath "${moduleName}_${version}"
|
||||
Write-Host " - $version [$modulePath]"
|
||||
Save-Module -Path $modulePath -Name $moduleName -RequiredVersion $version -Force
|
||||
@@ -28,17 +27,16 @@ foreach ($module in $modules)
|
||||
# Get github release asset for each version
|
||||
foreach ($toolVersion in $module.zip_versions) {
|
||||
$asset = $assets | Where-Object version -eq $toolVersion `
|
||||
| Select-Object -ExpandProperty files `
|
||||
| Select-Object -First 1
|
||||
| Select-Object -ExpandProperty files `
|
||||
| Select-Object -First 1
|
||||
|
||||
Write-Host "Installing $($module.name) $toolVersion ..."
|
||||
if ($null -ne $asset) {
|
||||
Write-Host "Download $($asset.filename)"
|
||||
wget $asset.download_url -nv --retry-connrefused --tries=10 -P $installPSModulePath
|
||||
} else {
|
||||
Write-Host "Asset was not found in versions manifest"
|
||||
if (-not $asset) {
|
||||
Write-Host "Asset for ${moduleName} ${toolVersion} was not found in versions manifest"
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "Downloading asset for ${moduleName} ${toolVersion}: $($asset.filename)"
|
||||
Invoke-DownloadWithRetry $asset.download_url -Destination "$installPSModulePath/$($asset.filename)"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user