Skip to content

Commit

Permalink
MacOS Notarization
Browse files Browse the repository at this point in the history
Notarizes the MacOS build of the desktop app for distribution on MacOS 10.15 and later.

Fixes #2182
  • Loading branch information
dpwatrous authored and gingi committed Jun 13, 2023
1 parent 52c7888 commit 3e857d6
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 15 deletions.
26 changes: 23 additions & 3 deletions .vsts/darwin/distribution.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,23 @@ steps:
displayName: Build packages
- script: |
set -e
dir=$(Agent.TempDirectory)
keychain=$dir/buildagent.keychain
security create-keychain -p pwd $keychain
security default-keychain -s $keychain
security unlock-keychain -p pwd $keychain
echo "$(apple-developer-certificate)" | base64 -D > $dir/cert.p12
security import $dir/cert.p12 -k $keychain -P "$(apple-developer-certificate-key)" -T /usr/bin/codesign
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k pwd $keychain
echo "##vso[task.setvariable variable=CSC_LINK]$dir/cert.p12
echo "##vso[task.setvariable variable=CSC_KEY_PASSWORD]$(apple-developer-certificate-key)
displayName: Prepare Apple Developer certificate
- script: |
set -e
. "$(Agent.WorkFolder)/.venv/batchexplorer/bin/activate"
npm run build-python
npm run package darwin-app
cd ./release/mac
Expand All @@ -25,24 +42,27 @@ steps:
workingDirectory: desktop
displayName: Build .app
- template: ./sign.yml
- script: |
set -e
. "$(Agent.WorkFolder)/.venv/batchexplorer/bin/activate"
unzip ./release/BatchExplorer*.zip -d ./release/mac
ls ./release/mac
rm -f ./release/mac/*.pkg
# rm -rf ./release/*.zip
mv ./release/*.zip ./release/code-sign-results.zip
npm run package darwin-dmg
rm -rf ./release/mac/*
workingDirectory: desktop
displayName: Build dmg
- template: ./sign.yml

- template: ./notarize.yml

- script: npm run package darwin-manifest
workingDirectory: desktop
displayName: Create manifest

- template: ../common/generate-sbom.yml

- template: ../common/publish-artifacts.yml
parameters:
folder: darwin
12 changes: 12 additions & 0 deletions .vsts/darwin/entitlements.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
</dict>
</plist>
21 changes: 21 additions & 0 deletions .vsts/darwin/notarize.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
steps:
- task: EsrpCodeSigning@2
inputs:
ConnectedServiceName: 'ESRP CodeSign'
FolderPath: ./desktop/release
Pattern: 'BatchExplorer-mac.zip,*.dmg'
signConfigType: inlineSignParams
inlineOperation: |
[
{
"KeyCode" : "CP-401337-Apple",
"OperationCode" : "MacAppNotarize",
"Parameters" : {
"BundleId": "com.microsoft.azure.BatchExplorer"
},
"ToolName" : "sign",
"ToolVersion" : "1.0"
}
]
SessionTimeout: 120
displayName: Notarization
16 changes: 6 additions & 10 deletions .vsts/darwin/sign.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
steps:
- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
inputs:
packageType: sdk
version: 2.1.x

- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1
- task: EsrpCodeSigning@2
inputs:
ConnectedServiceName: 'ESRP CodeSign'
FolderPath: ./desktop/release
Pattern: 'BatchExplorer-mac.zip'
Pattern: 'BatchExplorer-mac.zip,*.dmg'
signConfigType: inlineSignParams
inlineOperation: |
[
{
"keyCode": "CP-401337-Apple",
"operationSetCode": "MacAppDeveloperSign",
"parameters": [ ],
"operationCode": "MacAppDeveloperSign",
"parameters": {
"Hardening": "--options=runtime"
},
"toolName": "sign",
"toolVersion": "1.0"
}
Expand Down
1 change: 1 addition & 0 deletions .vsts/distribution.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ stages:
vmImage: macOS-11
demands: xcode
variables:
- group: BatchExplorer-Signing
- name: EOCompliance-Mac
value: true
steps:
Expand Down
16 changes: 14 additions & 2 deletions desktop/electron-builder.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
productName: "BatchExplorer"
appId: "microsoft.azure.batch-explorer"
appId: "com.microsoft.azure.BatchExplorer"

# Package electron code into a asar archive. Set to false to debug issues.
# Package electron code into a asar archive, except for .node binaries
# (see https://github.com/electron-userland/electron-builder/issues/4656)
asar: true
asarUnpack: "**/*.node"

files:
- "build/"
Expand Down Expand Up @@ -31,6 +33,16 @@ protocols:
# Mac OS configuration
mac:
icon: "src/app/assets/images/icon.icns"
target:
- "dmg"
- "zip"
hardenedRuntime: true
gatekeeperAssess: false
entitlements: "../.vsts/darwin/entitlements.plist"
entitlementsInherit: "../.vsts/darwin/entitlements.plist"
extendInfo:
# Required for hardening via ESRP
- CSFlags: 65536

# Config for OSX dmg
dmg:
Expand Down

0 comments on commit 3e857d6

Please sign in to comment.