mirror of
https://github.com/actions/runner-images.git
synced 2025-12-13 20:56:47 +00:00
[Mac OS] Update Anka Helpers to build Mac OS 14 ARM image (#8757)
* Update Anka Helpers to build Mac OS 14 ARM image * Drop Powershell 5 support
This commit is contained in:
committed by
GitHub
parent
be3fa4f3c3
commit
bbbda7bddf
@@ -63,24 +63,24 @@ function Get-AvailableIPSWVersions {
|
|||||||
)
|
)
|
||||||
|
|
||||||
if ($IsBeta) {
|
if ($IsBeta) {
|
||||||
$command = { mist list firmware "$MacOSCodeNameOrVersion" --include-betas --latest --export "/Applications/export.json"}
|
$command = { mist list firmware "$MacOSCodeNameOrVersion" --compatible --include-betas --latest --export "/Applications/export.json" }
|
||||||
} elseif ($IsLatest) {
|
} elseif ($IsLatest) {
|
||||||
$command = { mist list firmware "$MacOSCodeNameOrVersion" --latest --export "/Applications/export.json" }
|
$command = { mist list firmware "$MacOSCodeNameOrVersion" --compatible --latest --export "/Applications/export.json" }
|
||||||
} else {
|
} else {
|
||||||
$command = { mist list firmware "$MacOSCodeNameOrVersion" --export "/Applications/export.json" }
|
$command = { mist list firmware "$MacOSCodeNameOrVersion" --compatible --export "/Applications/export.json" }
|
||||||
}
|
}
|
||||||
|
|
||||||
$condition = { $LASTEXITCODE -eq 0 }
|
$condition = { $LASTEXITCODE -eq 0 }
|
||||||
Invoke-WithRetry -Command $command -BreakCondition $condition | Out-Null
|
Invoke-WithRetry -Command $command -BreakCondition $condition | Out-Null
|
||||||
$softwareList = get-content -Path "/Applications/export.json"
|
$softwareList = get-content -Path "/Applications/export.json"
|
||||||
$turgetVersion = ($softwareList | ConvertFrom-Json).version
|
$availableBuilds = ($softwareList | ConvertFrom-Json).build
|
||||||
if ($null -eq $turgetVersion) {
|
if ($null -eq $availableBuilds) {
|
||||||
Write-Host "Requested macOS '$MacOSCodeNameOrVersion' version not found in the list of available installers."
|
Write-Host "Requested macOS '$MacOSCodeNameOrVersion' version not found in the list of available installers."
|
||||||
$command = { mist list firmware "$($MacOSCodeNameOrVersion.split('.')[0])" }
|
$command = { mist list firmware "$($MacOSCodeNameOrVersion.split('.')[0])" }
|
||||||
Invoke-WithRetry -Command $command -BreakCondition $condition
|
Invoke-WithRetry -Command $command -BreakCondition $condition
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
return $turgetVersion
|
return $availableBuilds
|
||||||
}
|
}
|
||||||
|
|
||||||
function Get-MacOSIPSWInstaller {
|
function Get-MacOSIPSWInstaller {
|
||||||
@@ -100,17 +100,20 @@ function Get-MacOSIPSWInstaller {
|
|||||||
$MacOSName = $MacOSVersion.ToString()
|
$MacOSName = $MacOSVersion.ToString()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Write-Host "`t[*] Finding available full installers"
|
Write-Host "`t[*] Finding available full installers"
|
||||||
if ($DownloadLatestVersion -eq $true) {
|
if ($DownloadLatestVersion -eq $true) {
|
||||||
$targetVersion = Get-AvailableIPSWVersions -IsLatest $true -MacOSCodeNameOrVersion $MacOSName
|
$targetBuild = Get-AvailableIPSWVersions -IsLatest $true -MacOSCodeNameOrVersion $MacOSName
|
||||||
Write-host "`t[*] The 'DownloadLatestVersion' flag is set to true. Latest macOS version is '$MacOSName' - '$targetVersion' now"
|
Write-Host "`t[*] The 'DownloadLatestVersion' flag is set to true. Latest compatible macOS build of '$MacOSName' is '$targetBuild'"
|
||||||
} elseif ($BetaSearch -eq $true) {
|
} elseif ($BetaSearch -eq $true) {
|
||||||
$targetVersion = Get-AvailableIPSWVersions -IsBeta $true -MacOSCodeNameOrVersion $MacOSName
|
$targetBuild = Get-AvailableIPSWVersions -IsBeta $true -MacOSCodeNameOrVersion $MacOSName
|
||||||
Write-host "`t[*] The 'BetaSearch' flag is set to true. Latestbeta macOS version is '$MacOSName' - '$targetVersion' now"
|
Write-Host "`t[*] The 'BetaSearch' flag is set to true. Latest compatible beta macOS build of '$MacOSName' is '$targetBuild'"
|
||||||
} else {
|
} else {
|
||||||
$targetVersion = Get-AvailableIPSWVersions -MacOSCodeNameOrVersion $MacOSName -IsLatest $false
|
$targetBuild = Get-AvailableIPSWVersions -MacOSCodeNameOrVersion $MacOSName -IsLatest $false
|
||||||
Write-host "`t[*] The exact version was specified - '$MacOSName' "
|
Write-Host "`t[*] Available compatible macOS builds of '$MacOSName' are: $($targetBuild -join ', ')"
|
||||||
|
if ($targetBuild.Count -gt 1) {
|
||||||
|
Write-Error "`t[*] Please specify the exact build number of macOS you want to install"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$installerPathPattern = "/Applications/Install ${macOSName}*.ipsw"
|
$installerPathPattern = "/Applications/Install ${macOSName}*.ipsw"
|
||||||
@@ -123,12 +126,12 @@ function Get-MacOSIPSWInstaller {
|
|||||||
# Download macOS installer
|
# Download macOS installer
|
||||||
$installerDir = "/Applications/"
|
$installerDir = "/Applications/"
|
||||||
$installerName = "Install ${macOSName}.ipsw"
|
$installerName = "Install ${macOSName}.ipsw"
|
||||||
Write-Host "`t[*] Requested macOS '$targetVersion' version installer found, fetching it from mist database"
|
Write-Host "`t[*] Requested macOS '$targetBuild' version installer found, fetching it from mist database"
|
||||||
Invoke-WithRetry { mist download firmware "$targetVersion" --output-directory $installerDir --firmware-name "$installerName" } {$LASTEXITCODE -eq 0} | Out-Null
|
Invoke-WithRetry { mist download firmware "$targetBuild" --output-directory $installerDir --firmware-name "$installerName" } { $LASTEXITCODE -eq 0 } | Out-Null
|
||||||
if (Test-Path "$installerDir$installerName") {
|
if (Test-Path "$installerDir$installerName") {
|
||||||
$result = "$installerDir$installerName"
|
$result = "$installerDir$installerName"
|
||||||
} else {
|
} else {
|
||||||
Write-host "`t[*] Requested macOS '$targetVersion' version installer failed to download"
|
Write-Error "`t[*] Requested macOS '$targetBuild' version installer failed to download"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
return $result
|
return $result
|
||||||
@@ -302,7 +305,11 @@ function Invoke-SSHPassCommand {
|
|||||||
"${env:SSHUSER}@${HostName}"
|
"${env:SSHUSER}@${HostName}"
|
||||||
)
|
)
|
||||||
$sshPassOptions = $sshArg -join " "
|
$sshPassOptions = $sshArg -join " "
|
||||||
|
if ($PSVersionTable.PSVersion.Major -eq 7 -and $PSVersionTable.PSVersion.Minor -le 2) {
|
||||||
$result = bash -c "$sshPassOptions \""$Command\"" 2>&1"
|
$result = bash -c "$sshPassOptions \""$Command\"" 2>&1"
|
||||||
|
} else {
|
||||||
|
$result = bash -c "$sshPassOptions `"$Command`" 2>&1"
|
||||||
|
}
|
||||||
if ($LASTEXITCODE -ne 0) {
|
if ($LASTEXITCODE -ne 0) {
|
||||||
Write-Error "There is an error during command execution:`n$result"
|
Write-Error "There is an error during command execution:`n$result"
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
Reference in New Issue
Block a user