-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
Install-Stack.ps1
35 lines (26 loc) · 1.32 KB
/
Install-Stack.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
################################################################################
## 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"