Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions EsrpSign.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ steps:
pattern: ${{ parameters.pattern }}
certificateId: ${{ parameters.certificateId }}

- ${{ if eq(parameters.certificateId, 'CP-401337-Apple') }}:
- template: template-compliance/macOS-sign.yml
parameters:
signOutputPath: ${{ parameters.signOutputPath }}
pattern: ${{ parameters.pattern }}
certificateId: ${{ parameters.certificateId }}

- pwsh: |
Write-Verbose -Verbose "EsrpJson = '${env:EsrpJson}'"
displayName: Log Json
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,22 @@ This example signs `dll` `psd1` and `psm1` files recursively, using minimatch.
useMinimatch: true
```

### ESRP macOS example

This example signs `pkg` files recursively, using minimatch.

```yaml
- template: EsrpSign.yml@ComplianceRepo
parameters:
buildOutputPath: $(signSrcPath)
signOutputPath: $(signOutPath)
# this is the cert for macOS signing
certificateId: "CP-401337-Apple"
# this is the pattern for pkg signing
pattern: |
**\*.pkg
useMinimatch: true
```
## ESRP Malware Scanning Template Overview

** Requires on-boarding, see the wiki in the internal PowerShell Maintainers teams channel **
Expand Down
35 changes: 35 additions & 0 deletions template-compliance/macOS-sign.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
parameters:
- name: "signOutputPath"
default: "$(Build.ArtifactStagingDirectory)\\signed"
- name: "pattern"
default: "*.pkg"
- name: "certificateId"
default: "CP-401337-Apple"

steps:

- pwsh: |
[string] $CertificateId = "${{ parameters.certificateId }}"
Write-Verbose "CertificateId - $CertificateId" -Verbose

[string] $VariableName = "EsrpJson"

[string] $SigningServer = '$(SigningServer)'
Write-Verbose "SigningServer - $SigningServer" -Verbose

[hashtable[]] $esrp = @(@{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strictly speaking, the @( is no longer needed unless there are multiple hashtables, and then a comma between hashtables should suffice.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was never needed but testing this takes a LONG time. I'll file an issue.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filed an Issue:
#21 (review)

keyCode = $CertificateId
operationSetCode = "MacAppDeveloperSign"
toolName = "sign"
toolVersion = "1.0"
})

$vstsCommandString = "vso[task.setvariable variable=$VariableName][$($esrp | ConvertTo-Json -Compress)]"
Write-Verbose -Message ("sending " + $vstsCommandString) -Verbose
Write-Host "##$vstsCommandString"

$vstsCommandString = "vso[task.setvariable variable=GDN_CODESIGN_TARGETDIRECTORY]${{ parameters.signOutputPath }}"
Write-Verbose -Message ("sending " + $vstsCommandString) -Verbose
Write-Host "##$vstsCommandString"
displayName: Generate PGP signing JSON
condition: and(and(and(succeeded(), eq(variables['Build.Reason'], 'Manual')), ne(variables['SkipSigning'], 'True')), ne(variables['SigningServer'], ''))