Files
runner-images/images/windows/scripts/build/Install-Stack.ps1
Vasilii Polikarpov 7fe65a2204 [Windows] Apply code style rules to Windows scripts (#8957)
* Apply code style rules to Windows scripts

* Fix typo

* Fix configure-toolset script

* Fix parameters in Msys2 installation script

* Improve log readability

* Remove broken exit code validation
2023-12-11 22:23:36 +01:00

36 lines
1.3 KiB
PowerShell

################################################################################
## File: Install-Stack.ps1
## Desc: Install Stack for Windows
## Supply chain security: Stack - checksum validation
################################################################################
Write-Host "Get the latest Stack version..."
$version = (Get-GithubReleasesByVersion -Repo "commercialhaskell/stack" -Version "latest" -WithAssetsOnly).version
$downloadUrl = Resolve-GithubReleaseAssetUrl `
-Repo "commercialhaskell/stack" `
-Version $version `
-UrlMatchPattern "stack-*-windows-x86_64.zip"
Write-Host "Download stack archive"
$stackToolcachePath = Join-Path $env:AGENT_TOOLSDIRECTORY "stack\$version"
$destinationPath = Join-Path $stackToolcachePath "x64"
$stackArchivePath = Invoke-DownloadWithRetry $downloadUrl
#region Supply chain security - Stack
$externalHash = Get-ChecksumFromUrl -Type "SHA256" `
-Url "$downloadUrl.sha256" `
-FileName (Split-Path $downloadUrl -Leaf)
Test-FileChecksum $stackArchivePath -ExpectedSHA256Sum $externalHash
#endregion
Write-Host "Expand stack archive"
Expand-7ZipArchive -Path $stackArchivePath -DestinationPath $destinationPath
New-Item -Name "x64.complete" -Path $stackToolcachePath
Add-MachinePathItem -PathItem $destinationPath
Invoke-PesterTests -TestFile "Tools" -TestName "Stack"