Compare commits

...

4 Commits

Author SHA1 Message Date
sanasol
153868fb87 fix(macos): improve notarization with timeout and graceful failure
Changes:
- Add 30 minute timeout for notarization (fail fast)
- Add SKIP_NOTARIZE=true env var to skip notarization entirely
- Don't fail build if notarization fails (app still code-signed)
- Add NOTARIZE_FAIL_ON_ERROR=true to fail build on notarization error
- Add forceCodeSigning, strictVerify, type=distribution to mac config
- Disable electron-builder built-in notarize (using custom script)

This prevents CI from hanging forever waiting for Apple's notarization
service and reduces wasted GitHub Actions minutes.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-01 03:00:47 +01:00
sanasol
743d7f2b7c fix(ci): use macos-latest for ARM64 builds 2026-01-31 20:02:07 +01:00
sanasol
759a7089c4 fix(ci): use macos-15-large for Intel x64 builds (macos-13 retired) 2026-01-31 20:00:13 +01:00
sanasol
0a5cc3f6d7 feat(ci): separate macOS arm64 and x64 builds with individual code signing
Changes:
- Split macOS build into two separate jobs: build-macos-arm64 and build-macos-x64
- ARM64 builds on macos-14 (M1 runner) for native Apple Silicon builds
- x64 builds on macos-13 (Intel runner) for native Intel builds
- Each build has its own code signing and notarization process
- Artifacts renamed with -arm64 and -x64 suffixes for clarity
- Separate release jobs for each architecture
- Updated package.json mac targets from "universal" to ["arm64", "x64"]

This fixes code signing issues when building universal binaries and allows
faster parallel builds for each architecture.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 19:58:35 +01:00
3 changed files with 147 additions and 27 deletions

View File

