Skip to content

Commit b4e4115

Browse files
committed
CI: Code sign macOS bundle with PyInstaller
Replace custom code signing tool with PyInstaller functionality. Also always run notarization, as older macOS versions are no longer supported.
1 parent 8562aa9 commit b4e4115

File tree

2 files changed

+27
-46
lines changed

2 files changed

+27
-46
lines changed

picard.spec

+4-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,10 @@ else:
113113
upx=False,
114114
icon='picard.ico',
115115
version='win-version-info.txt',
116-
console=False)
116+
console=False,
117+
# macOS code signing
118+
codesign_identity=os.environ.get('CODESIGN_IDENTITY', None),
119+
entitlements_file='./scripts/package/entitlements.plist')
117120

118121

119122
coll = COLLECT(exe,

scripts/package/macos-package-app.sh

+23-45
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,13 @@ MACOS_VERSION_MAJOR=${MACOS_VERSION_MAJOR%.*}
99
MACOS_VERSION_MINOR=${MACOS_VERSION#*.}
1010
MACOS_VERSION_MINOR=${MACOS_VERSION_MINOR%.*}
1111

12-
echo "Building Picard..."
13-
rm -rf dist build locale
14-
python3 setup.py clean
15-
python3 setup.py build --disable-locales
16-
python3 setup.py build_locales
17-
python3 setup.py build_ext -i
18-
pyinstaller --noconfirm --clean picard.spec
12+
APP_BUNDLE="MusicBrainz Picard.app"
1913

2014
CODESIGN=0
2115
NOTARIZE=0
2216
KEYCHAIN_PATH=picard.keychain
2317
KEYCHAIN_PASSWORD=$(openssl rand -base64 32)
24-
CERTIFICATE_NAME="MetaBrainz Foundation Inc."
18+
CODESIGN_IDENTITY="MetaBrainz Foundation Inc."
2519
CERTIFICATE_FILE=scripts/package/appledev.p12
2620

2721
if [ -f "$CERTIFICATE_FILE" ] && [ -n "$CODESIGN_MACOS_P12_PASSWORD" ]; then
@@ -37,50 +31,34 @@ if [ -f "$CERTIFICATE_FILE" ] && [ -n "$CODESIGN_MACOS_P12_PASSWORD" ]; then
3731
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH"
3832
security find-identity -p codesigning # For debugging
3933
CODESIGN=1
34+
export CODESIGN_IDENTITY
4035
fi
4136

42-
# Submit app for notarization on macOS >= 10.14
43-
if { [ "$MACOS_VERSION_MAJOR" -eq 10 ] && [ "$MACOS_VERSION_MINOR" -ge 14 ]; } || [ "$MACOS_VERSION_MAJOR" -ge 11 ]; then
44-
NOTARIZE=1
45-
fi
37+
echo "Building Picard..."
38+
rm -rf dist build locale
39+
python3 setup.py clean
40+
python3 setup.py build --disable-locales
41+
python3 setup.py build_locales
42+
python3 setup.py build_ext -i
43+
pyinstaller --noconfirm --clean picard.spec
4644

4745
cd dist
4846

49-
echo "Create and sign app bundle..."
50-
APP_BUNDLE="MusicBrainz Picard.app"
51-
5247
if [ "$CODESIGN" = '1' ]; then
53-
echo "Code signing app bundle ${APP_BUNDLE}..."
54-
if [ "$NOTARIZE" = "1" ]; then
55-
# Enable hardened runtime if app will get notarized
56-
codesign --verbose --deep --force \
57-
--options runtime \
58-
--entitlements ../scripts/package/entitlements.plist \
59-
--keychain "$KEYCHAIN_PATH" --sign "$CERTIFICATE_NAME" \
60-
"$APP_BUNDLE"
61-
../scripts/package/macos-notarize-app.sh "$APP_BUNDLE"
62-
echo "Verifying signature and notarization for app bundle ${APP_BUNDLE}..."
63-
codesign --verify --verbose --deep --strict=symlinks --check-notarization "$APP_BUNDLE"
64-
else
65-
codesign --verbose --deep --force \
66-
--keychain "$KEYCHAIN_PATH" --sign "$CERTIFICATE_NAME" \
67-
"$APP_BUNDLE"
68-
echo "Verifying signature for app bundle ${APP_BUNDLE}..."
69-
codesign --verify --verbose --deep --strict=all "$APP_BUNDLE"
70-
fi
48+
../scripts/package/macos-notarize-app.sh "$APP_BUNDLE"
49+
echo "Verifying signature and notarization for app bundle ${APP_BUNDLE}..."
50+
codesign --verify --verbose --deep --strict=symlinks --check-notarization "$APP_BUNDLE"
7151
fi
7252

73-
# Only test the app if it was codesigned, otherwise execution likely fails
74-
if [ "$CODESIGN" = '1' ]; then
75-
"$APP_BUNDLE/Contents/MacOS/picard-run" --long-version --no-crash-dialog || echo "Failed running picard-run"
76-
VERSIONS=$("$APP_BUNDLE/Contents/MacOS/picard-run" --long-version --no-crash-dialog)
77-
echo "$VERSIONS"
78-
ASTRCMP_REGEX="astrcmp C"
79-
[[ $VERSIONS =~ $ASTRCMP_REGEX ]] || (echo "Failed: Build does not include astrcmp C" && false)
80-
LIBDISCID_REGEX="libdiscid [0-9]+\.[0-9]+\.[0-9]+"
81-
[[ $VERSIONS =~ $LIBDISCID_REGEX ]] || (echo "Failed: Build does not include libdiscid" && false)
82-
"$APP_BUNDLE/Contents/Frameworks/fpcalc" -version
83-
fi
53+
echo "Testing executables..."
54+
"$APP_BUNDLE/Contents/MacOS/picard-run" --long-version --no-crash-dialog || echo "Failed running picard-run"
55+
VERSIONS=$("$APP_BUNDLE/Contents/MacOS/picard-run" --long-version --no-crash-dialog)
56+
echo "$VERSIONS"
57+
ASTRCMP_REGEX="astrcmp C"
58+
[[ $VERSIONS =~ $ASTRCMP_REGEX ]] || (echo "Failed: Build does not include astrcmp C" && false)
59+
LIBDISCID_REGEX="libdiscid [0-9]+\.[0-9]+\.[0-9]+"
60+
[[ $VERSIONS =~ $LIBDISCID_REGEX ]] || (echo "Failed: Build does not include libdiscid" && false)
61+
"$APP_BUNDLE/Contents/Frameworks/fpcalc" -version
8462

8563
echo "Package app bundle into DMG image..."
8664
DMG="MusicBrainz-Picard${VERSION:+-$VERSION}${MACOSX_DEPLOYMENT_TARGET:+-macOS-$MACOSX_DEPLOYMENT_TARGET}${TARGET_ARCH:+-$TARGET_ARCH}.dmg"
@@ -108,7 +86,7 @@ fi
10886
set -e
10987

11088
[ "$CODESIGN" = '1' ] && codesign --verify --verbose \
111-
--keychain "$KEYCHAIN_PATH" --sign "$CERTIFICATE_NAME" "$DMG"
89+
--keychain "$KEYCHAIN_PATH" --sign "$CODESIGN_IDENTITY" "$DMG"
11290
md5 -r "$DMG"
11391

11492
if [ -n "$MACOS_UPLOAD" ]; then

0 commit comments

Comments
 (0)