Skip to content

Commit ca3083f

Browse files
committed
ci(desktop): finalize the DMG with the tested release script
The hand-written notarize step stapled the DMG after electron-builder had already written latest-mac.yml, so the manifest size and checksum no longer matched and the release failed verification. Reuse finalize-mac-artifacts.ts, which staples and then rewrites the manifest entry and drops the stale blockmap.
1 parent 8b6cc70 commit ca3083f

2 files changed

Lines changed: 20 additions & 23 deletions

File tree

.github/workflows/desktop-release.yml

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -237,29 +237,13 @@ jobs:
237237
run: pnpm exec electron-builder --mac dmg zip --publish never
238238
239239
# electron-builder notarizes and staples the .app but never the disk
240-
# image around it. A quarantined, unnotarized DMG is what Gatekeeper
241-
# reports as "damaged" on some macOS builds, so give the image its own
242-
# ticket and staple it. The API key is preferred; the Apple ID +
243-
# app-specific password pair is the fallback, mirroring electron-builder.
240+
# image around it; a quarantined, unnotarized DMG is what Gatekeeper
241+
# reports as "damaged". Stapling changes the DMG bytes, so the same
242+
# script also rewrites its latest-mac.yml entry and drops the stale
243+
# blockmap, keeping the update manifest verification below honest.
244244
- name: Notarize and staple macOS DMG
245-
shell: bash
246-
run: |
247-
set -euo pipefail
248-
dmg_path="$(find apps/desktop/dist -maxdepth 1 -type f -name '*.dmg' -print -quit)"
249-
if [ -z "$dmg_path" ]; then
250-
echo 'macOS DMG not found' >&2
251-
exit 1
252-
fi
253-
if [ -n "${APPLE_API_KEY:-}" ]; then
254-
auth=(--key "$APPLE_API_KEY" --key-id "$APPLE_API_KEY_ID" --issuer "$APPLE_API_ISSUER")
255-
elif [ -n "${APPLE_ID:-}" ]; then
256-
auth=(--apple-id "$APPLE_ID" --password "$APPLE_APP_SPECIFIC_PASSWORD" --team-id "$APPLE_TEAM_ID")
257-
else
258-
echo 'No notarization credentials configured; the DMG cannot be notarized.' >&2
259-
exit 1
260-
fi
261-
xcrun notarytool submit "$dmg_path" "${auth[@]}" --wait --timeout 30m
262-
xcrun stapler staple "$dmg_path"
245+
working-directory: apps/desktop
246+
run: node --import tsx scripts/finalize-mac-artifacts.ts dist
263247
264248
- name: Verify macOS update artifacts
265249
shell: bash

apps/desktop/scripts/finalize-mac-artifacts.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import {
1010
unlinkSync,
1111
writeFileSync,
1212
} from 'node:fs'
13-
import { basename, join } from 'node:path'
13+
import { basename, join, resolve } from 'node:path'
14+
import { fileURLToPath } from 'node:url'
1415
import { resolveNotarizationCredentials } from './release-preflight'
1516

1617
export interface CommandResult {
@@ -191,3 +192,15 @@ export function finalizeMacArtifacts(options: FinalizeMacArtifactsOptions): void
191192

192193
writeFileSync(metadataPath, metadata)
193194
}
195+
196+
const invokedPath = process.argv[1]
197+
if (invokedPath !== undefined && resolve(invokedPath) === fileURLToPath(import.meta.url)) {
198+
const distDir = process.argv[2]
199+
try {
200+
if (distDir === undefined) throw new Error('Usage: finalize-mac-artifacts.ts <dist-directory>')
201+
finalizeMacArtifacts({ distDir: resolve(distDir), env: process.env })
202+
} catch (error) {
203+
console.error(error instanceof Error ? error.message : String(error))
204+
process.exitCode = 1
205+
}
206+
}

0 commit comments

Comments
 (0)