Files
runner-images/images/win/scripts/Installers/Download-ToolCache.ps1
Maksim Petrov 0967620111 Switch Windows hostedtoolcache provisioner to GitHub Actions NPM registry (#315)
* Toolcache: add basic error handling in Windows toolcache provisioner

* Toolcache: add GITHUB_FEED_TOKEN into packer templates for Windows

* Toolcache: separate toolcache.json for Windows

* Rework "Validate-ToolCache" script (#6)

* Rework validate toolcache script

* change boost root folder

* Add boost 1.69 for windows-2019

* Add toolcache config variable to Windows 16, 19

* Revert "Add toolcache config variable to Windows 16, 19"

* Add default boost version for validate-boost VS19

* Remove bjam test for boost

* Add boost 1.72 validation for win-2016

Co-authored-by: MaksimZhukov <46996400+MaksimZhukov@users.noreply.github.com>
Co-authored-by: Aleksandr Chebotov <47745270+al-cheb@users.noreply.github.com>
2020-01-29 10:41:09 +03:00

77 lines
2.3 KiB
PowerShell

################################################################################
## File: Download-ToolCache.ps1
## Team: CI-Build
## Desc: Download tool cache
################################################################################
Function Install-NpmPackage {
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)]
[System.String] $PackageName,
[Parameter(Mandatory=$true)]
[System.Uri] $FeedPrefix
)
Push-Location -Path $env:TEMP
$FeedUri = $FeedPrefix.AbsoluteUri
Write-Host "Installing npm $PackageName from ${FeedUri}"
npm install $PackageName --registry "${FeedUri}"
if($LASTEXITCODE) {
Write-Host "$PackageName installation failure; Error: ${LASTEXITCODE}"
exit 1
}
Pop-Location
}
Function NPMFeed-AuthSetup {
param(
[Parameter(Mandatory=$true)]
[System.String] $AccessToken,
[Parameter(Mandatory=$true)]
[System.Uri] $FeedPrefix
)
$FeedHost = $FeedPrefix.Host
Write-Host "Configure auth for github package registry"
$npmrcContent = "//${FeedHost}/:_authToken=${AccessToken}"
$npmrcContent | Out-File -FilePath "$($env:TEMP)/.npmrc" -Encoding utf8
}
$FeedPrefix = "https://npm.pkg.github.com"
$AccessToken = $env:GITHUB_FEED_TOKEN
# HostedToolCache Path
$Dest = "C:/"
$Path = "hostedtoolcache/windows"
$ToolsDirectory = $Dest + $Path
# Define AGENT_TOOLSDIRECTORY environment variable
$env:AGENT_TOOLSDIRECTORY = $ToolsDirectory
setx AGENT_TOOLSDIRECTORY $ToolsDirectory /M
# Install HostedToolCache tools via NPM
$ToolVersionsFileContent = Get-Content -Path "$env:ROOT_FOLDER/toolcache.json" -Raw
$ToolVersions = ConvertFrom-Json -InputObject $ToolVersionsFileContent
NPMFeed-AuthSetup -AccessToken $AccessToken -FeedPrefix $FeedPrefix
$ToolVersions.PSObject.Properties | ForEach-Object {
$PackageName = $_.Name
$PackageVersions = $_.Value
$NpmPackages = $PackageVersions | ForEach-Object { "$PackageName@$_" }
foreach($NpmPackage in $NpmPackages) {
Install-NpmPackage -PackageName $NpmPackage -FeedPrefix $FeedPrefix
}
}
#junction point from the previous Python2 directory to the toolcache Python2
Write-Host "Create symlink to Python2"
$python2Dir = (Get-Item -Path ($ToolsDirectory + '/Python/2.7*/x64')).FullName
cmd.exe /c mklink /d "C:\Python27amd64" "$python2Dir"