Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
d5ce0ff
Make initial build changes to macos M1 packaging
rjmholt Jul 7, 2021
01380dc
Add release skip switch for testing
rjmholt Jul 7, 2021
2a938c9
Fix remote url usage
rjmholt Jul 7, 2021
772cc9f
Remove redundant switch property access
rjmholt Jul 8, 2021
7d3d76e
Use function for M1 macOS detection
rjmholt Jul 8, 2021
6ebe0cd
Build M1 macos build separately
rjmholt Jul 9, 2021
a1f2f39
Change job name
rjmholt Jul 9, 2021
5d5fd89
Fix job name
rjmholt Jul 9, 2021
b62c2c0
Fix parent jobs
rjmholt Jul 9, 2021
feb0b53
Fix job dependencies
rjmholt Jul 9, 2021
db29359
Don't run crossgen on arm64
rjmholt Jul 9, 2021
7f6af42
Improve symbol copying
rjmholt Jul 12, 2021
7ab5766
Fix parent jobs
rjmholt Jul 12, 2021
8554f86
Fix zip path
rjmholt Jul 12, 2021
80cee02
x
rjmholt Jul 12, 2021
d19f7c0
Move to matrix
rjmholt Jul 13, 2021
fadd924
Fix matrix
rjmholt Jul 13, 2021
a110cbb
Ditch matrix
rjmholt Jul 13, 2021
1699d29
Fix job name
rjmholt Jul 13, 2021
8ca450c
Add specific arch names
rjmholt Jul 13, 2021
e9ee185
Remove bad parameter
rjmholt Jul 13, 2021
7aa86e2
Add runtime to packaging step
rjmholt Jul 13, 2021
136f24f
Always include runtime
rjmholt Jul 13, 2021
09a9d62
Fix tar architecture
rjmholt Jul 13, 2021
eb9c1e5
Address @adityapatwardhan's comments
rjmholt Jul 15, 2021
488bbe7
Skip Start-NativeExecution for macOS M1 detection
rjmholt Jul 15, 2021
eac75d5
Fix arm64 detection
rjmholt Jul 16, 2021
149d4dd
Get more import error output
rjmholt Jul 16, 2021
0d6a9c9
Add trace output
rjmholt Jul 16, 2021
6f1db55
Try Get-Error
rjmholt Jul 16, 2021
bb7c646
Use uname test for M1 arch
rjmholt Jul 16, 2021
25c525e
Remove try/catch
rjmholt Jul 16, 2021
5227d59
Remove ErrorAction setting
rjmholt Jul 16, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,21 @@ function Sync-PSTags
$AddRemoteIfMissing
)

$PowerShellRemoteUrl = "https://github.com/PowerShell/PowerShell.git"
$powerShellRemoteUrls = @(
'https://github.com/PowerShell/PowerShell'
'git@github.com:PowerShell/PowerShell'
)
$defaultRemoteUrl = "$($powerShellRemoteUrls[0]).git"

