Files
runner-images-sangeeth/images/windows/scripts/build/Install-GitHub-CLI.ps1
Vasilii Polikarpov d3e630f774 [Windows] Implement installation helpers refactoring (#8865)
* [Windows] Refactor base Installer helper functions

* Fix helper name

* Fix name gen logic and improve error handling

* Fix hash checking logic

* Fix Install-VsixExtension invocation

* Fix variable name in Install-OpenSSL.ps1

* Fix type for git downloadUrl
2023-11-22 15:14:08 +01:00

23 lines
963 B
PowerShell

################################################################################
## File: Install-GitHub-CLI.ps1
## Desc: Install GitHub CLI
## Supply chain security: GitHub CLI - checksum validation
################################################################################
Write-Host "Get the latest gh version..."
$repoUrl = "https://api.github.com/repos/cli/cli/releases/latest"
$assets = (Invoke-RestMethod -Uri $repoUrl).assets
$downloadUrl = ($assets.browser_download_url -match "windows_amd64.msi") | Select-Object -First 1
$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]
Install-Binary `
-Url $downloadUrl `
-ExpectedSHA256Sum $externalHash
Add-MachinePathItem "C:\Program Files (x86)\GitHub CLI"
Invoke-PesterTests -TestFile "CLI.Tools" -TestName "GitHub CLI"