9494 path : newm-admin/${{ steps.package.outputs.PKG_PATH }}
9595
9696 package-macos :
97- name : Package macOS DMG
97+ name : Package macOS DMG (Universal)
9898 needs : build
9999 runs-on : macos-latest
100100
@@ -110,6 +110,7 @@ jobs:
110110 uses : dtolnay/rust-toolchain@stable
111111 with :
112112 toolchain : stable
113+ targets : aarch64-apple-darwin,x86_64-apple-darwin
113114
114115 - name : Setup Rust cache
115116 uses : Swatinem/rust-cache@v2
@@ -119,26 +120,93 @@ jobs:
119120 - name : Install create-dmg
120121 run : brew install create-dmg
121122
122- - name : Build Release
123+ - name : Build ARM64 (Apple Silicon)
123124 run : cargo build --release --target aarch64-apple-darwin --locked
124125
126+ - name : Build x86_64 (Intel)
127+ run : cargo build --release --target x86_64-apple-darwin --locked
128+
125129 - name : Get version
126130 id : version
127131 run : |
128132 VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)
129133 echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
130134
131- - name : Create DMG
135+ - name : Import Code Signing Certificate
136+ env :
137+ MACOS_CERTIFICATE : ${{ secrets.MACOS_CERTIFICATE }}
138+ MACOS_CERTIFICATE_PWD : ${{ secrets.MACOS_CERTIFICATE_PWD }}
139+ KEYCHAIN_PASSWORD : ${{ secrets.KEYCHAIN_PASSWORD }}
140+ run : |
141+ # Create a temporary keychain
142+ security create-keychain -p "$KEYCHAIN_PASSWORD" build.keychain
143+ security default-keychain -s build.keychain
144+ security unlock-keychain -p "$KEYCHAIN_PASSWORD" build.keychain
145+ security set-keychain-settings -t 3600 -u build.keychain
146+
147+ # Decode certificate
148+ echo "$MACOS_CERTIFICATE" | base64 --decode > certificate.p12
149+
150+ # Debug: Check file size (should be ~4300 bytes based on 5760 base64 chars)
151+ echo "Certificate file size:"
152+ ls -la certificate.p12
153+
154+ # Debug: Verify the p12 file is valid with openssl first
155+ echo "Verifying p12 with openssl..."
156+ openssl pkcs12 -in certificate.p12 -nokeys -passin pass:"$MACOS_CERTIFICATE_PWD" -legacy 2>&1 || {
157+ echo "OpenSSL verification failed. Trying without -legacy flag..."
158+ openssl pkcs12 -in certificate.p12 -nokeys -passin pass:"$MACOS_CERTIFICATE_PWD" 2>&1 || {
159+ echo "ERROR: p12 file appears invalid or password is wrong"
160+ echo "Password length: ${#MACOS_CERTIFICATE_PWD}"
161+ exit 1
162+ }
163+ }
164+
165+ # Import certificate
166+ security import certificate.p12 -k build.keychain -P "$MACOS_CERTIFICATE_PWD" -T /usr/bin/codesign -T /usr/bin/security
167+ security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KEYCHAIN_PASSWORD" build.keychain
168+
169+ # Verify certificate was imported
170+ security find-identity -v -p codesigning build.keychain
171+
172+ # Clean up certificate file
173+ rm certificate.p12
174+
175+ - name : Create Universal App Bundle and DMG
176+ env :
177+ MACOS_SIGNING_IDENTITY : ${{ secrets.MACOS_SIGNING_IDENTITY }}
132178 run : |
133179 chmod +x packaging/macos/bundle.sh
134180 packaging/macos/bundle.sh ${{ steps.version.outputs.VERSION }} aarch64-apple-darwin
135181
182+ - name : Notarize App
183+ env :
184+ APPLE_ID : ${{ secrets.APPLE_ID }}
185+ APPLE_APP_PASSWORD : ${{ secrets.APPLE_APP_PASSWORD }}
186+ APPLE_TEAM_ID : ${{ secrets.APPLE_TEAM_ID }}
187+ run : |
188+ DMG_PATH="target/aarch64-apple-darwin/release/NEWM-Admin-${{ steps.version.outputs.VERSION }}-macos.dmg"
189+
190+ echo "Submitting DMG for notarization..."
191+ xcrun notarytool submit "$DMG_PATH" \
192+ --apple-id "$APPLE_ID" \
193+ --password "$APPLE_APP_PASSWORD" \
194+ --team-id "$APPLE_TEAM_ID" \
195+ --wait
196+
197+ echo "Stapling notarization ticket to DMG..."
198+ xcrun stapler staple "$DMG_PATH"
199+
200+ echo "Verifying notarization..."
201+ xcrun stapler validate "$DMG_PATH"
202+
136203 - name : Upload DMG
137204 uses : actions/upload-artifact@v4
138205 with :
139206 name : NEWM-Admin-${{ steps.version.outputs.VERSION }}-macos.dmg
140207 path : newm-admin/target/aarch64-apple-darwin/release/NEWM-Admin-${{ steps.version.outputs.VERSION }}-macos.dmg
141208
209+
142210 package-linux :
143211 name : Package Linux AppImage
144212 needs : build
0 commit comments