mirror of
https://github.com/actions/runner-images-sangeeth.git
synced 2025-12-20 06:29:50 +00:00
[Windows] Add checksum verification for GitHub CLI (#8360)
This commit is contained in:
@@ -1,15 +1,25 @@
|
||||
################################################################################
|
||||
## File: Install-GitHub-CLI.ps1
|
||||
## Desc: Install GitHub CLI
|
||||
## Supply chain security: GitHub CLI - checksum validation
|
||||
################################################################################
|
||||
|
||||
Write-Host "Get the latest gh version..."
|
||||
|
||||
$Name = "gh_windows_amd64.msi"
|
||||
$Assets = (Invoke-RestMethod -Uri "https://api.github.com/repos/cli/cli/releases/latest").assets
|
||||
$DownloadUrl = ($Assets.browser_download_url -match "windows_amd64.msi") | Select-Object -First 1
|
||||
$repoUrl = "https://api.github.com/repos/cli/cli/releases/latest"
|
||||
$installerFile = "gh_windows_amd64.msi"
|
||||
$assets = (Invoke-RestMethod -Uri $repoUrl).assets
|
||||
$downloadUrl = ($assets.browser_download_url -match "windows_amd64.msi") | Select-Object -First 1
|
||||
$packagePath = Start-DownloadWithRetry -Url $downloadUrl -Name $installerFile
|
||||
|
||||
Install-Binary -Url $DownloadUrl -Name $Name
|
||||
#region Supply chain security - GitHub CLI
|
||||
$fileHash = (Get-FileHash -Path $packagePath -Algorithm SHA256).Hash
|
||||
$hashUrl = ($assets.browser_download_url -match "checksums.txt") | Select-Object -First 1
|
||||
$externalHash = (Invoke-RestMethod -Uri $hashURL).ToString().Split("`n").Where({ $_ -ilike "*windows_amd64.msi*" }).Split(' ')[0]
|
||||
Use-ChecksumComparison $fileHash $externalHash
|
||||
#endregion
|
||||
|
||||
Install-Binary -FilePath $packagePath
|
||||
|
||||
Add-MachinePathItem "C:\Program Files (x86)\GitHub CLI"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user