mirror of
https://github.com/actions/runner-images.git
synced 2025-12-20 06:35:47 +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
@@ -11,25 +11,27 @@ $dash = "-" * 40
|
||||
$origPath = $env:PATH
|
||||
|
||||
function Install-Msys2 {
|
||||
$msys2_release = "https://api.github.com/repos/msys2/msys2-installer/releases/latest"
|
||||
$assets = (Invoke-RestMethod -Uri $msys2_release).assets
|
||||
$msys2Uri = ($assets | Where-Object { $_.name -match "^msys2-x86_64" -and $_.name.EndsWith(".exe") }).browser_download_url
|
||||
# We can't use Resolve-GithubReleaseAssetUrl function here
|
||||
# because msys2-installer releases don't have a consistent versioning scheme
|
||||
|
||||
$assets = (Invoke-RestMethod -Uri "https://api.github.com/repos/msys2/msys2-installer/releases/latest").assets
|
||||
$downloadUri = ($assets | Where-Object { $_.name -match "^msys2-x86_64" -and $_.name.EndsWith(".exe") }).browser_download_url
|
||||
$installerName = Split-Path $downloadUri -Leaf
|
||||
|
||||
# Download the latest msys2 x86_64, filename includes release date
|
||||
Write-Host "Starting msys2 download using $($msys2Uri.split('/')[-1])"
|
||||
$msys2File = Invoke-DownloadWithRetry $msys2Uri
|
||||
Write-Host "Finished download"
|
||||
Write-Host "Download msys2 installer $installerName"
|
||||
$installerPath = Invoke-DownloadWithRetry $downloadUri
|
||||
|
||||
#region Supply chain security - Kind
|
||||
$hashUrl = ($assets.browser_download_url -match "msys2-checksums.txt") | Select-Object -First 1
|
||||
$externalHash = (Invoke-RestMethod -Uri $hashURL).ToString().Split("`n").Where({ $_ -ilike "*msys2-x86_64*" }).Split(' ')[0]
|
||||
Test-FileChecksum $msys2File -ExpectedSHA256Sum $externalHash
|
||||
#region Supply chain security - MSYS2
|
||||
$externalHash = Get-ChecksumFromUrl -Type "SHA256" `
|
||||
-Url ($downloadUri -replace $installerName, "msys2-checksums.txt") `
|
||||
-FileName $installerName
|
||||
Test-FileChecksum $installerPath -ExpectedSHA256Sum $externalHash
|
||||
#endregion
|
||||
|
||||
# extract tar.xz to C:\
|
||||
Write-Host "Starting msys2 installation"
|
||||
& $msys2File in --confirm-command --accept-messages --root C:/msys64
|
||||
Remove-Item $msys2File
|
||||
& $installerPath in --confirm-command --accept-messages --root C:/msys64
|
||||
Remove-Item $installerPath
|
||||
}
|
||||
|
||||
function Install-Msys2Packages($Packages) {
|
||||
|
||||
Reference in New Issue
Block a user