@@ -27,9 +27,10 @@ jobs:
dist/*.exe.blockmap dist/*.exe.blockmap
dist/latest.yml dist/latest.yml
build-macos: # macOS ARM64 build (Apple Silicon)
runs-on: macos-latest build-macos-arm64:
timeout-minutes: 360 # Max allowed (6 hours) for notarization runs-on: macos-latest # ARM64 runner for native Apple Silicon builds
timeout-minutes: 120
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: actions/setup-node@v4 - uses: actions/setup-node@v4
@@ -38,7 +39,7 @@ jobs:
cache: 'npm' cache: 'npm'
- run: npm ci - run: npm ci
- name: Build macOS Packages - name: Build macOS ARM64 Package
env: env:
# Code signing # Code signing
CSC_LINK: ${{ secrets.CSC_LINK }} CSC_LINK: ${{ secrets.CSC_LINK }}
@@ -47,14 +48,66 @@ jobs:
APPLE_ID: ${{ secrets.APPLE_ID }} APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }} APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
run: npx electron-builder --mac --publish never run: npx electron-builder --mac --arm64 --publish never
- name: Rename ARM64 artifacts for clarity
run: |
cd dist
for f in *.dmg; do
[ -f "$f" ] && mv "$f" "${f%.dmg}-arm64.dmg" 2>/dev/null || true
done
for f in *.zip; do
[ -f "$f" ] && mv "$f" "${f%.zip}-arm64.zip" 2>/dev/null || true
done
ls -la
- uses: actions/upload-artifact@v4 - uses: actions/upload-artifact@v4
with: with:
name: macos-builds name: macos-arm64-builds
path: |
dist/*.dmg
dist/*.zip
# macOS x64 build (Intel)
build-macos-x64:
runs-on: macos-15-large # Intel runner for native x64 builds
timeout-minutes: 120
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- run: npm ci
- name: Build macOS x64 Package
env:
# Code signing
CSC_LINK: ${{ secrets.CSC_LINK }}
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
# Notarization
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
run: npx electron-builder --mac --x64 --publish never
- name: Rename x64 artifacts for clarity
run: |
cd dist
for f in *.dmg; do
[ -f "$f" ] && mv "$f" "${f%.dmg}-x64.dmg" 2>/dev/null || true
done
for f in *.zip; do
[ -f "$f" ] && mv "$f" "${f%.zip}-x64.zip" 2>/dev/null || true
done
ls -la
- uses: actions/upload-artifact@v4
with:
name: macos-x64-builds
path: | path: |
dist/*.dmg dist/*.dmg
dist/*.zip dist/*.zip
dist/latest-mac.yml
build-linux: build-linux:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@@ -190,9 +243,9 @@ jobs:
draft: true draft: true
prerelease: false prerelease: false
# Upload macOS builds separately (slow due to notarization) # Upload macOS ARM64 builds separately
release-macos: release-macos-arm64:
needs: [build-macos, release] needs: [build-macos-arm64, release]
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: | if: |
startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/tags/v') ||
@@ -203,20 +256,51 @@ jobs:
contents: write contents: write
steps: steps:
- name: Download macOS artifacts - name: Download macOS ARM64 artifacts
uses: actions/download-artifact@v4 uses: actions/download-artifact@v4
with: with:
name: macos-builds name: macos-arm64-builds
path: artifacts/macos-builds path: artifacts/macos-arm64-builds
- name: Display macOS files - name: Display macOS ARM64 files
run: ls -R artifacts run: ls -R artifacts
- name: Upload macOS to Release - name: Upload macOS ARM64 to Release
uses: softprops/action-gh-release@v2 uses: softprops/action-gh-release@v2
with: with:
tag_name: ${{ github.ref_name }} tag_name: ${{ github.ref_name }}
files: | files: |
artifacts/macos-builds/* artifacts/macos-arm64-builds/*
draft: true draft: true
prerelease: false prerelease: false
# Upload macOS x64 builds separately
release-macos-x64:
needs: [build-macos-x64, release]
runs-on: ubuntu-latest
if: |
startsWith(github.ref, 'refs/tags/v') ||
github.ref == 'refs/heads/main' ||
github.event_name == 'workflow_dispatch'
permissions:
contents: write
steps:
- name: Download macOS x64 artifacts
uses: actions/download-artifact@v4
with:
name: macos-x64-builds
path: artifacts/macos-x64-builds
- name: Display macOS x64 files
run: ls -R artifacts
- name: Upload macOS x64 to Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
files: |
artifacts/macos-x64-builds/*
draft: true
prerelease: false

View File

@@ -121,13 +121,15 @@
{ {
"target": "dmg", "target": "dmg",
"arch": [ "arch": [
"universal" "arm64",
"x64"
] ]
}, },
{ {
"target": "zip", "target": "zip",
"arch": [ "arch": [
"universal" "arm64",
"x64"
] ]
} }
], ],
@@ -136,7 +138,11 @@
"hardenedRuntime": true, "hardenedRuntime": true,
"gatekeeperAssess": false, "gatekeeperAssess": false,
"entitlements": "build/entitlements.mac.plist", "entitlements": "build/entitlements.mac.plist",
"entitlementsInherit": "build/entitlements.mac.plist" "entitlementsInherit": "build/entitlements.mac.plist",
"forceCodeSigning": true,
"strictVerify": true,
"type": "distribution",
"notarize": false
}, },
"afterSign": "scripts/notarize.js", "afterSign": "scripts/notarize.js",
"nsis": { "nsis": {

View File

@@ -11,6 +11,18 @@ try {
const path = require('path'); const path = require('path');
// Timeout for notarization (30 minutes max)
const NOTARIZE_TIMEOUT_MS = 30 * 60 * 1000;
function withTimeout(promise, ms, message) {
return Promise.race([
promise,
new Promise((_, reject) =>
setTimeout(() => reject(new Error(message)), ms)
)
]);
}
exports.default = async function notarizing(context) { exports.default = async function notarizing(context) {
console.log('[Notarize] afterSign hook called'); console.log('[Notarize] afterSign hook called');
console.log('[Notarize] Context:', JSON.stringify({ console.log('[Notarize] Context:', JSON.stringify({
@@ -27,6 +39,12 @@ exports.default = async function notarizing(context) {
return; return;
} }
// Check if notarization is disabled via env var
if (process.env.SKIP_NOTARIZE === 'true') {
console.log('[Notarize] Skipping: SKIP_NOTARIZE=true');
return;
}
// Check credentials // Check credentials
const hasAppleId = !!process.env.APPLE_ID; const hasAppleId = !!process.env.APPLE_ID;
const hasPassword = !!process.env.APPLE_APP_SPECIFIC_PASSWORD; const hasPassword = !!process.env.APPLE_APP_SPECIFIC_PASSWORD;
@@ -45,18 +63,30 @@ exports.default = async function notarizing(context) {
console.log('[Notarize] Starting notarization...'); console.log('[Notarize] Starting notarization...');
console.log('[Notarize] App path:', appPath); console.log('[Notarize] App path:', appPath);
console.log('[Notarize] Team ID:', process.env.APPLE_TEAM_ID); console.log('[Notarize] Team ID:', process.env.APPLE_TEAM_ID);
console.log('[Notarize] Timeout:', NOTARIZE_TIMEOUT_MS / 1000, 'seconds');
try { try {
await notarize({ await withTimeout(
appPath, notarize({
appleId: process.env.APPLE_ID, appPath,
appleIdPassword: process.env.APPLE_APP_SPECIFIC_PASSWORD, appleId: process.env.APPLE_ID,
teamId: process.env.APPLE_TEAM_ID, appleIdPassword: process.env.APPLE_APP_SPECIFIC_PASSWORD,
}); teamId: process.env.APPLE_TEAM_ID,
}),
NOTARIZE_TIMEOUT_MS,
`Notarization timed out after ${NOTARIZE_TIMEOUT_MS / 1000} seconds`
);
console.log('[Notarize] Notarization complete!'); console.log('[Notarize] Notarization complete!');
} catch (error) { } catch (error) {
console.error('[Notarize] Notarization failed:', error.message); console.error('[Notarize] Notarization failed:', error.message);
console.error('[Notarize] Full error:', error);
// Don't fail the build if notarization times out or fails
// The app will still be code-signed, just not notarized
if (process.env.NOTARIZE_FAIL_ON_ERROR !== 'true') {
console.warn('[Notarize] Continuing build without notarization (set NOTARIZE_FAIL_ON_ERROR=true to fail)');
return;
}
throw error; throw error;
} }
}; };