mirror of
https://github.com/actions/runner-images.git
synced 2025-12-15 14:17:22 +00:00
[Windows] Cleanup various scripts (#8942)
* Use Resolve-GithubReleaseAssetUrl more widely * Add the Get-ChecksumFromUrl function * Sort exported functions and add docs * Remove alias and fix typo * Fix kind checksum url and syntax * Fix checksums url for gh cli and msys2 * [Windows] Cleanup various scripts * Add spaces after type specifications * Rename the Take-Part function
This commit is contained in:
committed by
GitHub
parent
ed911223ab
commit
5ed2615017
@@ -6,20 +6,24 @@
|
||||
|
||||
Write-Host "Install Kind"
|
||||
# Choco installation can't be used because it depends on docker-desktop
|
||||
$repoUrl = 'https://api.github.com/repos/kubernetes-sigs/kind/releases/latest'
|
||||
$assets = (Invoke-RestMethod -Uri $repoUrl).assets
|
||||
[System.String] $kindDownloadLink = $assets.browser_download_url -match "kind-windows-amd64$"
|
||||
$destFilePath = "C:\ProgramData\kind"
|
||||
$null = New-Item -Path $destFilePath -ItemType Directory -Force
|
||||
$packagePath = Invoke-DownloadWithRetry -Url $kindDownloadLink -Path "$destFilePath\kind.exe"
|
||||
|
||||
$targetDir = "C:\ProgramData\kind"
|
||||
New-Item -Path $targetDir -ItemType Directory -Force | Out-Null
|
||||
|
||||
$downloadUrl = Resolve-GithubReleaseAssetUrl `
|
||||
-Repo "kubernetes-sigs/kind" `
|
||||
-Version "latest" `
|
||||
-UrlMatchPattern "kind-windows-amd64"
|
||||
$packagePath = Invoke-DownloadWithRetry -Url $downloadUrl -Path "$targetDir\kind.exe"
|
||||
|
||||
#region Supply chain security - Kind
|
||||
$hashUrl = ($assets.browser_download_url -match "kind-windows-amd64.sha256sum") | Select-Object -First 1
|
||||
$externalHash = (Invoke-RestMethod -Uri $hashURL).ToString().Split("`n").Where({ $_ -ilike "*kind-windows-amd64*" }).Split(' ')[0]
|
||||
$externalHash = Get-ChecksumFromUrl -Type "SHA256" `
|
||||
-Url "$downloadUrl.sha256sum" `
|
||||
-FileName (Split-Path $downloadUrl -Leaf)
|
||||
Test-FileChecksum $packagePath -ExpectedSHA256Sum $externalHash
|
||||
#endregion
|
||||
|
||||
Add-MachinePathItem $destFilePath
|
||||
Add-MachinePathItem $targetDir
|
||||
|
||||
Write-Host "Install Kubectl"
|
||||
Install-ChocoPackage kubernetes-cli
|
||||
|
||||
Reference in New Issue
Block a user