mirror of
https://github.com/actions/runner-images.git
synced 2025-12-12 12:06:59 +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
|
||||||
@@ -169,7 +172,7 @@ function Get-MacOSInstaller {
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
Show-StringWithFormat $filteredVersions
|
Show-StringWithFormat $filteredVersions
|
||||||
$osVersions = $filteredVersions.OSVersion | Sort-Object {[version]$_}
|
$osVersions = $filteredVersions.OSVersion | Sort-Object { [version]$_ }
|
||||||
$MacOSVersion = $osVersions | Select-Object -Last 1
|
$MacOSVersion = $osVersions | Select-Object -Last 1
|
||||||
Write-Host "`t[*] The 'DownloadLatestVersion' flag is set. Latest macOS version is '$MacOSVersion' now"
|
Write-Host "`t[*] The 'DownloadLatestVersion' flag is set. Latest macOS version is '$MacOSVersion' now"
|
||||||
}
|
}
|
||||||
@@ -248,7 +251,7 @@ function Install-SoftwareUpdate {
|
|||||||
$command = "sw_vers"
|
$command = "sw_vers"
|
||||||
$guestMacosVersion = Invoke-SSHPassCommand -HostName $HostName -Command $command
|
$guestMacosVersion = Invoke-SSHPassCommand -HostName $HostName -Command $command
|
||||||
if ($guestMacosVersion[1] -match "12") {
|
if ($guestMacosVersion[1] -match "12") {
|
||||||
foreach ($update in $listOfUpdates){
|
foreach ($update in $listOfUpdates) {
|
||||||
# Filtering updates that contain "Ventura" word
|
# Filtering updates that contain "Ventura" word
|
||||||
if ($update -notmatch "Ventura") {
|
if ($update -notmatch "Ventura") {
|
||||||
$command = "sudo /usr/sbin/softwareupdate --restart --verbose --install '$($update.trim())'"
|
$command = "sudo /usr/sbin/softwareupdate --restart --verbose --install '$($update.trim())'"
|
||||||
@@ -256,7 +259,7 @@ function Install-SoftwareUpdate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif ($guestMacosVersion[1] -match "13") {
|
} elseif ($guestMacosVersion[1] -match "13") {
|
||||||
foreach ($update in $listOfUpdates){
|
foreach ($update in $listOfUpdates) {
|
||||||
# Filtering updates that contain "Sonoma" word
|
# Filtering updates that contain "Sonoma" word
|
||||||
if ($update -notmatch "Sonoma") {
|
if ($update -notmatch "Sonoma") {
|
||||||
$command = "sudo /usr/sbin/softwareupdate --restart --verbose --install '$($update.trim())'"
|
$command = "sudo /usr/sbin/softwareupdate --restart --verbose --install '$($update.trim())'"
|
||||||
@@ -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