Skip to content

Commit

Permalink
[Mac OS] Configure template for Mac OS 14 ARM64 image (actions#8769)
Browse files Browse the repository at this point in the history
* Configure template for Mac OS 14 ARM64 image

* Change conditions for ruby
  • Loading branch information
vpolikarpov-akvelon authored Nov 10, 2023
1 parent f685533 commit df292be
Show file tree
Hide file tree
Showing 31 changed files with 434 additions and 202 deletions.
14 changes: 9 additions & 5 deletions images/macos/helpers/Common.Helpers.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,17 @@ function Get-OSVersion {
$osVersionMajorMinor = $osVersion.Version.ToString(2)
$processorArchitecture = arch
return [PSCustomObject]@{
Version = $osVersion.Version
Platform = $osVersion.Platform
IsBigSur = $osVersion.Version.Major -eq "11"
IsMonterey = $osVersion.Version.Major -eq "12"
IsVentura = $($osVersion.Version.Major -eq "13" -and $processorArchitecture -ne "arm64")
Version = $osVersion.Version
Platform = $osVersion.Platform
IsArm64 = $processorArchitecture -eq "arm64"
IsBigSur = $osVersion.Version.Major -eq "11"
IsMonterey = $osVersion.Version.Major -eq "12"
IsVentura = $($osVersion.Version.Major -eq "13")
IsVenturaArm64 = $($osVersion.Version.Major -eq "13" -and $processorArchitecture -eq "arm64")
IsVenturaX64 = $($osVersion.Version.Major -eq "13" -and $processorArchitecture -ne "arm64")
IsSonoma = $($osVersion.Version.Major -eq "14")
IsSonomaArm64 = $($osVersion.Version.Major -eq "14" -and $processorArchitecture -eq "arm64")
IsSonomaX64 = $($osVersion.Version.Major -eq "14" -and $processorArchitecture -ne "arm64")
}
}

Expand Down
2 changes: 1 addition & 1 deletion images/macos/helpers/Xcode.Installer.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function Approve-XcodeLicense {
Write-Host "Approving Xcode license for '$XcodeRootPath'..."
$xcodeBuildPath = Get-XcodeToolPath -XcodeRootPath $XcodeRootPath -ToolName "xcodebuild"

if ($os.IsVentura -or $os.IsVenturaArm64 -or $os.IsSonoma) {
if ($os.IsVentura -or $os.IsSonoma) {
Invoke-ValidateCommand -Command "sudo $xcodeBuildPath -license accept" -Timeout 15
} else {
Invoke-ValidateCommand -Command "sudo $xcodeBuildPath -license accept"
Expand Down
2 changes: 1 addition & 1 deletion images/macos/provision/configuration/preimagedata.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ else
fi
release_label="macOS-${label_version}"

if is_Ventura || is_Sonoma; then
if is_VenturaX64 || is_SonomaX64; then
software_url="https://github.com/actions/runner-images/blob/${image_label}/${image_version}/images/macos/${image_label}-Readme.md"
releaseUrl="https://github.com/actions/runner-images/releases/tag/${image_label}%2F${image_version}"
else
Expand Down
2 changes: 1 addition & 1 deletion images/macos/provision/core/open_windows_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
source ~/utils/utils.sh

# Close System Preferences window because in Ventura arm64 it is opened by default on Apperance tab
if is_VenturaArm64; then
if is_Arm64; then
echo "Close System Preferences window"
osascript -e 'tell application "System Preferences" to quit'
fi
Expand Down
4 changes: 2 additions & 2 deletions images/macos/provision/core/openssl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ source ~/utils/utils.sh
echo "Install [email protected]"
brew_smart_install "[email protected]"

if ! is_VenturaArm64; then
if ! is_Arm64; then
# Symlink brew [email protected] to `/usr/local/bin` as Homebrew refuses
ln -sf $(brew --prefix [email protected])/bin/openssl /usr/local/bin/openssl
else
# arm64 has a different installation prefix for brew
ln -sf $(brew --prefix [email protected])/bin/openssl /opt/homebrew/bin/openssl
fi

if ! is_VenturaArm64; then
if ! is_Arm64; then
# Most of buildsystems and scripts look up ssl here
ln -sf $(brew --cellar [email protected])/1.1* /usr/local/opt/openssl
fi
Expand Down
2 changes: 1 addition & 1 deletion images/macos/provision/core/ruby.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ else
echo 'export PATH="$GEM_PATH:/usr/local/opt/ruby@'${DEFAULT_RUBY_VERSION}'/bin:$PATH"' >> "$HOME/.bashrc"
fi

if ! is_VenturaArm64; then
if ! is_Arm64; then
echo "Install Ruby from toolset..."
[ -n "$API_PAT" ] && authString=(-H "Authorization: token ${API_PAT}")
PACKAGE_TAR_NAMES=$(curl "${authString[@]}" -fsSL "https://api.github.com/repos/ruby/ruby-builder/releases/latest" | jq -r '.assets[].name')
Expand Down
55 changes: 23 additions & 32 deletions images/macos/provision/utils/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,53 +46,44 @@ download_with_retries() {
return 1
}

is_VenturaArm64() {
arch=$(get_arch)
if [ "$OSTYPE" = "darwin22" ] && [ $arch = "arm64" ]; then
true
else
false
fi
is_Arm64() {
[ "$(arch)" = "arm64" ]
}

is_Sonoma() {
if [ "$OSTYPE" = "darwin23" ]; then
true
else
false
fi
[ "$OSTYPE" = "darwin23" ]
}

is_SonomaArm64() {
is_Sonoma && is_Arm64
}

is_SonomaX64() {
is_Sonoma && ! is_Arm64
}

is_Ventura() {
if [ "$OSTYPE" = "darwin22" ]; then
true
else
false
fi
[ "$OSTYPE" = "darwin22" ]
}

is_VenturaArm64() {
is_Ventura && is_Arm64
}

is_VenturaX64() {
is_Ventura && ! is_Arm64
}

is_Monterey() {
if [ "$OSTYPE" = "darwin21" ]; then
true
else
false
fi
[ "$OSTYPE" = "darwin21" ]
}

is_BigSur() {
if [ "$OSTYPE" = "darwin20" ]; then
true
else
false
fi
[ "$OSTYPE" = "darwin20" ]
}

is_Veertu() {
if [ -d "/Library/Application Support/Veertu" ]; then
true
else
false
fi
[ -d "/Library/Application Support/Veertu" ]
}

get_toolset_path() {
Expand Down
4 changes: 2 additions & 2 deletions images/macos/software-report/SoftwareReport.Browsers.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function Build-BrowserSection {
[ToolVersionNode]::new("ChromeDriver", $(Get-ChromeDriverVersion))
)

if (-not $os.IsVenturaArm64) {
if ((-not $os.IsVenturaArm64) -and (-not $os.IsSonomaArm64)) {
$nodes += @(
[ToolVersionNode]::new("Microsoft Edge", $(Get-EdgeVersion))
[ToolVersionNode]::new("Microsoft Edge WebDriver", $(Get-EdgeDriverVersion))
Expand Down Expand Up @@ -79,7 +79,7 @@ function Get-GeckodriverVersion {

function Get-SeleniumVersion {
$os = Get-OSVersion
if ($os.IsVenturaArm64) {
if ($os.IsVenturaArm64 -or $os.IsSonomaArm64) {
$cellarPath = "/opt/homebrew/Cellar"
} else {
$cellarPath = "/usr/local/Cellar"
Expand Down
50 changes: 25 additions & 25 deletions images/macos/software-report/SoftwareReport.Generator.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,26 @@ $languageAndRuntime.AddNodes($(Get-GccVersions))
$languageAndRuntime.AddNodes($(Get-FortranVersions))
$languageAndRuntime.AddToolVersion("Julia", $(Get-JuliaVersion))
$languageAndRuntime.AddToolVersion("Kotlin", $(Get-KotlinVersion))
if ((-not $os.IsVentura) -and (-not $os.IsVenturaArm64) -and (-not $os.IsSonoma)) {
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
$languageAndRuntime.AddToolVersion("Go", $(Get-GoVersion))
}
$languageAndRuntime.AddToolVersion("Mono", $(Get-MonoVersion))
$languageAndRuntime.AddToolVersion("Node.js", $(Get-NodeVersion))
if ((-not $os.IsVentura) -and (-not $os.IsVenturaArm64) -and (-not $os.IsSonoma)) {
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
$languageAndRuntime.AddToolVersion("MSBuild", $(Get-MSBuildVersion))
$languageAndRuntime.AddToolVersion("NVM", $(Get-NVMVersion))
$languageAndRuntime.AddToolVersionsListInline("NVM - Cached node versions", $(Get-NVMNodeVersionList), '^\d+')
}
$languageAndRuntime.AddToolVersion("Perl", $(Get-PerlVersion))
if (-not $os.IsVenturaArm64) {
if ((-not $os.IsVenturaArm64) -and (-not $os.IsSonomaArm64)) {
$languageAndRuntime.AddToolVersion("PHP", $(Get-PHPVersion))
}

if ((-not $os.IsVentura) -and (-not $os.IsVenturaArm64) -and (-not $os.IsSonoma)) {
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
$languageAndRuntime.AddToolVersion("Python", $(Get-PythonVersion))
}

if (-not $os.IsVenturaArm64) {
if ((-not $os.IsVenturaArm64) -and (-not $os.IsSonomaArm64)) {
$languageAndRuntime.AddToolVersion("Python3", $(Get-Python3Version))
}
$languageAndRuntime.AddToolVersion("R", $(Get-RVersion))
Expand All @@ -70,39 +70,39 @@ $packageManagement = $installedSoftware.AddHeader("Package Management")
$packageManagement.AddToolVersion("Bundler", $(Get-BundlerVersion))
$packageManagement.AddToolVersion("Carthage", $(Get-CarthageVersion))
$packageManagement.AddToolVersion("CocoaPods", $(Get-CocoaPodsVersion))
if (-not $os.IsVenturaArm64) {
if ((-not $os.IsVenturaArm64) -and (-not $os.IsSonomaArm64)) {
$packageManagement.AddToolVersion("Composer", $(Get-ComposerVersion))
}
$packageManagement.AddToolVersion("Homebrew", $(Get-HomebrewVersion))
if ((-not $os.IsVentura) -and (-not $os.IsVenturaArm64) -and (-not $os.IsSonoma)) {
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
$packageManagement.AddToolVersion("Miniconda", $(Get-CondaVersion))
}
$packageManagement.AddToolVersion("NPM", $(Get-NPMVersion))
$packageManagement.AddToolVersion("NuGet", $(Get-NuGetVersion))
if ((-not $os.IsVentura) -and (-not $os.IsVenturaArm64) -and (-not $os.IsSonoma)) {
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
$packageManagement.AddToolVersion("Pip", $(Get-PipVersion -Version 2))
}

if (-not $os.IsVenturaArm64) {
if ((-not $os.IsVenturaArm64) -and (-not $os.IsSonomaArm64)) {
$packageManagement.AddToolVersion("Pip3", $(Get-PipVersion -Version 3))
$packageManagement.AddToolVersion("Pipx", $(Get-PipxVersion))
}

$packageManagement.AddToolVersion("RubyGems", $(Get-RubyGemsVersion))
if (-not $os.IsVenturaArm64) {
if ((-not $os.IsVenturaArm64) -and (-not $os.IsSonomaArm64)) {
$packageManagement.AddToolVersion("Vcpkg", $(Get-VcpkgVersion))
}
$packageManagement.AddToolVersion("Yarn", $(Get-YarnVersion))

if ((-not $os.IsVentura) -and (-not $os.IsVenturaArm64) -and (-not $os.IsSonoma)) {
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
$packageManagement.AddNode($(Build-PackageManagementEnvironmentTable))
}
# Project Management
$projectManagement = $installedSoftware.AddHeader("Project Management")
$projectManagement.AddToolVersion("Apache Ant", $(Get-ApacheAntVersion))
$projectManagement.AddToolVersion("Apache Maven", $(Get-MavenVersion))
$projectManagement.AddToolVersion("Gradle", $(Get-GradleVersion))
if ((-not $os.IsVentura) -and (-not $os.IsVenturaArm64) -and (-not $os.IsSonoma)) {
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
$projectManagement.AddToolVersion("Sbt", $(Get-SbtVersion))
}

Expand All @@ -124,11 +124,11 @@ $utilities.AddToolVersion("gpg (GnuPG)", $(Get-GPGVersion))
if ($os.IsBigSur) {
$utilities.AddToolVersion("helm", $(Get-HelmVersion))
}
if ((-not $os.IsVentura) -and (-not $os.IsVenturaArm64) -and (-not $os.IsSonoma)) {
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
$utilities.AddToolVersion("ImageMagick", $(Get-ImageMagickVersion))
}
$utilities.AddToolVersion("jq", $(Get-JqVersion))
if ((-not $os.IsVentura) -and (-not $os.IsVenturaArm64) -and (-not $os.IsSonoma)) {
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
$utilities.AddToolVersion("mongo", $(Get-MongoVersion))
$utilities.AddToolVersion("mongod", $(Get-MongodVersion))
}
Expand All @@ -138,7 +138,7 @@ if ($os.IsBigSur) {
$utilities.AddToolVersion("OpenSSL", $(Get-OpenSSLVersion))
$utilities.AddToolVersion("Packer", $(Get-PackerVersion))
$utilities.AddToolVersion("pkg-config", $(Get-PKGConfigVersion))
if ((-not $os.IsVentura) -and (-not $os.IsVenturaArm64) -and (-not $os.IsSonoma)) {
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
$utilities.AddToolVersion("PostgreSQL", $(Get-PostgresServerVersion))
$utilities.AddToolVersion("psql (PostgreSQL)", $(Get-PostgresClientVersion))
$utilities.AddToolVersion("Sox", $(Get-SoxVersion))
Expand All @@ -157,7 +157,7 @@ $tools = $installedSoftware.AddHeader("Tools")
if ($os.IsBigSur) {
$tools.AddToolVersion("Aliyun CLI", $(Get-AliyunCLIVersion))
}
if ((-not $os.IsVentura) -and (-not $os.IsVenturaArm64) -and (-not $os.IsSonoma)) {
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
$tools.AddToolVersion("App Center CLI", $(Get-AppCenterCLIVersion))
}
$tools.AddToolVersion("AWS CLI", $(Get-AWSCLIVersion))
Expand All @@ -166,7 +166,7 @@ $tools.AddToolVersion("AWS Session Manager CLI", $(Get-AWSSessionManagerCLIVersi
$tools.AddToolVersion("Azure CLI", $(Get-AzureCLIVersion))
$tools.AddToolVersion("Azure CLI (azure-devops)", $(Get-AzureDevopsVersion))
$tools.AddToolVersion("Bicep CLI", $(Get-BicepVersion))
if ((-not $os.IsVentura) -and (-not $os.IsVenturaArm64) -and (-not $os.IsSonoma)) {
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
$tools.AddToolVersion("Cabal", $(Get-CabalVersion))
}
$tools.AddToolVersion("Cmake", $(Get-CmakeVersion))
Expand All @@ -175,26 +175,26 @@ if ($os.IsMonterey) {
$tools.AddToolVersion("Colima", $(Get-ColimaVersion))
}
$tools.AddToolVersion("Fastlane", $(Get-FastlaneVersion))
if ((-not $os.IsVentura) -and (-not $os.IsVenturaArm64) -and (-not $os.IsSonoma)) {
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
$tools.AddToolVersion("GHC", $(Get-GHCVersion))
$tools.AddToolVersion("GHCup", $(Get-GHCupVersion))
$tools.AddToolVersion("Jazzy", $(Get-JazzyVersion))
}
if (-not $os.IsVenturaArm64) {
if ((-not $os.IsVenturaArm64) -and (-not $os.IsSonomaArm64)) {
$tools.AddToolVersion("Stack", $(Get-StackVersion))
}
$tools.AddToolVersion("SwiftFormat", $(Get-SwiftFormatVersion))
if ((-not $os.IsVentura) -and (-not $os.IsVenturaArm64) -and (-not $os.IsSonoma)) {
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
$tools.AddToolVersion("Swig", $(Get-SwigVersion))
}
$tools.AddToolVersion("Xcode Command Line Tools", $(Get-XcodeCommandLineToolsVersion))

# Linters
$linters = $installedSoftware.AddHeader("Linters")
if (-not $os.IsVenturaArm64) {
if ((-not $os.IsVenturaArm64) -and (-not $os.IsSonomaArm64)) {
$linters.AddToolVersion("SwiftLint", $(Get-SwiftLintVersion))
}
if ((-not $os.IsVentura) -and (-not $os.IsVenturaArm64) -and (-not $os.IsSonoma)) {
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
$linters.AddToolVersion("Yamllint", $(Get-YamllintVersion))
}

Expand All @@ -220,7 +220,7 @@ if (-not $os.IsSonoma) {
$rust.AddToolVersion("Rustup", $(Get-RustupVersion))

$rustPackages = $rust.AddHeader("Packages")
if ((-not $os.IsVentura) -and (-not $os.IsVenturaArm64)) {
if (-not $os.IsVentura) {
$rustPackages.AddToolVersion("Bindgen", $(Get-Bindgen))
$rustPackages.AddToolVersion("Cargo-audit", $(Get-Cargoaudit))
$rustPackages.AddToolVersion("Cargo-outdated", $(Get-Cargooutdated))
Expand All @@ -238,13 +238,13 @@ $powerShellModules = $powerShell.AddHeader("PowerShell Modules")
$powerShellModules.AddNodes($(Get-PowerShellModules))

# Web Servers
if ((-not $os.IsVentura) -and (-not $os.IsVenturaArm64) -and (-not $os.IsSonoma)) {
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
$webServers = $installedSoftware.AddHeader("Web Servers")
$webServers.AddTable($(Build-WebServersSection))
}

# Xamarin section
if ((-not $os.IsVentura) -and (-not $os.IsVenturaArm64) -and (-not $os.IsSonoma)) {
if ((-not $os.IsVentura) -and (-not $os.IsSonoma)) {
$xamarin = $installedSoftware.AddHeader("Xamarin")
$vsForMac = $xamarin.AddHeader("Visual Studio for Mac")
$vsForMac.AddTable($(Build-VSMacTable))
Expand Down
2 changes: 1 addition & 1 deletion images/macos/software-report/SoftwareReport.Java.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ function Get-JavaVersions {
$defaultJavaPath = (Get-Item env:JAVA_HOME).value

$os = Get-OSVersion
if ($os.IsVenturaArm64) {
if ($os.IsVenturaArm64 -or $os.IsSonomaArm64) {
$javaVersions = Get-Item env:JAVA_HOME_*_arm64
} else {
$javaVersions = Get-Item env:JAVA_HOME_*_X64
Expand Down
2 changes: 1 addition & 1 deletion images/macos/software-report/SoftwareReport.Toolcache.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function Build-ToolcacheSection {

$nodes = @()

if (-not $os.IsVenturaArm64) {
if ((-not $os.IsVenturaArm64) -and (-not $os.IsSonomaArm64)) {
$nodes += @(
[ToolVersionsListNode]::new("Ruby", $(Get-ToolcacheRubyVersions), '^\d+\.\d+', "List"),
[ToolVersionsListNode]::new("PyPy", $(Get-ToolcachePyPyVersions), '^\d+\.\d+', "List")
Expand Down
Loading

0 comments on commit df292be

Please sign in to comment.