aboutsummaryrefslogtreecommitdiff
path: root/ci/install.ps1
blob: b15dfc22714bad7fdc24368de28211e3d42a48d0 (plain)
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
param([String] $BaseUrl, [String] $ModuleName, [String] $ProjectName, [String]$FileName, [String]$Version)

#random delays to space out the downloads
$randomDelay = Get-Random -Minimum 300 -Maximum 1000
Start-Sleep -Milliseconds $randomDelay

$_src = "$BaseUrl/$ModuleName/$Version/$ProjectName/$FileName"

#download the latest version
Invoke-WebRequest "$_src" -OutFile $FileName

#download latest sha256
Invoke-WebRequest "$_src.sha256" -OutFile "$FileName.sha256"

#verify the file
$hash = (Get-FileHash $FileName -Algorithm SHA256).Hash

#read the sha256 file
$sha256 = Get-Content "$FileName.sha256"

#compare the hashes
if ($hash -eq $sha256) {
    Write-Host "Hashes match, file is valid" -ForegroundColor Blue
} else {
   throw "Hashes do not match, file is invalid"
}