Skip to content

Commit b03314b

Browse files
committed
ci: allow signed-only cli mac builds
1 parent 0dc8d29 commit b03314b

2 files changed

Lines changed: 31 additions & 6 deletions

File tree

.github/workflows/cli-release.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ on:
1111
description: "Optional comma-separated release targets override"
1212
required: false
1313
default: ""
14+
skip_notarize:
15+
description: "Skip macOS notarization and publish signed-only CLI binaries"
16+
required: false
17+
default: false
18+
type: boolean
1419

1520
concurrency:
1621
group: ${{ github.workflow }}
@@ -45,6 +50,7 @@ jobs:
4550
APPLE_NOTARIZATION_KEY: ${{ secrets.APPLE_NOTARIZATION_KEY }}
4651
APPLE_NOTARIZATION_KEY_ID: ${{ secrets.APPLE_NOTARIZATION_KEY_ID }}
4752
APPLE_NOTARIZATION_ISSUER: ${{ secrets.APPLE_NOTARIZATION_ISSUER }}
53+
INLINE_SKIP_NOTARIZE: ${{ github.event.inputs.skip_notarize }}
4854
run: |
4955
set -euo pipefail
5056
supported=(
@@ -100,6 +106,11 @@ jobs:
100106
exit 1
101107
fi
102108
109+
skip_notarize=false
110+
if [[ "${INLINE_SKIP_NOTARIZE}" == "true" || "${INLINE_SKIP_NOTARIZE}" == "1" ]]; then
111+
skip_notarize=true
112+
fi
113+
103114
if [[ -z "${TARGETS_OVERRIDE}" || "${TARGETS_OVERRIDE}" == *apple-darwin* ]]; then
104115
has_api_key=false
105116
if [[ -n "${APPLE_NOTARIZATION_KEY:-}" && -n "${APPLE_NOTARIZATION_KEY_ID:-}" && -n "${APPLE_NOTARIZATION_ISSUER:-}" ]]; then
@@ -109,7 +120,7 @@ jobs:
109120
if [[ -n "${APPLE_ID:-}" && -n "${APPLE_PASSWORD:-}" && -n "${APPLE_TEAM_ID:-}" ]]; then
110121
has_apple_id=true
111122
fi
112-
if [[ "${has_api_key}" != "true" && "${has_apple_id}" != "true" ]]; then
123+
if [[ "${skip_notarize}" != "true" && "${has_api_key}" != "true" && "${has_apple_id}" != "true" ]]; then
113124
echo "Missing notarization credentials: provide APPLE_NOTARIZATION_KEY, APPLE_NOTARIZATION_KEY_ID, APPLE_NOTARIZATION_ISSUER or APPLE_ID, APPLE_PASSWORD, APPLE_TEAM_ID" >&2
114125
exit 1
115126
fi
@@ -314,6 +325,7 @@ jobs:
314325
APPLE_NOTARIZATION_KEY: ${{ secrets.APPLE_NOTARIZATION_KEY }}
315326
APPLE_NOTARIZATION_KEY_ID: ${{ secrets.APPLE_NOTARIZATION_KEY_ID }}
316327
APPLE_NOTARIZATION_ISSUER: ${{ secrets.APPLE_NOTARIZATION_ISSUER }}
328+
INLINE_SKIP_NOTARIZE: ${{ github.event.inputs.skip_notarize }}
317329
run: |
318330
set -euo pipefail
319331
bun run scripts/release-cli.ts build

scripts/release-cli.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ const appleTeamId = process.env.APPLE_TEAM_ID;
2020
const appleNotarizationKey = process.env.APPLE_NOTARIZATION_KEY;
2121
const appleNotarizationKeyId = process.env.APPLE_NOTARIZATION_KEY_ID;
2222
const appleNotarizationIssuer = process.env.APPLE_NOTARIZATION_ISSUER;
23+
const skipNotarize =
24+
isTruthy(process.env.INLINE_SKIP_NOTARIZE) || isTruthy(process.env.SKIP_NOTARIZE);
2325
const defaultTargets = [
2426
"aarch64-apple-darwin",
2527
"x86_64-apple-darwin",
@@ -58,6 +60,10 @@ function trimSlash(value: string): string {
5860
return value.replace(/^\/+|\/+$/g, "");
5961
}
6062

63+
function isTruthy(value: string | undefined): boolean {
64+
return ["1", "true", "yes"].includes(value?.toLowerCase() ?? "");
65+
}
66+
6167
function getR2Context() {
6268
const accessKeyId = requireEnv("PUBLIC_RELEASES_R2_ACCESS_KEY_ID");
6369
const secretAccessKey = requireEnv("PUBLIC_RELEASES_R2_SECRET_ACCESS_KEY");
@@ -361,7 +367,7 @@ async function signAndNotarize(context: ReleaseContext) {
361367
Boolean(appleNotarizationKeyId) &&
362368
Boolean(appleNotarizationIssuer);
363369
const hasAppleId = Boolean(appleId) && Boolean(applePassword) && Boolean(appleTeamId);
364-
if (!hasApiKey && !hasAppleId) {
370+
if (!skipNotarize && !hasApiKey && !hasAppleId) {
365371
throw new Error(
366372
"Missing notarization env vars: provide APPLE_NOTARIZATION_KEY, APPLE_NOTARIZATION_KEY_ID, APPLE_NOTARIZATION_ISSUER or APPLE_ID, APPLE_PASSWORD, APPLE_TEAM_ID",
367373
);
@@ -380,7 +386,8 @@ async function signAndNotarize(context: ReleaseContext) {
380386
10,
381387
);
382388

383-
const keyPath = hasApiKey ? join(context.releaseDir, "notarization-key.p8") : null;
389+
const keyPath =
390+
!skipNotarize && hasApiKey ? join(context.releaseDir, "notarization-key.p8") : null;
384391
if (keyPath && appleNotarizationKey) {
385392
await writeFile(keyPath, appleNotarizationKey, { mode: 0o600 });
386393
}
@@ -405,6 +412,15 @@ async function signAndNotarize(context: ReleaseContext) {
405412
{ cwd: cliDir },
406413
);
407414

415+
await runCommand("codesign", ["--verify", "--strict", "--verbose=2", binaryPath], {
416+
cwd: cliDir,
417+
});
418+
419+
if (skipNotarize) {
420+
console.log(`Skipping notarization for ${target} (INLINE_SKIP_NOTARIZE=1).`);
421+
continue;
422+
}
423+
408424
await runCommand("zip", ["-j", "-X", zipPath, binaryPath], { cwd: cliDir });
409425

410426
const args = notarytoolSubmitArgs(zipPath, keyPath);
@@ -440,9 +456,6 @@ async function signAndNotarize(context: ReleaseContext) {
440456
await sleep(delay);
441457
}
442458

443-
await runCommand("codesign", ["--verify", "--strict", "--verbose=2", binaryPath], {
444-
cwd: cliDir,
445-
});
446459
}
447460
} finally {
448461
if (keyPath) {

0 commit comments

Comments
 (0)