[MacOS] Pin sha256 for xcode (#9007)

* pin sha256 for xcode

* add sha256 for xcode 15.1
This commit is contained in:
sergei-pyshnoi
2023-12-15 16:44:17 +01:00
committed by GitHub
parent 1cb43238b5
commit 7fe17c7614
6 changed files with 40 additions and 30 deletions

View File

@@ -6,7 +6,9 @@ function Install-XcodeVersion {
[Parameter(Mandatory)]
[string] $Version,
[Parameter(Mandatory)]
[string] $LinkTo
[string] $LinkTo,
[Parameter(Mandatory)]
[string] $Sha256Sum
)
$xcodeDownloadDirectory = "$env:HOME/Library/Caches/XcodeInstall"
@@ -28,8 +30,15 @@ function Invoke-DownloadXcodeArchive {
$tempXipDirectory = New-Item -Path $DownloadDirectory -Name "Xcode$Version" -ItemType "Directory"
$xcodeFileName = 'Xcode-{0}.xip' -f $Version
$xcodeUri = '{0}{1}?{2}'-f ${env:XCODE_INSTALL_STORAGE_URL}, $xcodeFileName, ${env:XCODE_INSTALL_SAS}
Invoke-DownloadWithRetry -Url $xcodeUri -Path (Join-Path $tempXipDirectory.FullName $xcodeFileName) | Out-Null
$xcodeFullPath = Join-Path $tempXipDirectory.FullName $xcodeFileName
Invoke-DownloadWithRetry -Url $xcodeUri -Path $xcodeFullPath | Out-Null
# Validating checksum
$xcodeSha256 = Get-FileHash -Path $xcodeFullPath -Algorithm SHA256 | Select-Object -ExpandProperty Hash
if ($xcodeSha256 -ne $Sha256Sum) {
throw "Xcode $Version checksum mismatch. Expected: $Sha256Sum, Actual: $xcodeSha256"
}
return $tempXipDirectory
}