mirror of
https://github.com/actions/runner-images-sangeeth.git
synced 2026-01-05 01:31:51 +08:00
[Windows] Implement installation helpers refactoring (#8865)
* [Windows] Refactor base Installer helper functions * Fix helper name * Fix name gen logic and improve error handling * Fix hash checking logic * Fix Install-VsixExtension invocation * Fix variable name in Install-OpenSSL.ps1 * Fix type for git downloadUrl
This commit is contained in:
committed by
GitHub
parent
46f21c4413
commit
d3e630f774
@@ -5,28 +5,28 @@
|
||||
################################################################################
|
||||
|
||||
$CondaDestination = "C:\Miniconda"
|
||||
|
||||
# Install the latest Miniconda
|
||||
$InstallerName = "Miniconda3-latest-Windows-x86_64.exe"
|
||||
$InstallerUrl = "https://repo.anaconda.com/miniconda/${InstallerName}"
|
||||
$ArgumentList = ("/S", "/AddToPath=0", "/RegisterPython=0", "/D=$CondaDestination")
|
||||
|
||||
Install-Binary -Url $InstallerUrl -Name $InstallerName -ArgumentList $ArgumentList
|
||||
[System.Environment]::SetEnvironmentVariable("CONDA", $CondaDestination, "Machine")
|
||||
|
||||
#region Supply chain security
|
||||
$localFileHash = (Get-FileHash -Path (Join-Path ${env:TEMP} $installerName) -Algorithm SHA256).Hash
|
||||
$distributorFileHash = $null
|
||||
|
||||
$checksums = (Invoke-RestMethod -Uri 'https://repo.anaconda.com/miniconda/' | ConvertFrom-HTML).SelectNodes('//html/body/table/tr')
|
||||
|
||||
ForEach($node in $checksums) {
|
||||
foreach ($node in $checksums) {
|
||||
if ($node.ChildNodes[1].InnerText -eq $InstallerName) {
|
||||
$distributorFileHash = $node.ChildNodes[7].InnerText
|
||||
}
|
||||
}
|
||||
|
||||
Use-ChecksumComparison -LocalFileHash $localFileHash -DistributorFileHash $distributorFileHash
|
||||
if ($null -eq $distributorFileHash) {
|
||||
throw "Unable to find checksum for $InstallerName in https://repo.anaconda.com/miniconda/"
|
||||
}
|
||||
#endregion
|
||||
|
||||
Install-Binary `
|
||||
-Url "https://repo.anaconda.com/miniconda/${InstallerName}" `
|
||||
-InstallArgs @("/S", "/AddToPath=0", "/RegisterPython=0", "/D=$CondaDestination") `
|
||||
-ExpectedSHA256Sum $distributorFileHash
|
||||
|
||||
[System.Environment]::SetEnvironmentVariable("CONDA", $CondaDestination, "Machine")
|
||||
|
||||
Invoke-PesterTests -TestFile "Miniconda"
|
||||
|
||||
Reference in New Issue
Block a user