A desktop coding agent with free access to frontier models.
TypeScript
ci: sign and notarize the macOS build
ogsamrat6db4e1e7072b
diff --git a/.github/workflows/build-electron-desktop.yml b/.github/workflows/build-electron-desktop.ymlindex abe2e889..48255dea 100644--- a/.github/workflows/build-electron-desktop.yml+++ b/.github/workflows/build-electron-desktop.yml@@ -74,6 +74,7 @@ jobs:electron-macos-notarization-smoke:name: Electron macOS notarization smokeruns-on: macos-14+ timeout-minutes: 300steps:- name: Checkout@@ -92,47 +93,45 @@ jobs:- name: Setup Bunuses: oven-sh/setup-bun@v2with:- bun-version: 1.3.9+ bun-version: 1.3.10- name: Install dependenciesrun: pnpm install --frozen-lockfile- # Same signing inputs as the release workflow's mac leg.- - name: Write notary API key+ # Same signing, notarization and checks as the release workflow's mac leg.+ - name: Prepare macOS signingenv:+ MAC_CSC_LINK: ${{ secrets.MAC_CSC_LINK }}+ MAC_CSC_KEY_PASSWORD: ${{ secrets.MAC_CSC_KEY_PASSWORD }}APPLE_API_KEY_P8_BASE64: ${{ secrets.APPLE_API_KEY }}APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}- run: |- set -euo pipefail- key="$RUNNER_TEMP/AuthKey_${APPLE_API_KEY_ID}.p8"- printf '%s' "$APPLE_API_KEY_P8_BASE64" | base64 --decode > "$key"- chmod 600 "$key"- {- echo "APPLE_API_KEY=$key"- echo "APPLE_API_KEY_ID=$APPLE_API_KEY_ID"- echo "APPLE_API_ISSUER=$APPLE_API_ISSUER"- } >> "$GITHUB_ENV"+ run: scripts/release/macos-signing-env.sh- name: Package Electron desktop (signed + notarized, no publish)env:CSC_LINK: ${{ secrets.MAC_CSC_LINK }}CSC_KEY_PASSWORD: ${{ secrets.MAC_CSC_KEY_PASSWORD }}+ CSC_IDENTITY_AUTO_DISCOVERY: "true"OMNIRUSH_DESKTOP_SENTRY_DSN: ${{ secrets.OMNIRUSH_DESKTOP_SENTRY_DSN || vars.OMNIRUSH_DESKTOP_SENTRY_DSN }}OMNIRUSH_DESKTOP_SENTRY_TRACES_SAMPLE_RATE: ${{ vars.OMNIRUSH_DESKTOP_SENTRY_TRACES_SAMPLE_RATE || '0.01' }}run: |set -euo pipefailpnpm --filter @omnirush/desktop run build:electron- pnpm --dir apps/desktop exec electron-builder --config electron-builder.yml --mac --arm64 -c.mac.notarize=true --publish never+ pnpm --dir apps/desktop exec electron-builder --config electron-builder.yml --mac --arm64 -c.mac.forceCodeSigning=true --publish never- - name: Verify macOS signature and notarization+ - name: Notarize macOS disk imagerun: |- set -euo pipefail- app=$(find apps/desktop/dist-electron -maxdepth 2 -name '*.app' -type d | head -n 1)- codesign --verify --deep --strict --verbose=2 "$app"- codesign -dv --verbose=4 "$app" 2>&1 | grep -E '^(Authority|TeamIdentifier|Runtime)'- spctl --assess --type execute --verbose=4 "$app"- xcrun stapler validate "$app"+ node apps/desktop/scripts/macos-notarize.cjs \+ --dist apps/desktop/dist-electron \+ --manifest apps/desktop/dist-electron/latest-mac.yml \+ --keychain "$MACOS_SIGNING_KEYCHAIN"++ - name: Verify update manifest+ run: node apps/desktop/scripts/verify-update-manifest.mjs --manifest apps/desktop/dist-electron/latest-mac.yml++ - name: Verify macOS signature and notarization+ run: scripts/release/verify-macos-signing.sh apps/desktop/dist-electron- name: Verify the bundled engine is signed and runsrun: |@@ -145,3 +144,13 @@ jobs:version=$("$engine" --version)echo "bundled engine: $version"test "$version" = "$(node -p "require('./apps/desktop/scripts/engine-release.json').version")"++ - name: Upload signed macOS build+ uses: actions/upload-artifact@v4+ with:+ name: omnirush-electron-macos-signed+ path: |+ apps/desktop/dist-electron/*.dmg+ apps/desktop/dist-electron/*.zip+ apps/desktop/dist-electron/*.blockmap+ apps/desktop/dist-electron/latest-mac.ymldiff --git a/.github/workflows/release-desktop.yml b/.github/workflows/release-desktop.ymlindex abfa6e72..f69fbdaa 100644--- a/.github/workflows/release-desktop.yml+++ b/.github/workflows/release-desktop.yml@@ -65,7 +65,8 @@ jobs:build:name: Build ${{ matrix.name }}needs: prepare- timeout-minutes: 120+ # Apple's notarization review of the app and the DMG can take an hour each.+ timeout-minutes: ${{ matrix.platform == 'macos' && 300 || 120 }}strategy:fail-fast: falsematrix:@@ -74,7 +75,7 @@ jobs:runner: macos-14platform: macostarget: aarch64-apple-darwin- builder_args: --mac --arm64+ builder_args: --mac --arm64 -c.mac.forceCodeSigning=trueupdate_manifest: latest-mac.yml# No Windows build: Windows installs and updates are no longer# offered, so no installer and no latest.yml feed are published.@@ -149,7 +150,24 @@ jobs:shell: bashrun: pnpm --filter @omnirush/desktop build:electron+ # Developer ID signature, hardened runtime and notarization. Refuses to+ # package a mac build without the signing secrets.+ - name: Prepare macOS signing+ if: matrix.platform == 'macos'+ env:+ MAC_CSC_LINK: ${{ secrets.MAC_CSC_LINK }}+ MAC_CSC_KEY_PASSWORD: ${{ secrets.MAC_CSC_KEY_PASSWORD }}+ APPLE_API_KEY_P8_BASE64: ${{ secrets.APPLE_API_KEY }}+ APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}+ APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}+ shell: bash+ run: scripts/release/macos-signing-env.sh+- name: Package installer+ env:+ CSC_LINK: ${{ matrix.platform == 'macos' && secrets.MAC_CSC_LINK || '' }}+ CSC_KEY_PASSWORD: ${{ matrix.platform == 'macos' && secrets.MAC_CSC_KEY_PASSWORD || '' }}+ CSC_IDENTITY_AUTO_DISCOVERY: ${{ matrix.platform == 'macos' && 'true' || 'false' }}shell: bashrun: |pnpm --dir apps/desktop exec electron-builder \@@ -157,6 +175,23 @@ jobs:${{ matrix.builder_args }} \--publish never+ # The app was notarized and stapled before electron-builder zipped it;+ # the DMG is signed, notarized and stapled here, and its sha512 in+ # latest-mac.yml rewritten to match.+ - name: Notarize macOS disk image+ if: matrix.platform == 'macos'+ shell: bash+ run: |+ node apps/desktop/scripts/macos-notarize.cjs \+ --dist apps/desktop/dist-electron \+ --manifest "apps/desktop/dist-electron/${{ matrix.update_manifest }}" \+ --keychain "$MACOS_SIGNING_KEYCHAIN"++ - name: Verify macOS signature and notarization+ if: matrix.platform == 'macos'+ shell: bash+ run: scripts/release/verify-macos-signing.sh apps/desktop/dist-electron+- name: Verify packaged server importsshell: bashrun: node apps/desktop/scripts/verify-packaged-imports.mjsdiff --git a/apps/desktop/scripts/electron-after-sign.cjs b/apps/desktop/scripts/electron-after-sign.cjsindex fa4b485f..e9a7c206 100644--- a/apps/desktop/scripts/electron-after-sign.cjs+++ b/apps/desktop/scripts/electron-after-sign.cjs@@ -1,5 +1,6 @@const { spawnSync } = require("node:child_process");const { existsSync, mkdtempSync, rmSync } = require("node:fs");+const { notaryCredentials, notarizeFile, runWithRetry, staple } = require("./macos-notarize.cjs");const { tmpdir } = require("node:os");const path = require("node:path");@@ -12,29 +13,6 @@ function run(command, args) {}}-async function runWithRetry(command, args, attempts, baseDelayMs = 30_000) {- for (let attempt = 1; ; attempt++) {- const result = spawnSync(command, args, { stdio: "inherit" });- if (result.status === 0) return;- if (attempt >= attempts) {- throw new Error(`${command} ${args.join(" ")} failed with status ${result.status} after ${attempts} attempts`);- }- const delayMs = baseDelayMs * attempt;- console.warn(- `[electron-after-sign] ${command} ${args.join(" ")} failed with status ${result.status}; retrying in ${delayMs / 1000}s (attempt ${attempt}/${attempts}).`,- );- await new Promise((resolve) => setTimeout(resolve, delayMs));- }-}--function requireEnv(name) {- const value = process.env[name];- if (!value) {- throw new Error(`${name} is required to notarize the Electron macOS app`);- }- return value;-}-function computerUseHelperPath(appPath) {return path.join(appPath, "Contents", "Resources", "helpers", computerUseHelperAppName);}@@ -91,31 +69,21 @@ async function afterSign(context) {console.warn("[electron-after-sign] MACOS_NOTARIZE is not true; skipping notarization.");return;}- verifyComputerUseHelper(appPath, process.env.MACOS_NOTARIZE === "true");+ const display = spawnSync("codesign", ["--display", "--verbose=2", appPath], { encoding: "utf8" });+ if (!/Authority=Developer ID Application/.test(`${display.stdout || ""}${display.stderr || ""}`)) {+ throw new Error("MACOS_NOTARIZE is true but the app is not Developer ID signed; check the signing certificate.");+ }+ verifyComputerUseHelper(appPath, true);+ const credentials = notaryCredentials();const notaryTempDir = mkdtempSync(path.join(tmpdir(), "omnirush-electron-notary-"));- const notaryZipPath = path.join(notaryTempDir, `${context.packager.appInfo.productFilename}-notary.zip`);- const keyPath = requireEnv("APPLE_API_KEY_PATH");- const keyId = requireEnv("APPLE_API_KEY");- const issuer = requireEnv("APPLE_API_ISSUER");-+ const notaryZipPath = path.join(notaryTempDir, `${context.packager.appInfo.productFilename}.zip`);try {run("ditto", ["-c", "-k", "--keepParent", appPath, notaryZipPath]);- run("xcrun", [- "notarytool",- "submit",- notaryZipPath,- "--key",- keyPath,- "--key-id",- keyId,- "--issuer",- issuer,- "--wait",- ]);- // Notarization tickets can take minutes to propagate to Apple's CDN after acceptance; stapler can transiently fail with status 65 ("CloudKit query failed").- await runWithRetry("xcrun", ["stapler", "staple", appPath], 5);- run("xcrun", ["stapler", "validate", appPath]);+ await notarizeFile(notaryZipPath, credentials);+ // electron-builder builds the DMG and the updater zip after this hook, so+ // both carry the stapled app.+ await staple(appPath);} finally {rmSync(notaryTempDir, { recursive: true, force: true });}diff --git a/apps/desktop/scripts/macos-notarize.cjs b/apps/desktop/scripts/macos-notarize.cjsnew file mode 100644index 00000000..e9c9607e--- /dev/null+++ b/apps/desktop/scripts/macos-notarize.cjs@@ -0,0 +1,208 @@+#!/usr/bin/env node+/**+ * Apple notarization helpers for the macOS release.+ *+ * `notarizeFile` submits without `--wait` and polls the submission itself, so a+ * dropped connection during Apple's (sometimes hour-long) review does not fail+ * the build the way `notarytool submit --wait` does.+ *+ * As a command it finishes the disk images after electron-builder:+ *+ * node scripts/macos-notarize.cjs --dist <dir> --manifest <latest-mac.yml> --keychain <path>+ *+ * Each DMG in <dir> is signed with the Developer ID identity from <keychain>,+ * notarized and stapled. Stapling changes the file, so its .blockmap is rebuilt+ * and its sha512 and size in the update manifest are rewritten. The zip the+ * updater installs is not touched: the app inside it was stapled before it was+ * zipped.+ *+ * Credentials come from APPLE_API_KEY (path to the .p8), APPLE_API_KEY_ID and+ * APPLE_API_ISSUER.+ */+const { spawnSync } = require("node:child_process");+const { createHash } = require("node:crypto");+const { createReadStream, existsSync, readdirSync, readFileSync, statSync, writeFileSync } = require("node:fs");+const path = require("node:path");++const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));++function capture(command, args) {+ const result = spawnSync(command, args, { encoding: "utf8", maxBuffer: 64 * 1024 * 1024 });+ if (result.error) throw result.error;+ return { status: result.status, stdout: result.stdout ?? "", stderr: result.stderr ?? "" };+}++function run(command, args) {+ const result = spawnSync(command, args, { stdio: "inherit" });+ if (result.status !== 0) {+ throw new Error(`${command} ${args.join(" ")} failed with status ${result.status}`);+ }+}++async function runWithRetry(command, args, attempts, baseDelayMs = 30_000) {+ for (let attempt = 1; ; attempt++) {+ const result = spawnSync(command, args, { stdio: "inherit" });+ if (result.status === 0) return;+ if (attempt >= attempts) {+ throw new Error(`${command} ${args.join(" ")} failed with status ${result.status} after ${attempts} attempts`);+ }+ const delayMs = baseDelayMs * attempt;+ console.warn(`[notarize] ${command} ${args[0]} failed with status ${result.status}; retrying in ${delayMs / 1000}s (attempt ${attempt}/${attempts}).`);+ await sleep(delayMs);+ }+}++function notaryCredentials(env = process.env) {+ const missing = ["APPLE_API_KEY", "APPLE_API_KEY_ID", "APPLE_API_ISSUER"].filter((name) => !env[name]);+ if (missing.length) throw new Error(`${missing.join(", ")} required to notarize the macOS build`);+ if (!existsSync(env.APPLE_API_KEY)) throw new Error("APPLE_API_KEY must be the path to the App Store Connect .p8 key");+ return { key: env.APPLE_API_KEY, keyId: env.APPLE_API_KEY_ID, issuer: env.APPLE_API_ISSUER };+}++function authArgs(credentials) {+ return ["--key", credentials.key, "--key-id", credentials.keyId, "--issuer", credentials.issuer];+}++function parseJson(text) {+ try {+ return JSON.parse(text);+ } catch {+ return null;+ }+}++async function notarizeFile(filePath, credentials = notaryCredentials(), {+ pollMs = 30_000,+ timeoutMs = 150 * 60_000,+ submitAttempts = 4,+} = {}) {+ const name = path.basename(filePath);+ let id = null;+ for (let attempt = 1; !id; attempt++) {+ const submit = capture("xcrun", ["notarytool", "submit", filePath, ...authArgs(credentials), "--output-format", "json"]);+ id = parseJson(submit.stdout)?.id ?? null;+ if (id) break;+ const detail = `${submit.stdout}${submit.stderr}`.trim();+ if (attempt >= submitAttempts) throw new Error(`notarytool submit ${name} failed: ${detail}`);+ console.warn(`[notarize] submit ${name} failed (attempt ${attempt}/${submitAttempts}): ${detail}`);+ await sleep(30_000 * attempt);+ }+ console.log(`[notarize] ${name}: submission ${id}`);++ const deadline = Date.now() + timeoutMs;+ let status = "In Progress";+ while (status === "In Progress") {+ if (Date.now() > deadline) throw new Error(`notarization of ${name} (${id}) did not finish within ${timeoutMs / 60_000} minutes`);+ await sleep(pollMs);+ const info = capture("xcrun", ["notarytool", "info", id, ...authArgs(credentials), "--output-format", "json"]);+ const parsed = parseJson(info.stdout);+ if (parsed?.status) {+ status = parsed.status;+ } else {+ // A network blip while polling is not a notarization failure.+ console.warn(`[notarize] ${name}: status check failed, retrying: ${`${info.stdout}${info.stderr}`.trim()}`);+ }+ }+ console.log(`[notarize] ${name}: ${status}`);++ let log = "";+ for (let attempt = 1; attempt <= 5; attempt++) {+ const result = capture("xcrun", ["notarytool", "log", id, ...authArgs(credentials)]);+ if (result.status === 0) {+ log = result.stdout;+ break;+ }+ await sleep(15_000 * attempt);+ }+ if (log) console.log(`[notarize] ${name} log:\n${log}`);+ if (status !== "Accepted") throw new Error(`notarization of ${name} (${id}) ended with status ${status}`);+ return { id, status };+}++async function staple(filePath) {+ // A fresh ticket can take minutes to reach Apple's CDN; stapler then fails+ // with status 65 ("CloudKit query failed").+ await runWithRetry("xcrun", ["stapler", "staple", filePath], 5);+ run("xcrun", ["stapler", "validate", filePath]);+}++function developerIdIdentity(keychain) {+ const { stdout } = capture("security", ["find-identity", "-v", "-p", "codesigning", keychain]);+ const match = stdout.match(/^\s*\d+\)\s+([0-9A-F]{40})\s+"Developer ID Application: [^"]+"/m);+ if (!match) throw new Error(`no Developer ID Application identity in ${keychain}`);+ return match[1];+}++function sha512Base64(filePath) {+ return new Promise((resolve, reject) => {+ const hash = createHash("sha512");+ createReadStream(filePath)+ .on("data", (chunk) => hash.update(chunk))+ .on("error", reject)+ .on("end", () => resolve(hash.digest("base64")));+ });+}++async function rebuildBlockmap(filePath) {+ const builderDir = path.dirname(require.resolve("electron-builder/package.json"));+ const libDir = path.dirname(require.resolve("app-builder-lib/package.json", { paths: [builderDir] }));+ const { buildBlockMap } = require(path.join(libDir, "out", "targets", "blockmap", "blockmap.js"));+ await buildBlockMap(filePath, "gzip", `${filePath}.blockmap`);+}++/**+ * Points the manifest entries for the given files at their current bytes. Edits+ * the parsed document in place so every other value keeps its exact form (a+ * quoted releaseDate must stay a string for electron-updater's YAML parser).+ */+async function refreshManifest(manifestPath, filePaths) {+ const YAML = require("yaml");+ const doc = YAML.parseDocument(readFileSync(manifestPath, "utf8"));+ const files = doc.get("files");+ for (const filePath of filePaths) {+ const name = path.basename(filePath);+ const entry = files?.items?.find((item) => item.get("url") === name);+ if (!entry) throw new Error(`${path.basename(manifestPath)} does not list ${name}`);+ const sha512 = await sha512Base64(filePath);+ entry.set("sha512", sha512);+ entry.set("size", statSync(filePath).size);+ if (doc.get("path") === name) doc.set("sha512", sha512);+ }+ writeFileSync(manifestPath, doc.toString({ lineWidth: 0 }));+}++async function finishDiskImages({ dist, manifest, keychain }) {+ const credentials = notaryCredentials();+ const identity = developerIdIdentity(keychain);+ const images = readdirSync(dist).filter((name) => name.endsWith(".dmg")).map((name) => path.join(dist, name));+ if (!images.length) throw new Error(`no .dmg in ${dist}`);+ for (const image of images) {+ run("codesign", ["--force", "--sign", identity, "--keychain", keychain, "--timestamp", image]);+ await notarizeFile(image, credentials);+ await staple(image);+ await rebuildBlockmap(image);+ }+ await refreshManifest(manifest, images);+}++function parseArgs(argv) {+ const args = {};+ for (let i = 0; i < argv.length; i += 2) {+ const flag = argv[i];+ if (!flag.startsWith("--") || argv[i + 1] === undefined) throw new Error(`unexpected argument ${flag}`);+ args[flag.slice(2)] = argv[i + 1];+ }+ for (const name of ["dist", "manifest", "keychain"]) {+ if (!args[name]) throw new Error(`--${name} is required`);+ }+ return args;+}++module.exports = { notaryCredentials, notarizeFile, staple, runWithRetry, refreshManifest, rebuildBlockmap };++if (require.main === module) {+ finishDiskImages(parseArgs(process.argv.slice(2))).catch((error) => {+ console.error(`[notarize] ${error?.message ?? error}`);+ process.exit(1);+ });+}diff --git a/scripts/release/macos-signing-env.sh b/scripts/release/macos-signing-env.shnew file mode 100755index 00000000..fc847196--- /dev/null+++ b/scripts/release/macos-signing-env.sh@@ -0,0 +1,48 @@+#!/usr/bin/env bash+# Prepares a macOS runner to sign and notarize the desktop app.+#+# Reads MAC_CSC_LINK (base64 .p12), MAC_CSC_KEY_PASSWORD, APPLE_API_KEY_P8_BASE64,+# APPLE_API_KEY_ID and APPLE_API_ISSUER; refuses when any is missing. Imports the+# Developer ID certificate into a temporary keychain (used to sign the DMG),+# writes the notary key, and exports the notarization environment through+# $GITHUB_ENV. electron-builder still gets the certificate as CSC_LINK /+# CSC_KEY_PASSWORD in the packaging step's own env.+set -euo pipefail++for name in MAC_CSC_LINK MAC_CSC_KEY_PASSWORD APPLE_API_KEY_P8_BASE64 APPLE_API_KEY_ID APPLE_API_ISSUER; do+ if [ -z "${!name:-}" ]; then+ echo "macOS signing secret for $name is missing; refusing to build an unsigned app." >&2+ exit 1+ fi+done++key="$RUNNER_TEMP/AuthKey_${APPLE_API_KEY_ID}.p8"+printf '%s' "$APPLE_API_KEY_P8_BASE64" | base64 --decode > "$key"+chmod 600 "$key"++keychain="$RUNNER_TEMP/omnirush-signing.keychain-db"+keychain_password=$(openssl rand -hex 24)+cert="$RUNNER_TEMP/omnirush-signing.p12"+printf '%s' "$MAC_CSC_LINK" | base64 --decode > "$cert"+security create-keychain -p "$keychain_password" "$keychain"+security set-keychain-settings -lut 21600 "$keychain"+security unlock-keychain -p "$keychain_password" "$keychain"+security import "$cert" -k "$keychain" -P "$MAC_CSC_KEY_PASSWORD" -T /usr/bin/codesign >/dev/null+rm -f "$cert"+security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$keychain_password" "$keychain" >/dev/null+# Keep the login keychain searchable alongside the new one.+existing=$(security list-keychains -d user | sed -e 's/^ *"//' -e 's/" *$//')+# shellcheck disable=SC2086+security list-keychains -d user -s "$keychain" $existing+security find-identity -v -p codesigning "$keychain" | grep -q '"Developer ID Application: ' || {+ echo "The signing certificate holds no Developer ID Application identity." >&2+ exit 1+}++{+ echo "MACOS_NOTARIZE=true"+ echo "MACOS_SIGNING_KEYCHAIN=$keychain"+ echo "APPLE_API_KEY=$key"+ echo "APPLE_API_KEY_ID=$APPLE_API_KEY_ID"+ echo "APPLE_API_ISSUER=$APPLE_API_ISSUER"+} >> "$GITHUB_ENV"diff --git a/scripts/release/verify-macos-signing.sh b/scripts/release/verify-macos-signing.shnew file mode 100755index 00000000..17125b64--- /dev/null+++ b/scripts/release/verify-macos-signing.sh@@ -0,0 +1,54 @@+#!/usr/bin/env bash+# Verifies the signed macOS output in <dist-dir> (apps/desktop/dist-electron):+# the packaged app, every DMG, and the app inside every updater zip must carry a+# Developer ID signature with the hardened runtime, pass Gatekeeper as+# "Notarized Developer ID", and hold a stapled ticket.+set -euo pipefail++dist="${1:?usage: verify-macos-signing.sh <dist-dir>}"+shopt -s nullglob++gatekeeper() {+ local out+ out=$(spctl "$@" 2>&1) || { echo "$out" >&2; return 1; }+ echo "$out"+ grep -q 'source=Notarized Developer ID' <<<"$out" || { echo "Gatekeeper source is not Notarized Developer ID" >&2; return 1; }+}++check_app() {+ local app="$1" details+ echo "== $app"+ codesign --verify --deep --strict --verbose=2 "$app"+ details=$(codesign -dv --verbose=4 "$app" 2>&1)+ grep -E '^(Identifier|Authority|TeamIdentifier|Timestamp|CodeDirectory)' <<<"$details"+ grep -q '^Authority=Developer ID Application' <<<"$details" || { echo "not Developer ID signed" >&2; return 1; }+ grep -Eq '^CodeDirectory .*flags=0x[0-9a-f]*\(.*runtime' <<<"$details" || { echo "hardened runtime is off" >&2; return 1; }+ codesign -d --entitlements - --xml "$app" 2>/dev/null | plutil -p - || true+ gatekeeper -a -vv -t exec "$app"+ xcrun stapler validate "$app"+}++apps=("$dist"/mac*/*.app)+dmgs=("$dist"/*.dmg)+zips=("$dist"/*-mac-*.zip)+[ ${#apps[@]} -gt 0 ] || { echo "no packaged .app under $dist" >&2; exit 1; }+[ ${#dmgs[@]} -gt 0 ] || { echo "no .dmg under $dist" >&2; exit 1; }+[ ${#zips[@]} -gt 0 ] || { echo "no mac .zip under $dist" >&2; exit 1; }++for app in "${apps[@]}"; do check_app "$app"; done++for dmg in "${dmgs[@]}"; do+ echo "== $dmg"+ codesign --verify --strict --verbose=2 "$dmg"+ codesign -dv --verbose=4 "$dmg" 2>&1 | grep -E '^(Authority|TeamIdentifier|Timestamp)'+ gatekeeper -a -vv -t open --context context:primary-signature "$dmg"+ xcrun stapler validate "$dmg"+done++for zip in "${zips[@]}"; do+ echo "== $zip"+ out=$(mktemp -d)+ ditto -x -k "$zip" "$out"+ for app in "$out"/*.app; do check_app "$app"; done+ rm -rf "$out"+done