$upstreamRemoteDefaultName = 'upstream'
$remotes = Start-NativeExecution {git --git-dir="$PSScriptRoot/.git" remote}
$upstreamRemote = $null
foreach($remote in $remotes)
{
$url = Start-NativeExecution {git --git-dir="$PSScriptRoot/.git" remote get-url $remote}
if($url -eq $PowerShellRemoteUrl)
if ($url.EndsWith('.git')) { $url = $url.Substring(0, $url.Length - 4) }

if($url -in $powerShellRemoteUrls)
{
$upstreamRemote = $remote
break
Expand All @@ -49,12 +56,12 @@ function Sync-PSTags

if(!$upstreamRemote -and $AddRemoteIfMissing.IsPresent -and $remotes -notcontains $upstreamRemoteDefaultName)
{
$null = Start-NativeExecution {git --git-dir="$PSScriptRoot/.git" remote add $upstreamRemoteDefaultName $PowerShellRemoteUrl}
$null = Start-NativeExecution {git --git-dir="$PSScriptRoot/.git" remote add $upstreamRemoteDefaultName $defaultRemoteUrl}
$upstreamRemote = $upstreamRemoteDefaultName
}
elseif(!$upstreamRemote)
{
Write-Error "Please add a remote to PowerShell\PowerShell. Example: git remote add $upstreamRemoteDefaultName $PowerShellRemoteUrl" -ErrorAction Stop
Write-Error "Please add a remote to PowerShell\PowerShell. Example: git remote add $upstreamRemoteDefaultName $defaultRemoteUrl" -ErrorAction Stop
}

$null = Start-NativeExecution {git --git-dir="$PSScriptRoot/.git" fetch --tags --quiet $upstreamRemote}
Expand Down Expand Up @@ -135,6 +142,10 @@ function Get-EnvironmentInformation
$environment += @{'UsingHomebrew' = [bool](Get-Command brew -ErrorAction ignore)}
$environment += @{'UsingMacports' = [bool](Get-Command port -ErrorAction ignore)}

$environment += @{
'OSArchitecture' = if ((uname -v) -match 'ARM64') { 'arm64' } else { 'x64' }
}

if (-not($environment.UsingHomebrew -or $environment.UsingMacports)) {
throw "Neither Homebrew nor MacPorts is installed on this system, visit https://brew.sh/ or https://www.macports.org/ to continue"
}
Expand Down
4 changes: 2 additions & 2 deletions tools/ci.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ if(Test-Path $dotNetPath)
}

# import build into the global scope so it can be used by packaging
Import-Module (Join-Path $repoRoot 'build.psm1') -Scope Global
Import-Module (Join-Path $repoRoot 'tools\packaging') -Scope Global
Import-Module (Join-Path $repoRoot 'build.psm1') -Verbose -Scope Global
Import-Module (Join-Path $repoRoot 'tools\packaging') -Verbose -Scope Global

# import the windows specific functcion only in Windows PowerShell or on Windows
if($PSVersionTable.PSEdition -eq 'Desktop' -or $IsWindows)
Expand Down
18 changes: 17 additions & 1 deletion tools/packaging/packaging.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ function Start-PSPackage {
[ValidateScript({$Environment.IsWindows})]
[string] $WindowsRuntime,

[ValidateSet('osx-x64', 'osx-arm64')]
[ValidateScript({$Environment.IsMacOS})]
[string] $MacOSRuntime,

[Switch] $Force,

[Switch] $SkipReleaseChecks,
Expand Down Expand Up @@ -71,12 +75,18 @@ function Start-PSPackage {
# Runtime and Configuration settings required by the package
($Runtime, $Configuration) = if ($WindowsRuntime) {
$WindowsRuntime, "Release"
} elseif ($MacOSRuntime) {
$MacOSRuntime, "Release"
} elseif ($Type -eq "tar-alpine") {
New-PSOptions -Configuration "Release" -Runtime "alpine-x64" -WarningAction SilentlyContinue | ForEach-Object { $_.Runtime, $_.Configuration }
} elseif ($Type -eq "tar-arm") {
New-PSOptions -Configuration "Release" -Runtime "Linux-ARM" -WarningAction SilentlyContinue | ForEach-Object { $_.Runtime, $_.Configuration }
} elseif ($Type -eq "tar-arm64") {
New-PSOptions -Configuration "Release" -Runtime "Linux-ARM64" -WarningAction SilentlyContinue | ForEach-Object { $_.Runtime, $_.Configuration }
if ($IsMacOS) {
New-PSOptions -Configuration "Release" -Runtime "osx-arm64" -WarningAction SilentlyContinue | ForEach-Object { $_.Runtime, $_.Configuration }
} else {
New-PSOptions -Configuration "Release" -Runtime "Linux-ARM64" -WarningAction SilentlyContinue | ForEach-Object { $_.Runtime, $_.Configuration }
}
} else {
New-PSOptions -Configuration "Release" -WarningAction SilentlyContinue | ForEach-Object { $_.Runtime, $_.Configuration }
}
Expand All @@ -97,6 +107,8 @@ function Start-PSPackage {
} elseif ($Type -eq 'fxdependent-win-desktop') {
$NameSuffix = "win-fxdependentWinDesktop"
Write-Log "Packaging : '$Type'; Packaging Configuration: '$Configuration'"
} elseif ($MacOSRuntime) {
$NameSuffix = $MacOSRuntime
} else {
Write-Log "Packaging RID: '$Runtime'; Packaging Configuration: '$Configuration'"
}
Expand Down Expand Up @@ -417,6 +429,10 @@ function Start-PSPackage {
Force = $Force
}

if ($MacOSRuntime) {
$Arguments['Architecture'] = $MacOSRuntime.Split('-')[1]
}

if ($PSCmdlet.ShouldProcess("Create tar.gz Package")) {
New-TarballPackage @Arguments
}
Expand Down
24 changes: 21 additions & 3 deletions tools/releaseBuild/azureDevOps/releaseBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,36 @@ stages:
dependsOn: ['prep']
jobs:
- template: templates/mac.yml
parameters:
buildArchitecture: x64

- template: templates/mac.yml
parameters:
buildArchitecture: arm64

- template: templates/mac-file-signing.yml
parameters:
buildArchitecture: x64

- template: templates/mac-file-signing.yml
parameters:
parentJob: build_macOS
buildArchitecture: arm64

- template: templates/mac-package-build.yml
parameters:
parentJob: MacFileSigningJob
buildArchitecture: x64

- template: templates/mac-package-build.yml
parameters:
buildArchitecture: arm64

- template: templates/mac-package-signing.yml
parameters:
buildArchitecture: x64

- template: templates/mac-package-signing.yml
parameters:
parentJob: package_macOS
buildArchitecture: arm64

- stage: linux
dependsOn: ['prep']
Expand Down
20 changes: 10 additions & 10 deletions tools/releaseBuild/azureDevOps/templates/mac-file-signing.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
parameters:
parentJob: ''
buildArchitecture: 'x64'

jobs:
- job: MacFileSigningJob
displayName: macOS File signing
dependsOn: ${{ parameters.parentJob }}
- job: MacFileSigningJob_${{ parameters.buildArchitecture }}
displayName: macOS File signing ${{ parameters.buildArchitecture }}
dependsOn: build_macOS_${{ parameters.buildArchitecture }}
condition: succeeded()
pool:
name: Package ES Standard Build
Expand Down Expand Up @@ -41,7 +41,7 @@ jobs:
continueOnError: true

- pwsh: |
$zipPath = Get-Item '$(System.ArtifactsDirectory)\Symbols\macosBinResults\*symbol*.zip'
$zipPath = Get-Item '$(System.ArtifactsDirectory)\Symbols\macosBinResults\*symbol*${{ parameters.buildArchitecture }}*.zip'
Write-Verbose -Verbose "Zip Path: $zipPath"

$expandedFolder = $zipPath.BaseName
Expand All @@ -63,7 +63,7 @@ jobs:

- pwsh: |
$null = new-item -type directory -path "$(Build.StagingDirectory)\macos"
$zipFile = "$(Build.StagingDirectory)\macos\powershell-files-$(Version)-osx-x64.zip"
$zipFile = "$(Build.StagingDirectory)\macos\powershell-files-$(Version)-osx-${{ parameters.buildArchitecture }}.zip"
Get-ChildItem "$(System.ArtifactsDirectory)\$(SymbolsFolder)" -Recurse -Include pwsh, *.dylib |
Compress-Archive -Destination $zipFile
Write-Host $zipFile
Expand All @@ -81,7 +81,7 @@ jobs:
displayName: Sign macOS Binaries

- pwsh: |
$destination = "$(System.ArtifactsDirectory)\azureMacOs"
$destination = "$(System.ArtifactsDirectory)\azureMacOs_${{ parameters.buildArchitecture }}"
New-Item -Path $destination -Type Directory
$zipPath = Get-ChildItem "$(Build.StagingDirectory)\signedMacOSPackages\powershell-*.zip" -Recurse | select-object -expandproperty fullname
foreach ($z in $zipPath) { Expand-Archive -Path $z -DestinationPath $destination }
Expand All @@ -90,15 +90,15 @@ jobs:

- template: upload-final-results.yml
parameters:
artifactPath: $(System.ArtifactsDirectory)\azureMacOs
artifactPath: $(System.ArtifactsDirectory)\azureMacOs_${{ parameters.buildArchitecture }}
artifactFilter: "*"
artifactName: signedMacOsBins
artifactName: signedMacOsBins_${{ parameters.buildArchitecture }}
condition: and(succeeded(), eq(variables['SHOULD_SIGN'], 'true'))

- ${{ if eq(variables['SHOULD_SIGN'], 'true') }}:
- template: EsrpScan.yml@ComplianceRepo
parameters:
scanPath: $(System.ArtifactsDirectory)\azureMacOs
scanPath: $(System.ArtifactsDirectory)\azureMacOs_${{ parameters.buildArchitecture }}
pattern: |
**\*

Expand Down
18 changes: 9 additions & 9 deletions tools/releaseBuild/azureDevOps/templates/mac-package-build.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
parameters:
parentJob: ''
jobName: 'package_macOS'
buildArchitecture: x64

jobs:
- job: ${{ parameters.jobName }}
displayName: Package macOS
dependsOn: ${{ parameters.parentJob }}
- job: package_macOS_${{ parameters.buildArchitecture }}
displayName: Package macOS ${{ parameters.buildArchitecture }}
dependsOn: MacFileSigningJob_${{ parameters.buildArchitecture }}
condition: succeeded()
pool: Hosted Mac Internal
variables:
Expand Down Expand Up @@ -40,13 +40,13 @@ jobs:
displayName: Download macosBinResults
inputs:
artifactName: 'macosBinResults'
itemPattern: '**/*.zip'
itemPattern: '**/*${{ parameters.buildArchitecture }}.zip'
downloadPath: '$(System.ArtifactsDirectory)/Symbols'

- task: DownloadBuildArtifacts@0
displayName: Download signedMacOsBins
inputs:
artifactName: 'signedMacOsBins'
artifactName: 'signedMacOsBins_${{ parameters.buildArchitecture }}'
itemPattern: '**/*'
downloadPath: '$(System.ArtifactsDirectory)/macOsBins'
condition: and(succeeded(), eq(variables['SHOULD_SIGN'], 'true'))
Expand All @@ -58,7 +58,7 @@ jobs:
continueOnError: true

- pwsh: |
$zipPath = Get-Item '$(System.ArtifactsDirectory)\Symbols\macosBinResults\*symbol*.zip'
$zipPath = Get-Item '$(System.ArtifactsDirectory)\Symbols\macosBinResults\*symbol*${{ parameters.buildArchitecture }}.zip'
Write-Verbose -Verbose "Zip Path: $zipPath"

$expandedFolder = $zipPath.BaseName
Expand All @@ -71,7 +71,7 @@ jobs:
- pwsh: |
Import-Module $(PowerShellRoot)/build.psm1 -Force
Import-Module $(PowerShellRoot)/tools/packaging -Force
$signedFilesPath = '$(System.ArtifactsDirectory)/macOsBins/signedMacOsBins/'
$signedFilesPath = '$(System.ArtifactsDirectory)/macOsBins/signedMacOsBins_${{ parameters.buildArchitecture }}/'
$BuildPath = '$(System.ArtifactsDirectory)\$(SymbolsFolder)'

Update-PSSignedBuildFolder -BuildPath $BuildPath -SignedFilesPath $SignedFilesPath
Expand Down Expand Up @@ -102,7 +102,7 @@ jobs:
displayName: 'Bootstrap VM'

- pwsh: |
$(Build.SourcesDirectory)/tools/releaseBuild/macOS/PowerShellPackageVsts.ps1 -ReleaseTag $(ReleaseTagVar) -Destination $(System.ArtifactsDirectory) -location $(PowerShellRoot) -ArtifactName macosPkgResults -BuildZip $(BuildPackagePath) -ExtraPackage "tar"
$(Build.SourcesDirectory)/tools/releaseBuild/macOS/PowerShellPackageVsts.ps1 -ReleaseTag $(ReleaseTagVar) -Destination $(System.ArtifactsDirectory) -location $(PowerShellRoot) -ArtifactName macosPkgResults -BuildZip $(BuildPackagePath) -ExtraPackage "tar" -Runtime 'osx-${{ parameters.buildArchitecture }}'
displayName: 'Package'

- task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
parameters:
parentJob: ''
buildArchitecture: x64

jobs:
- job: MacPackageSigningJob
displayName: macOS Package signing
dependsOn: ${{ parameters.parentJob }}
- job: MacPackageSigningJob_${{ parameters.buildArchitecture }}
displayName: macOS Package signing ${{ parameters.buildArchitecture }}
dependsOn: package_macOS_${{ parameters.buildArchitecture }}
condition: succeeded()
pool:
name: Package ES Standard Build
Expand Down Expand Up @@ -41,15 +41,15 @@ jobs:

- pwsh: |
$null = new-item -type directory -path "$(Build.StagingDirectory)\macos"
$zipFile = "$(Build.StagingDirectory)\macos\powershell-$(Version)-osx-x64.zip"
Compress-Archive -Path "$(System.ArtifactsDirectory)\macosPkgResults\powershell-$(Version)-osx-x64.pkg" -Destination $zipFile
$zipFile = "$(Build.StagingDirectory)\macos\powershell-$(Version)-osx-${{ parameters.buildArchitecture }}.zip"
Compress-Archive -Path "$(System.ArtifactsDirectory)\macosPkgResults\powershell-$(Version)-osx-${{ parameters.buildArchitecture }}.pkg" -Destination $zipFile
Write-Host $zipFile

$ltsPkgPath = "$(System.ArtifactsDirectory)\macosPkgResults\powershell-lts-$(Version)-osx-x64.pkg"
$ltsPkgPath = "$(System.ArtifactsDirectory)\macosPkgResults\powershell-lts-$(Version)-osx-${{ parameters.buildArchitecture }}.pkg"

if(Test-Path $ltsPkgPath)
{
$ltsZipFile = "$(Build.StagingDirectory)\macos\powershell-lts-$(Version)-osx-x64.zip"
$ltsZipFile = "$(Build.StagingDirectory)\macos\powershell-lts-$(Version)-osx-${{ parameters.buildArchitecture }}.zip"
Compress-Archive -Path $ltsPkgPath -Destination $ltsZipFile
Write-Host $ltsZipFile
}
Expand All @@ -69,7 +69,7 @@ jobs:
- template: upload-final-results.yml
parameters:
artifactPath: $(System.ArtifactsDirectory)\macosPkgResults
artifactFilter: "*.tar.gz"
artifactFilter: "*${{ parameters.buildArchitecture }}.tar.gz"

- pwsh: |
$destination = "$(System.ArtifactsDirectory)\azureMacOs"
Expand Down
8 changes: 4 additions & 4 deletions tools/releaseBuild/azureDevOps/templates/mac.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
parameters:
jobName: 'build_macOS'
buildArchitecture: 'x64'

jobs:
- job: ${{ parameters.jobName }}
displayName: Build macOS
- job: build_macOS_${{ parameters.buildArchitecture }}
displayName: Build macOS ${{ parameters.buildArchitecture }}
condition: succeeded()
pool: Hosted Mac Internal
variables:
Expand Down Expand Up @@ -45,7 +45,7 @@ jobs:

- pwsh: |
$env:AzDevOpsFeedPAT2 = '$(AzDevOpsFeedPAT2)'
$(Build.SourcesDirectory)/tools/releaseBuild/macOS/PowerShellPackageVsts.ps1 -ReleaseTag $(ReleaseTagVar) -Destination $(System.ArtifactsDirectory) -Symbols -location $(PowerShellRoot) -Build -ArtifactName macosBinResults
$(Build.SourcesDirectory)/tools/releaseBuild/macOS/PowerShellPackageVsts.ps1 -ReleaseTag $(ReleaseTagVar) -Destination $(System.ArtifactsDirectory) -Symbols -location $(PowerShellRoot) -Build -ArtifactName macosBinResults -Runtime 'osx-${{ parameters.buildArchitecture }}'
$env:AzDevOpsFeedPAT2 = $null
displayName: 'Build'

Expand Down
Loading