-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use self-signed openemv.org code signing certificate for MacOS
This requires Github Actions to provide these secrets: * OPENEMV_MACOS_CERT_BASE64 * OPENEMV_MACOS_CERT_PWD * KEYCHAIN_PASSWORD A new keychain is created, unlocked, and used to import the code signing certificate. The keychain ACLs are also set to allow the codesign tool to use this keychain without user interaction. The keychain is explicitly cleaned up by the Github Actions workflow. The above functionality is encapsulated in scripts to allow easy reuse but also to avoid the various secrets that are used directly on the command line from appearing in the Github Actions log.
- Loading branch information
Showing
4 changed files
with
89 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
# This script implements the cleanup recommended by: | ||
# https://docs.github.com/en/actions/deployment/deploying-xcode-applications/installing-an-apple-certificate-on-macos-runners-for-xcode-development | ||
|
||
# Remove temporary keychain | ||
security delete-keychain $RUNNER_TEMP/app-signing.keychain-db | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/bin/bash | ||
|
||
# This script is inspired by these guides: | ||
# - https://docs.github.com/en/actions/deployment/deploying-xcode-applications/installing-an-apple-certificate-on-macos-runners-for-xcode-development | ||
# - https://localazy.com/blog/how-to-automatically-sign-macos-apps-using-github-actions | ||
# - https://federicoterzi.com/blog/automatic-code-signing-and-notarization-for-macos-apps-using-github-actions/ | ||
# - https://github.com/lando/code-sign-action/ | ||
|
||
# This script assumes that these environment variables are provided: | ||
# - RUNNER_TEMP (temporary directory provided by Github Actions runner) | ||
# - OPENEMV_MACOS_CERT_BASE64 | ||
# - OPENEMV_MACOS_CERT_PWD | ||
# - KEYCHAIN_PASSWORD | ||
|
||
# Temporary paths | ||
OPENEMV_MACOS_CERT_PATH=$RUNNER_TEMP/certificate.p12 | ||
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db | ||
|
||
# Create temporary keychain | ||
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH | ||
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH | ||
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH | ||
|
||
# Decode and import signing certificate | ||
echo -n "$OPENEMV_MACOS_CERT_BASE64" | base64 --decode > $OPENEMV_MACOS_CERT_PATH | ||
security import $OPENEMV_MACOS_CERT_PATH -P "$OPENEMV_MACOS_CERT_PWD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH | ||
security list-keychains -d user -s $KEYCHAIN_PATH | ||
security find-identity -v -p codesigning | ||
|
||
# Allow codesign application to use signing key | ||
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH | ||
|
||
# Cleanup | ||
rm $OPENEMV_MACOS_CERT_PATH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters