Files
aeternalis/tools/bootstrap-helm.ps1

14 lines
967 B
PowerShell

$ErrorActionPreference = 'Stop'
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$toolsDir = Join-Path $PSScriptRoot '..\.tools'
New-Item -ItemType Directory -Force -Path $toolsDir | Out-Null
$name = 'helm-v3.18.6-windows-amd64.zip'
$destination = Join-Path $toolsDir $name
$checksumResponse = (Invoke-WebRequest ('https://get.helm.sh/' + $name + '.sha256sum') -UseBasicParsing).Content
$checksumText = if ($checksumResponse -is [byte[]]) { [Text.Encoding]::ASCII.GetString($checksumResponse) } else { [string]$checksumResponse }
$expected = ($checksumText.Trim() -split '\s+')[0]
Invoke-WebRequest ('https://get.helm.sh/' + $name) -UseBasicParsing -OutFile $destination
if ((Get-FileHash $destination -Algorithm SHA256).Hash.ToLowerInvariant() -ne $expected) { throw 'Helm checksum mismatch.' }
Expand-Archive -LiteralPath $destination -DestinationPath $toolsDir -Force
& (Join-Path $toolsDir 'windows-amd64\helm.exe') version --short