Skip to content

Commit 21cbf4b

Browse files
committed
chore: macos code signing
1 parent 67a5c58 commit 21cbf4b

File tree

3 files changed

+57
-1
lines changed

3 files changed

+57
-1
lines changed

.github/workflows/macos.yaml

+31
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ jobs:
1111
runs-on: macos-11
1212

1313
strategy:
14+
fail-fast: false
1415
matrix:
1516
arch: [arm64, x86_64]
1617

@@ -26,13 +27,43 @@ jobs:
2627
tools: 'tools_ifw tools_cmake'
2728
modules: 'qtwebsockets qt5compat'
2829

30+
- name: Install the Apple certificate and provisioning profile
31+
env:
32+
APPLE_CERTIFICATE_BASE64: ${{ secrets.APPLE_CERTIFICATE_BASE64 }}
33+
APPLE_P12_PASSWORD: ${{ secrets.APPLE_P12_PASSWORD }}
34+
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
35+
run: |
36+
if [[ -n "$APPLE_CERTIFICATE_BASE64" ]]; then
37+
# create variables
38+
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
39+
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
40+
41+
# import certificate and provisioning profile from secrets
42+
echo -n "$APPLE_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH
43+
44+
# create temporary keychain
45+
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
46+
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
47+
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
48+
49+
# import certificate to keychain
50+
security import $CERTIFICATE_PATH -P "$APPLE_P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
51+
security list-keychain -d user -s $KEYCHAIN_PATH
52+
53+
# list signing identities
54+
# security find-identity -v -p codesigning
55+
fi
2956
- name: Run build
3057
run: |
3158
./tools/build-macos.sh ${{ matrix.arch }}
3259
env:
3360
CI: 1
3461
BUILD_QT_PATH: ${{ github.workspace }}/Qt/6.5.3/macos
3562
BUILD_PARALLEL_THREADS: 2
63+
MACOS_SIGN_NAME: ${{ secrets.MACOS_SIGN_NAME }}
64+
APPLEID: ${{ secrets.APPLEID }}
65+
APPLEIDPASS: ${{ secrets.APPLEIDPASS }}
66+
APPLEIDTEAM: ${{ secrets.APPLEIDTEAM }}
3667

3768
- name: Rename build
3869
id: "rename-build"

resources/macos/entitlements.plist

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
6+
<true/>
7+
<key>com.apple.security.cs.disable-library-validation</key>
8+
<true/>
9+
</dict>
10+
</plist>

tools/build-macos.sh

+16-1
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,27 @@ mkdir "$CLIENT_FOLDER" || fail "Could not create $CLIENT_FOLDER"
5151
# Copy app bundle
5252
mv staging/casparcg-client.app "$CLIENT_FOLDER/$CLIENT_FOLDER.app" || fail "Could not move app bundle"
5353

54+
# Sign app bundle
55+
if [ -n "$MACOS_SIGN_NAME" ]; then
56+
echo "Signing..."
57+
codesign --deep --timestamp --options runtime -s "$MACOS_SIGN_NAME" --entitlements "../resources/macos/entitlements.plist" "$CLIENT_FOLDER/$CLIENT_FOLDER.app"
58+
fi
59+
5460
# Copy documentation
5561
echo Copying documentation...
5662
cp -f ../CHANGELOG "$CLIENT_FOLDER/" || fail "Could not copy CHANGELOG"
5763
cp -f ../LICENSE "$CLIENT_FOLDER/" || fail "Could not copy LICENSE"
64+
ln -s /Applications "$CLIENT_FOLDER/"
5865

5966
# Create dmg file
6067
echo Creating dmg...
61-
hdiutil create -size "$BUILD_HDIUTILS_WORKAROUND_SIZE" -volname "$CLIENT_FOLDER" -srcfolder "$CLIENT_FOLDER" -ov -format UDZO "$BUILD_ARCHIVE_NAME-$ARCH.dmg" || fail "Could not create dmg"
68+
DMG_NAME="$BUILD_ARCHIVE_NAME-macos-$ARCH.dmg"
69+
hdiutil create -size "$BUILD_HDIUTILS_WORKAROUND_SIZE" -volname "$CLIENT_FOLDER" -srcfolder "$CLIENT_FOLDER" -ov -format UDZO "$DMG_NAME" || fail "Could not create dmg"
70+
71+
# notarize dmg
72+
if [ -n "$APPLEID" ]; then
73+
echo "Notarizing..."
74+
xcrun notarytool submit "$DMG_NAME" --wait --apple-id "$APPLEID" --password "$APPLEIDPASS" --team-id "$APPLEIDTEAM"
75+
xcrun stapler staple "$DMG_NAME"
76+
fi
6277

0 commit comments

Comments
 (0)