mirror of
https://github.com/actions/runner-images.git
synced 2025-12-20 06:35:47 +00:00
Parallel installation of Xcode (#2432)
* parallel xcode installation * resolve comments * fix changes * resolve comments and change ErrorActionPreference * return imports * switch ErrorActionPreference to Stop * add log for threadCount * add errorAction * use new approach for warning * change to bash -c * change approach to install xcodes through to parallel foreach * use & bash -c "command" * mv upper ErrorActionPreference and work on logs * mv $env:SPACESHIP_SKIP_2FA_UPGRADE = 1 * change process count to 5 * Invoke-XCVersion add out-host
This commit is contained in:
@@ -10,15 +10,16 @@ function Install-XcodeVersion {
|
|||||||
|
|
||||||
$xcodeDownloadDirectory = "$env:HOME/Library/Caches/XcodeInstall"
|
$xcodeDownloadDirectory = "$env:HOME/Library/Caches/XcodeInstall"
|
||||||
$xcodeTargetPath = Get-XcodeRootPath -Version $LinkTo
|
$xcodeTargetPath = Get-XcodeRootPath -Version $LinkTo
|
||||||
|
$xcodeXipDirectory = Invoke-DownloadXcodeArchive -DownloadDirectory $xcodeDownloadDirectory -Version $Version
|
||||||
|
Expand-XcodeXipArchive -DownloadDirectory $xcodeXipDirectory -TargetPath $xcodeTargetPath
|
||||||
|
|
||||||
Invoke-DownloadXcodeArchive -Version $Version
|
Remove-Item -Path $xcodeXipDirectory -Force -Recurse
|
||||||
Expand-XcodeXipArchive -DownloadDirectory $xcodeDownloadDirectory -TargetPath $xcodeTargetPath
|
|
||||||
|
|
||||||
Get-ChildItem $xcodeDownloadDirectory | Remove-Item -Force
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function Invoke-DownloadXcodeArchive {
|
function Invoke-DownloadXcodeArchive {
|
||||||
param(
|
param(
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
[string]$DownloadDirectory,
|
||||||
[Parameter(Mandatory)]
|
[Parameter(Mandatory)]
|
||||||
[string]$Version
|
[string]$Version
|
||||||
)
|
)
|
||||||
@@ -28,7 +29,15 @@ function Invoke-DownloadXcodeArchive {
|
|||||||
throw "Version '$Version' can't be matched to any available version"
|
throw "Version '$Version' can't be matched to any available version"
|
||||||
}
|
}
|
||||||
Write-Host "Downloading Xcode $resolvedVersion"
|
Write-Host "Downloading Xcode $resolvedVersion"
|
||||||
Invoke-XCVersion -Arguments "install '$resolvedVersion' --no-install"
|
Invoke-XCVersion -Arguments "install '$resolvedVersion' --no-install" | Out-Host
|
||||||
|
|
||||||
|
$xcodeXipName = "$resolvedVersion" -replace " ", "_"
|
||||||
|
$xcodeXipFile = Get-ChildItem -Path $DownloadDirectory -Filter "Xcode_$xcodeXipName.xip" | Select-Object -First 1
|
||||||
|
$tempXipDirectory = New-Item -Path $DownloadDirectory -Name "Xcode$xcodeXipName" -ItemType "Directory"
|
||||||
|
Move-Item -Path "$xcodeXipFile" -Destination $tempXipDirectory
|
||||||
|
|
||||||
|
return $tempXipDirectory
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function Resolve-ExactXcodeVersion {
|
function Resolve-ExactXcodeVersion {
|
||||||
|
|||||||
@@ -18,9 +18,14 @@ $os = Get-OSVersion
|
|||||||
$xcodeVersions = Get-ToolsetValue "xcode.versions"
|
$xcodeVersions = Get-ToolsetValue "xcode.versions"
|
||||||
$defaultXcode = Get-ToolsetValue "xcode.default"
|
$defaultXcode = Get-ToolsetValue "xcode.default"
|
||||||
[Array]::Reverse($xcodeVersions)
|
[Array]::Reverse($xcodeVersions)
|
||||||
|
$threadCount = "5"
|
||||||
|
|
||||||
Write-Host "Installing Xcode versions..."
|
Write-Host "Installing Xcode versions..."
|
||||||
$xcodeVersions | ForEach-Object {
|
$xcodeVersions | ForEach-Object -ThrottleLimit $threadCount -Parallel {
|
||||||
|
$ErrorActionPreference = "Stop"
|
||||||
|
Import-Module "$env:HOME/image-generation/helpers/Common.Helpers.psm1"
|
||||||
|
Import-Module "$env:HOME/image-generation/helpers/Xcode.Installer.psm1"
|
||||||
|
|
||||||
Install-XcodeVersion -Version $_.version -LinkTo $_.link
|
Install-XcodeVersion -Version $_.version -LinkTo $_.link
|
||||||
Confirm-XcodeIntegrity -Version $_.link
|
Confirm-XcodeIntegrity -Version $_.link
|
||||||
Approve-XcodeLicense -Version $_.link
|
Approve-XcodeLicense -Version $_.link
|
||||||
@@ -31,7 +36,9 @@ if ($os.IsLessThanCatalina) {
|
|||||||
$latestXcodeVersion = $xcodeVersions | Select-Object -Last 1 -ExpandProperty link
|
$latestXcodeVersion = $xcodeVersions | Select-Object -Last 1 -ExpandProperty link
|
||||||
Install-XcodeAdditionalPackages -Version $latestXcodeVersion
|
Install-XcodeAdditionalPackages -Version $latestXcodeVersion
|
||||||
}
|
}
|
||||||
$xcodeVersions | ForEach-Object { Invoke-XcodeRunFirstLaunch -Version $_.link }
|
$xcodeVersions | ForEach-Object {
|
||||||
|
Invoke-XcodeRunFirstLaunch -Version $_.link
|
||||||
|
}
|
||||||
Invoke-XcodeRunFirstLaunch -Version $defaultXcode
|
Invoke-XcodeRunFirstLaunch -Version $defaultXcode
|
||||||
|
|
||||||
Write-Host "Configuring Xcode symlinks..."
|
Write-Host "Configuring Xcode symlinks..."
|
||||||
|
|||||||
Reference in New Issue
Block a user