2222 - name : skipNugetSecurityAnalysis
2323 value : true
2424 - group : DotNetPrivateBuildAccess
25+ - group : certificate_logical_to_actual
2526 - name : ob_outputDirectory
2627 value : ' $(Build.ArtifactStagingDirectory)/ONEBRANCH_ARTIFACT'
2728 - name : ob_sdl_binskim_enabled
7677 # Diagnostics is not critical it passes every time it runs
7778 continueOnError: true
7879
80+ - pwsh : |
81+ $signedDir = "$(Pipeline.Workspace)/CoOrdinatedBuildPipeline/drop_macos_sign_${{ parameters.buildArchitecture }}/Signed-${{ parameters.buildArchitecture }}"
82+ Get-ChildItem $signedDir -Recurse -Include 'pwsh', '*.dylib' | ForEach-Object {
83+ codesign --verify --deep --strict --verbose=4 $_.FullName
84+ if ($LASTEXITCODE -ne 0) { throw "codesign verification failed for $($_.FullName)" }
85+ }
86+ displayName: 'Verify Apple codesign on signed binaries'
87+
7988 - pwsh : |
8089 # Add -SkipReleaseChecks as a mitigation to unblock release.
8190 # macos-10.15 does not allow creating a folder under root. Hence, moving the folder.
@@ -154,11 +163,20 @@ jobs:
154163
155164 foreach($t in $tarPkgPath) {
156165 $file = $t.FullName
166+ $entry = & tar -tzvf $file | Where-Object { $_ -match '\spwsh$' } | Select-Object -First 1
167+ if ($entry -notmatch '^-..x') {
168+ throw "pwsh is not executable in $file : $entry"
169+ }
157170 Write-Verbose -verbose "Uploading $file to macos-pkgs"
158171 Write-Host "##vso[artifact.upload containerfolder=macos-pkgs;artifactname=macos-pkgs]$file"
159172 }
160173
174+ $packageInfo = Get-MacOSPackageIdentifierInfo -Version '$(Version)' -LTS:$LTS
175+ Write-Verbose -Verbose "BundleId: $($packageInfo.PackageIdentifier)"
176+ Write-Host "##vso[task.setvariable variable=BundleId;isOutput=true]$($packageInfo.PackageIdentifier)"
177+
161178 displayName: 'Package ${{ parameters.buildArchitecture}}'
179+ name: packageStep
162180 env:
163181 __DOTNET_RUNTIME_FEED_KEY: $(RUNTIME_SOURCEFEED_KEY)
164182
@@ -170,6 +188,7 @@ jobs:
170188 type : windows
171189
172190 variables :
191+ - group : certificate_logical_to_actual
173192 - name : ob_outputDirectory
174193 value : ' $(Build.ArtifactStagingDirectory)/ONEBRANCH_ARTIFACT'
175194 - name : ob_sdl_binskim_enabled
@@ -178,7 +197,8 @@ jobs:
178197 value : $(Build.SourcesDirectory)/PowerShell/.config/suppress.json
179198 - name : BuildArch
180199 value : ${{ parameters.buildArchitecture }}
181- - group : mscodehub-macos-package-signing
200+ - name : BundleId
201+ value : $[ dependencies.package_macOS_${{ parameters.buildArchitecture }}.outputs['packageStep.BundleId'] ]
182202
183203 steps :
184204 - download : current
@@ -216,32 +236,59 @@ jobs:
216236 inline_operation : |
217237 [
218238 {
219- "KeyCode": "$(KeyCode )",
239+ "KeyCode": "$(apple_cert_id )",
220240 "OperationCode": "MacAppDeveloperSign",
221241 "ToolName": "sign",
222242 "ToolVersion": "1.0",
223243 "Parameters": {
224- "Hardening": "Enable",
225- "OpusInfo": "http://microsoft.com"
244+ "Hardening": "--options=runtime"
245+ }
246+ }
247+ ]
248+
249+ - task : onebranch.pipeline.signing@1
250+ displayName : ' OneBranch Notarize Package'
251+ inputs :
252+ command : ' sign'
253+ files_to_sign : ' **/*-osx-*.zip'
254+ search_root : ' $(Pipeline.Workspace)'
255+ inline_operation : |
256+ [
257+ {
258+ "KeyCode": "$(apple_cert_id)",
259+ "OperationCode": "MacAppNotarize",
260+ "ToolName": "sign",
261+ "ToolVersion": "1.0",
262+ "Parameters": {
263+ "BundleId": "$(BundleId)"
226264 }
227265 }
228266 ]
267+ timeoutInMinutes : 120
229268
230269 - pwsh : |
231270 $signedPkg = Get-ChildItem -Path $(Pipeline.Workspace) -Filter "*osx*.zip" -File
232271
272+ if (-not (Test-Path $(ob_outputDirectory))) {
273+ $null = New-Item -Path $(ob_outputDirectory) -ItemType Directory
274+ }
275+
276+ $expandDir = "$(Pipeline.Workspace)/pkgExpand"
277+ $null = New-Item -Path $expandDir -ItemType Directory -Force
278+
233279 $signedPkg | ForEach-Object {
234280 Write-Verbose -Verbose "Signed package zip: $_"
281+ Expand-Archive -Path $_ -DestinationPath $expandDir -Verbose
282+ }
235283
236- if (-not (Test-Path $_)) {
237- throw "Package not found: $_"
238- }
239-
240- if (-not (Test-Path $(ob_outputDirectory))) {
241- $null = New-Item -Path $(ob_outputDirectory) -ItemType Directory
242- }
284+ # ESRP's signing pipeline nests the PKG inside a '<hash>.zip.unzipped' subfolder
285+ $pkgFile = Get-ChildItem -Path $expandDir -Filter '*.pkg' -Recurse -File
286+ if (-not $pkgFile) {
287+ throw "Package not found in: $signedPkg"
288+ }
243289
244- Expand-Archive -Path $_ -DestinationPath $(ob_outputDirectory) -Verbose
290+ $pkgFile | ForEach-Object {
291+ Move-Item -Path $_ -Destination $(ob_outputDirectory) -Verbose
245292 }
246293
247294 Write-Verbose -Verbose "Expanded pkg file:"
0 commit comments