-
Notifications
You must be signed in to change notification settings - Fork 452
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add signing script for macos build separately
Fix signing dmg Add spctl assement at the end of macos signing to check notarization
- Loading branch information
Showing
4 changed files
with
119 additions
and
37 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env bash | ||
set -x # print all commands | ||
set -e # exit when any command fails | ||
|
||
export APPNAME=Tribler | ||
export LOG_LEVEL=${LOG_LEVEL:-"DEBUG"} | ||
export BUILD_ENV=${BUILD_ENV:-"venv"} | ||
|
||
PRE_BUILD_INSTRUCTIONS=$(cat <<-END | ||
git describe --tags | python -c "import sys; print(next(sys.stdin).lstrip('v'))" > .TriblerVersion | ||
git rev-parse HEAD > .TriblerCommit | ||
export TRIBLER_VERSION=\$(head -n 1 .TriblerVersion) | ||
python3 ./build/update_version.py -r . | ||
END | ||
) | ||
|
||
if [ ! -f .TriblerVersion ]; then | ||
echo "No .TriblerVersion file found, run the following commands:" | ||
echo "$PRE_BUILD_INSTRUCTIONS" | ||
exit 1 | ||
fi | ||
|
||
if [ -e .TriblerVersion ]; then | ||
export DMGNAME="Tribler-$(cat .TriblerVersion)" | ||
fi | ||
|
||
# Directories | ||
export DIST_DIR=dist | ||
export INSTALL_DIR=$DIST_DIR/installdir | ||
export TEMP_DIR=$DIST_DIR/temp | ||
export RESOURCES_DIR=build/mac/resources | ||
|
||
# Environment variables related to signing | ||
export CODE_SIGN_ENABLED=${CODE_SIGN_ENABLED:-""} | ||
export APPLE_DEV_ID=${APPLE_DEV_ID:-""} |
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,26 @@ | ||
#!/bin/bash | ||
set -x # print all commands | ||
set -e # exit when any command fails | ||
|
||
source ./build/mac/env.sh | ||
|
||
# App file to sign | ||
APP_FILE=$INSTALL_DIR/$APPNAME.app | ||
if [ -z "$APP_FILE" ]; then | ||
echo "$APP_FILE file not found" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$CODE_SIGN_ENABLED" ]; then | ||
echo "Code sign is not enabled. Skipping code signing the app $APP_FILE." | ||
exit 0 | ||
fi | ||
|
||
if [ -z "$APPLE_DEV_ID" ]; then | ||
echo "Code sign is enabled but Apple Dev ID is not set. Exiting with failure" | ||
exit 1 | ||
fi | ||
|
||
echo "Signing $APP_FILE with Apple Dev ID: $APPLE_DEV_ID" | ||
SIGN_MSG="Developer ID Application: $APPLE_DEV_ID" | ||
codesign --deep --force --verbose --sign "$SIGN_MSG" --options runtime $APP_FILE |
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,36 @@ | ||
#!/bin/bash | ||
set -x # print all commands | ||
set -e # exit when any command fails | ||
|
||
source ./build/mac/env.sh | ||
|
||
DMG_FILE=$DIST_DIR/$DMGNAME.dmg | ||
if [ -z "$DMG_FILE" ]; then | ||
echo "$DMG_FILE file not found" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$CODE_SIGN_ENABLED" ]; then | ||
echo "Code sign is not enabled. Skipping code signing the installer $DMG_FILE." | ||
exit 0 | ||
fi | ||
|
||
if [ -z "$APPLE_DEV_ID" ]; then | ||
echo "Code sign is enabled but Apple Dev ID is not set. Exiting with failure" | ||
exit 1 | ||
fi | ||
|
||
# Sign the dmg package and verify it | ||
SIGN_MSG="Developer ID Application: $APPLE_DEV_ID" | ||
codesign --force --verify --verbose --sign "$SIGN_MSG" $DMG_FILE | ||
codesign --verify --verbose=4 $DMG_FILE | ||
|
||
# Assuming the keychain profile with the signing key is created and named as "tribler-codesign-profile". | ||
# If not create the keychain profile with the following command: | ||
# xcrun notarytool store-credentials "tribler-codesign-profile" --apple-id "<dev-id-email>" --team-id "<dev-id-team>" | ||
KEYCHAIN_PROFILE=${KEYCHAIN_PROFILE:-"tribler-codesign-profile"} | ||
# Submit the DMG for notarization and staple afterwards | ||
xcrun notarytool submit $DMG_FILE --keychain-profile "$KEYCHAIN_PROFILE" --wait | ||
xcrun stapler staple $DMG_FILE | ||
# Verify the notarization | ||
spctl --assess --type open --context context:primary-signature -v $DMG_FILE |