2626 CARGO_PROFILE_RELEASE_CODEGEN_UNITS : " 1"
2727 CARGO_PROFILE_RELEASE_STRIP : " true"
2828 run : cargo build --release
29-
29+
30+ - name : Import Apple Certificate
31+ if : ${{ secrets.MACOS_CERTIFICATE != '' }}
32+ env :
33+ BUILD_CERTIFICATE_BASE64 : ${{ secrets.MACOS_CERTIFICATE }}
34+ P12_PASSWORD : ${{ secrets.MACOS_CERTIFICATE_PWD }}
35+ run : |
36+ CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
37+ KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
38+ KEYCHAIN_PASSWORD=$(openssl rand -base64 12)
39+
40+ echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH
41+
42+ security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
43+ security default-keychain -s $KEYCHAIN_PATH
44+ security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
45+
46+ security import $CERTIFICATE_PATH -k $KEYCHAIN_PATH -P "$P12_PASSWORD" -T /usr/bin/codesign -T /usr/bin/productsign
47+ security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
48+
3049 - name : Package Application
3150 run : |
3251 VERSION=$(grep -m1 '^version =' Cargo.toml | cut -d '"' -f2)
@@ -87,8 +106,16 @@ jobs:
87106 cp assets/soundfont.sf2 RustTracker.app/Contents/Resources/
88107 dylibbundler -od -b -x RustTracker.app/Contents/MacOS/rusttracker -d RustTracker.app/Contents/Frameworks/ -p @executable_path/../Frameworks/
89108
90- # Ad-hoc codesign the entire bundle recursively to satisfy security requirements (especially Apple Silicon)
91- codesign --force --deep --sign - RustTracker.app
109+ # Codesign the application
110+ if [ -n "${{ secrets.MACOS_CERTIFICATE }}" ]; then
111+ echo "Signing with Developer ID Certificate..."
112+ find RustTracker.app/Contents/Frameworks -type f \( -name "*.dylib" -or -name "*.so" \) -exec codesign --force --options runtime --sign "Developer ID Application" {} \;
113+ codesign --force --options runtime --entitlements entitlements.plist --sign "Developer ID Application" RustTracker.app/Contents/MacOS/rusttracker
114+ codesign --force --options runtime --entitlements entitlements.plist --sign "Developer ID Application" RustTracker.app
115+ else
116+ echo "No Developer ID Certificate found. Performing ad-hoc signing..."
117+ codesign --force --deep --sign - RustTracker.app
118+ fi
92119
93120 - name : Create DMG
94121 run : |
@@ -101,6 +128,31 @@ jobs:
101128 --app-drop-link 400 190 \
102129 "RustTracker-MacOS-Installer.dmg" \
103130 "RustTracker.app"
131+
132+ - name : Notarize DMG
133+ if : ${{ secrets.APPLE_ID != '' }}
134+ env :
135+ APPLE_ID : ${{ secrets.APPLE_ID }}
136+ APPLE_ID_PASSWORD : ${{ secrets.APPLE_ID_PASSWORD }}
137+ APPLE_TEAM_ID : ${{ secrets.APPLE_TEAM_ID }}
138+ run : |
139+ echo "Submitting DMG for notarization..."
140+ xcrun notarytool submit RustTracker-MacOS-Installer.dmg \
141+ --apple-id "$APPLE_ID" \
142+ --password "$APPLE_ID_PASSWORD" \
143+ --team-id "$APPLE_TEAM_ID" \
144+ --wait
145+
146+ echo "Stapling notarization ticket to DMG..."
147+ xcrun stapler staple RustTracker-MacOS-Installer.dmg
148+
149+ - name : Clean up Keychain
150+ if : always() && secrets.MACOS_CERTIFICATE != ''
151+ run : |
152+ KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
153+ if [ -f "$KEYCHAIN_PATH" ]; then
154+ security delete-keychain $KEYCHAIN_PATH
155+ fi
104156
105157 - name : Upload Artifact
106158 uses : actions/upload-artifact@v5
0 commit comments