Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/nightly-step-coverage.json
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,15 @@
"Bundle size budget": {"pr": "cmux-next.yml:checks:Script tests (pin-cmux-tui, embed-cef, ensure-cef store)"}},
"signer-build": {"Set up Rust": {"plumbing": true},
"Build the signer": {"nightly_only": "builds the pinned release signer; the build script's pins are tested by tests/test_release_signer_scripts.py"}},
"signer-app": {"Install the signer": {"pr": "ci-guards.yml:workflow-guard-tests:Validate the release signer scripts"}, "Prepare the app": {"pr": "ci-guards.yml:workflow-guard-tests:Validate the release signer scripts"}, "Notarize and staple the app": {"pr": "ci-guards.yml:workflow-guard-tests:Validate the release signer scripts"},
"signer-app": {"Install the signer": {"pr": "ci-guards.yml:workflow-guard-tests:Validate the release signer scripts"}, "Prepare the app": {"pr": "ci-guards.yml:workflow-guard-tests:Validate the release signer scripts"},
"Sign the app, the Computer Use helper notarized first": {"nightly_only": "signs with the release environment's Developer ID; the signer's rules are tested by its script tests"},
"Pack the stapled app": {"plumbing": true}},
"Pack the signed app": {"plumbing": true}},
"signer-app-notary": {"Install the signer": {"pr": "ci-guards.yml:workflow-guard-tests:Validate the release signer scripts"},
"Unpack the signed app": {"plumbing": true},
"Notarize the app": {"pr": "ci-guards.yml:workflow-guard-tests:Validate the release signer scripts"}},
"signer-dmg-image": {"Initialize cmux-next notices submodule": {"plumbing": true}, "Select Xcode": {"plumbing": true},
"Unpack the signed app": {"plumbing": true},
"Staple the app's notarization ticket": {"nightly_only": "Apple's stapler fetches the ticket of a release-pool app Apple notarized in signer-app-notary; only a release run has one"},
"Apple's checks of the stapled app": {"nightly_only": "Apple's tools on a notarized release build; only a release run has one"},
"Start the signed-app checks": {"nightly_only": "the checks build-sign-notarize-nightly runs on its signed app, on the release-pool build"},
"Start the verify-signed checks": {"nightly_only": "verify-signed-nightly's checks of the signed Release app (signer-verify-signed.sh), on the release-pool build that only the nightly signs"},
Expand Down
128 changes: 64 additions & 64 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5197,6 +5197,14 @@ jobs:
persist-credentials: false
ref: ${{ needs.resolve-nightly-cmux-tui-client.outputs.build_sha }}
submodules: false
# verify-final-dmg-artifact.sh (this commit's) runs the build tree's verify-dmg-artifact.sh.
- name: Checkout publication tooling at the workflow commit
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
ref: ${{ github.sha }}
path: .publish-tooling
sparse-checkout: scripts/ci/nightly-steps

# The static DMG verifier runs the license check, which reads
# ghostty-next/build.zig.zon.
Expand Down Expand Up @@ -5227,35 +5235,7 @@ jobs:
env:
POOL_SIGNED: ${{ needs.signer-dmg.result == 'success' }}
NIGHTLY_BUILD: ${{ needs.build-nightly-app.outputs.daemon_build }}
run: |
set -euo pipefail
mkdir -p tested
: > "tested/tested-${NIGHTLY_VARIANT}.sha256"
release="final-dmg/${CHANNEL_DMG_PREFIX}-${NIGHTLY_VARIANT}.dmg"
[ -f "$release" ] || { echo "no final DMG for $NIGHTLY_VARIANT" >&2; exit 1; }
# The DMG was signed and checked for the signing channel (cmux NEXT signs as next).
stapled_flag=(--require-stapled-app)
if [ -n "${STAPLED_APP_FALLBACK_ID:-}" ]; then
stapled_flag=(--stapled-app-fallback "$STAPLED_APP_FALLBACK_ID")
fi
# signer-dmg's one-DMG artifact carries no immutable copy, which signer-dmg.sh makes with
# cp: make it the same way. publish-nightly publishes that name only with these bytes.
if [ "$POOL_SIGNED" = true ]; then
immutable="final-dmg/${CHANNEL_DMG_PREFIX}-${NIGHTLY_VARIANT}-${NIGHTLY_BUILD:?}.dmg"
[ ! -e "$immutable" ] || { echo "the one-DMG artifact holds $(basename "$immutable")" >&2; exit 1; }
cp -c "$release" "$immutable" 2>/dev/null || cp "$release" "$immutable"
fi
./scripts/ci/verify-dmg-artifact.sh "$release" "$SIGN_CHANNEL" "${stapled_flag[@]}" 3>"$RUNNER_TEMP/verified.line"
tested="$(awk '$1 == "verified" {print $2}' "$RUNNER_TEMP/verified.line")"
[ -n "$tested" ] || { echo "verify-dmg-artifact.sh reported no verified digest" >&2; exit 1; }
# The immutable DMG is a copy of the release DMG: require the same bytes.
for dmg in final-dmg/"${CHANNEL_DMG_PREFIX}"-*.dmg; do
[ -f "$dmg" ] || continue
actual="$(shasum -a 256 "$dmg" | awk '{print $1}')"
[ "$actual" = "$tested" ] || { echo "$(basename "$dmg") differs from the DMG that was verified" >&2; exit 1; }
printf '%s %s\n' "$actual" "$(basename "$dmg")" >> "tested/tested-${NIGHTLY_VARIANT}.sha256"
done
cat "tested/tested-${NIGHTLY_VARIANT}.sha256"
run: bash .publish-tooling/scripts/ci/nightly-steps/verify-final-dmg-artifact.sh

- name: Apple's checks of a pool-signed DMG and the app in it
if: needs.signer-dmg.result == 'success'
Expand Down Expand Up @@ -5308,11 +5288,11 @@ jobs:

# nightly-next on the release runner pool, off unless the sign_pool input or
# vars.CI_NIGHTLY_NEXT_SIGN_POOL turns it on: signer-app signs the app
# (the Computer Use helper notarized and stapled first) and notarizes it,
# signer-dmg-image runs Apple's checks and packages the DMG on a Mac (the
# pool's one Mac job), and signer-dmg signs, notarizes and staples the DMG,
# writes the appcast and hands them on. The verify jobs check them on a Mac
# before publish; build-sign-notarize-nightly signs whenever signer-dmg did not pass.
# (the Computer Use helper notarized and stapled first), signer-app-notary
# notarizes it, signer-dmg-image staples it, checks it and packages the DMG on
# a Mac, and signer-dmg signs, notarizes and staples the DMG, writes the appcast
# and hands them on; verify-final-dmg-nightly checks them before publish.
# build-sign-notarize-nightly signs whenever signer-dmg did not pass.
signer-build:
needs: [decide]
if: needs.decide.outputs.track == 'nightly-next' && (inputs.sign_pool || vars.CI_NIGHTLY_NEXT_SIGN_POOL == '1') && vars.CMUX_NEXT_CEF_ON_DEMAND != '1' && needs.decide.outputs.should_build == 'true' && (github.event_name != 'schedule' || github.event.schedule == '47 8 * * *') && needs.decide.outputs.build_only != 'true' && needs.decide.outputs.continue_only != 'true' && needs.decide.outputs.fast_build != 'true' && needs.decide.outputs.notary_paused != 'true' && needs.decide.outputs.notary_test != 'true' && needs.decide.outputs.notary_probe != 'true' && needs.decide.outputs.variants == '["arm64"]' && inputs.nightly_next_unsigned_run == ''
Expand Down Expand Up @@ -5435,34 +5415,60 @@ jobs:
ASC_API_KEY_P8_BASE64: ${{ secrets.ASC_API_KEY_P8_BASE64 }}
ENTITLEMENTS: ${{ needs.decide.outputs.entitlements }}
run: bash .publish-tooling/scripts/ci/release-signer/sign-app.sh "${{ steps.prepare.outputs.app }}" "$ENTITLEMENTS"
- name: Notarize and staple the app
id: notarize
env:
NOTARY_MAX_WAIT_SECONDS: "1200"
ASC_API_KEY_ID: ${{ secrets.ASC_API_KEY_ID }}
ASC_API_ISSUER_ID: ${{ secrets.ASC_API_ISSUER_ID }}
ASC_API_KEY_P8_BASE64: ${{ secrets.ASC_API_KEY_P8_BASE64 }}
run: bash .publish-tooling/scripts/ci/release-signer/notarize-app.sh "${{ steps.prepare.outputs.app }}" "$RUNNER_TEMP/notary-app.log" >> "$GITHUB_OUTPUT"
- name: Pack the stapled app
# Unstapled: signer-app-notary notarizes it while signer-dmg-image checks it and staples.
- name: Pack the signed app
id: pack
env:
APP_SUBMISSION: ${{ steps.notarize.outputs.submission_id }}
run: bash .publish-tooling/scripts/ci/nightly-steps/signer-app-pack.sh
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: cmux-nightly-next-signer-app-${{ needs.resolve-nightly-cmux-tui-client.outputs.build_short_sha }}
path: signer-out/stapled-app.tar
path: signer-out/signed-app.tar
# Deflated: the tar is 794 MB stored and 323 MB compressed, and signer-dmg-image reads it
# on an office Mac whose shared uplink moved 2.0-3.6 MB/s (222-396 s stored).
compression-level: 6
if-no-files-found: error
retention-days: 1
overwrite: true

signer-app-notary:
environment: ${{ needs.decide.outputs.environment }}
needs: [decide, resolve-nightly-cmux-tui-client, signer-build, signer-app]
runs-on: ${{ github.repository_owner != 'manaflow-ai' && 'ubuntu-24.04' || 'blacksmith-32vcpu-ubuntu-2404' }}
timeout-minutes: 40
permissions:
contents: read
outputs:
submission_id: ${{ steps.notarize.outputs.submission_id }}
env:
SIGNER_WORK: ${{ github.workspace }}/signer-work
CHANNEL_APP_NAME: ${{ needs.decide.outputs.app_name }}
steps:
- *signer-checkout-tools
- *signer-install
- *signer-install-check
- name: Download the signed app
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
name: cmux-nightly-next-signer-app-${{ needs.resolve-nightly-cmux-tui-client.outputs.build_short_sha }}
path: signer-app
- &signer-unpack-app
name: Unpack the signed app
env:
APP_SHA256: ${{ needs.signer-app.outputs.sha256 }}
run: bash .publish-tooling/scripts/ci/nightly-steps/signer-unpack-app.sh
- name: Notarize the app
id: notarize
env:
NOTARY_MAX_WAIT_SECONDS: "1200"
ASC_API_KEY_ID: ${{ secrets.ASC_API_KEY_ID }}
ASC_API_ISSUER_ID: ${{ secrets.ASC_API_ISSUER_ID }}
ASC_API_KEY_P8_BASE64: ${{ secrets.ASC_API_KEY_P8_BASE64 }}
run: bash .publish-tooling/scripts/ci/release-signer/notarize-app.sh "$SIGNER_WORK/$CHANNEL_APP_NAME.app" "$RUNNER_TEMP/notary-app.log" >> "$GITHUB_OUTPUT"

signer-dmg-image:
needs: [decide, build-nightly-app, resolve-nightly-cmux-tui-client, pick-nightly-sign-runner, signer-app]
runs-on: ${{ github.repository_owner != 'manaflow-ai' && 'macos-26' || needs.pick-nightly-sign-runner.outputs.attempt == github.run_attempt && needs.pick-nightly-sign-runner.outputs.owned || github.run_attempt > 1 && needs.pick-nightly-sign-runner.outputs.alternate || needs.pick-nightly-sign-runner.outputs.runner || vars.MACOS_RUNNER_26 || 'blacksmith-6vcpu-macos-26' }}
timeout-minutes: 30
timeout-minutes: 45
permissions:
contents: read
outputs:
Expand All @@ -5489,7 +5495,7 @@ jobs:
# 40809822736) failed the job and sent the build to the macOS signer, about 8 min later to
# the feed: 5 min, then one retry. The next step checks the tar against signer-app's digest.
- &signer-download-app
name: Download the stapled app
name: Download the signed app
id: signer-download-app
continue-on-error: true
timeout-minutes: 5
Expand All @@ -5498,26 +5504,16 @@ jobs:
name: cmux-nightly-next-signer-app-${{ needs.resolve-nightly-cmux-tui-client.outputs.build_short_sha }}
path: signer-app
- &signer-download-app-retry
name: Download the stapled app (retry)
name: Download the signed app (retry)
if: steps.signer-download-app.outcome == 'failure'
timeout-minutes: 5
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
name: cmux-nightly-next-signer-app-${{ needs.resolve-nightly-cmux-tui-client.outputs.build_short_sha }}
path: signer-app
- name: Apple's checks of the stapled app
env:
APP_SHA256: ${{ needs.signer-app.outputs.sha256 }}
run: |
set -euo pipefail
echo "$APP_SHA256 signer-app/stapled-app.tar" | shasum -a 256 -c -
mkdir -p "$SIGNER_WORK" && tar -C "$SIGNER_WORK" -xf signer-app/stapled-app.tar
bash .publish-tooling/scripts/ci/nightly-steps/signer-apple-checks.sh "$SIGNER_WORK/$CHANNEL_APP_NAME.app"
# The checks of the stapled app run on copies in the background while the DMG is built and
# sent, and the job fails after the upload when one fails, so signer-dmg never reads that DMG.
# They include verify-signed-nightly's checks: a pool-signed build has no second download of
# the app to another office Mac (2-5 min in runs 40905688542, 40913618519, 40918131595), and
# verify-signed-nightly runs only for the macOS signer's app.
- *signer-unpack-app
# The signed-app and verify-signed-nightly checks run on copies in the background while
# Apple notarizes and the DMG is built and sent; the job fails after the upload on a failure.
- name: Start the signed-app checks
env:
CHECK_MINOS: "true"
Expand All @@ -5533,6 +5529,10 @@ jobs:
CHANNEL_ENTITLEMENTS: ${{ needs.decide.outputs.entitlements }}
TRACK: ${{ needs.decide.outputs.track }}
run: bash .publish-tooling/scripts/ci/nightly-steps/signer-verify-signed.sh start "$SIGNER_WORK/$CHANNEL_APP_NAME.app"
- name: Staple the app's notarization ticket
run: bash .publish-tooling/scripts/ci/nightly-steps/signer-staple-app.sh "$SIGNER_WORK/$CHANNEL_APP_NAME.app"
- name: Apple's checks of the stapled app
run: bash .publish-tooling/scripts/ci/nightly-steps/signer-apple-checks.sh "$SIGNER_WORK/$CHANNEL_APP_NAME.app"
- name: Build the unsigned DMG
id: dmg
run: bash .publish-tooling/scripts/ci/nightly-steps/signer-dmg-image.sh
Expand All @@ -5554,7 +5554,7 @@ jobs:

signer-dmg:
environment: ${{ needs.decide.outputs.environment }}
needs: [decide, build-nightly-app, resolve-nightly-cmux-tui-client, signer-build, signer-app, signer-dmg-image]
needs: [decide, build-nightly-app, resolve-nightly-cmux-tui-client, signer-build, signer-app, signer-app-notary, signer-dmg-image]
runs-on: ${{ github.repository_owner != 'manaflow-ai' && 'ubuntu-24.04' || 'blacksmith-32vcpu-ubuntu-2404' }}
timeout-minutes: 40
permissions:
Expand Down Expand Up @@ -5604,7 +5604,7 @@ jobs:
SPARKLE_CHANNEL: ${{ vars.NIGHTLY_NEXT_DEV_RING == 'on' && 'cmux-next-dev' || 'cmux-next' }}
NEXT_SPARKLE_PRIVATE_KEY: ${{ secrets.SPARKLE_NEXT_PRIVATE_KEY }}
run: |
echo "$APP_SHA256 signer-app/stapled-app.tar" | sha256sum -c -
echo "$APP_SHA256 signer-app/signed-app.tar" | sha256sum -c -
bash .publish-tooling/scripts/ci/nightly-steps/signer-appcast.sh
# Hand it on under the names the macOS signer job uses: the verify jobs
# check it on a Mac before publish reads it. Never overwrite: once the
Expand Down
9 changes: 5 additions & 4 deletions scripts/ci/nightly-steps/signer-app-pack.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/usr/bin/env bash
# nightly.yml signer-app: "Pack the stapled app" for the Mac DMG job.
# nightly.yml signer-app: "Pack the signed app" for signer-app-notary (Apple's notarization) and
# the Mac DMG job (signer-dmg-image), which staples the ticket once Apple has accepted these bytes.
set -euo pipefail
: "${SIGNER_WORK:?}" "${CHANNEL_APP_NAME:?}"
mkdir -p signer-out
tar -C "$SIGNER_WORK" -cf signer-out/stapled-app.tar "$CHANNEL_APP_NAME.app"
sha="$(sha256sum signer-out/stapled-app.tar | cut -d' ' -f1)"
tar -C "$SIGNER_WORK" -cf signer-out/signed-app.tar "$CHANNEL_APP_NAME.app"
sha="$(sha256sum signer-out/signed-app.tar | cut -d' ' -f1)"
echo "sha256=$sha" >> "$GITHUB_OUTPUT"
echo "Stapled app tar sha256: $sha (app submission $APP_SUBMISSION)" >> "$GITHUB_STEP_SUMMARY"
echo "Signed app tar sha256: $sha" >> "$GITHUB_STEP_SUMMARY"
4 changes: 2 additions & 2 deletions scripts/ci/nightly-steps/signer-appcast.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# nightly.yml signer-dmg: "Write the appcast". The item
# scripts/sparkle_generate_appcast.sh writes for the immutable DMG alone, from
# the stapled app's Info.plist (scripts/ci/tip_appcast_linux.py: the same
# the signed app's Info.plist (stapling adds only the ticket) (scripts/ci/tip_appcast_linux.py: the same
# deterministic Ed25519 signature as Sparkle's sign_update), then the macOS
# floor and the ring tag. The signature is then checked again against the
# pinned NIGHTLY_NEXT_SPARKLE_PUBLIC_KEY, not the key that made it.
Expand All @@ -10,7 +10,7 @@ set -euo pipefail
appcast="signer-out/appcast-${NIGHTLY_VARIANT}.xml"
dmg="signer-out/$NIGHTLY_DMG_IMMUTABLE"
plist_dir="$(mktemp -d "$RUNNER_TEMP/plist.XXXXXX")"
tar -C "$plist_dir" -xf signer-app/stapled-app.tar "$CHANNEL_APP_NAME.app/Contents/Info.plist"
tar -C "$plist_dir" -xf signer-app/signed-app.tar "$CHANNEL_APP_NAME.app/Contents/Info.plist"
(cd "$plist_dir" && python3 -I -m zipfile -c "$RUNNER_TEMP/plist.zip" "$CHANNEL_APP_NAME.app")
SPARKLE_PRIVATE_KEY="$(bash "$TOOLS/scripts/ci/nightly-sparkle-key.sh")"
export SPARKLE_PRIVATE_KEY
Expand Down
42 changes: 42 additions & 0 deletions scripts/ci/nightly-steps/signer-staple-app.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash
# nightly.yml signer-dmg-image: "Staple the app's notarization ticket", on the Mac, with Apple's
# stapler and no secret.
#
# signer-staple-app.sh <app>
#
# signer-app-notary submits the app signer-app signed (the bytes of the tar whose digest this job
# checked) to Apple at the same time as this job downloads and checks it, so the DMG Mac no longer
# waits for Apple before its download starts. Apple's ticket is published under the app's CDHash
# once Apple accepts the submission; until then `stapler staple` finds no ticket. This asks Apple
# for it every STAPLE_RETRY_SECONDS (default 10) up to STAPLE_MAX_WAIT_SECONDS (default 1500:
# signer-app-notary waits up to 1200 s after its upload), then `stapler validate` checks the
# staple. A submission Apple rejects never gets a ticket, so this fails at the deadline (and
# signer-app-notary fails first). The bundle changes only by the ticket stapler writes.
set -euo pipefail
app="${1:?usage: signer-staple-app.sh <app>}"
app="${app%/}"
[[ -d "$app/Contents" ]] || { echo "no app at $app" >&2; exit 1; }
xcrun="${XCRUN_TOOL:-xcrun}"
max_wait="${STAPLE_MAX_WAIT_SECONDS:-1500}"
retry="${STAPLE_RETRY_SECONDS:-10}"
[[ "$max_wait" =~ ^[0-9]+$ && "$retry" =~ ^[1-9][0-9]*$ ]] || { echo "STAPLE_MAX_WAIT_SECONDS and STAPLE_RETRY_SECONDS must be whole seconds" >&2; exit 2; }
started=$SECONDS
attempt=0
while :; do
attempt=$((attempt + 1))
if out="$("$xcrun" stapler staple "$app" 2>&1)"; then
echo "$out"
break
fi
waited=$((SECONDS - started))
if (( waited + retry > max_wait )); then
echo "$out" >&2
echo "error: no notarization ticket for ${app##*/} after ${waited} s ($attempt attempts); Apple has not accepted signer-app-notary's submission" >&2
exit 1
fi
# Each attempt's own output stays in the log, so a failure other than "no ticket yet" shows.
echo "attempt $attempt after ${waited} s: no ticket yet ($(tail -n 1 <<<"$out"))"
sleep "$retry"
done
"$xcrun" stapler validate "$app"
echo "stapled ${app##*/} after $((SECONDS - started)) s ($attempt attempts)" | tee -a "${GITHUB_STEP_SUMMARY:-/dev/null}"
10 changes: 10 additions & 0 deletions scripts/ci/nightly-steps/signer-unpack-app.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
# nightly.yml signer-app-notary and signer-dmg-image: "Unpack the signed app". Checks
# signer-app/signed-app.tar against the digest signer-app printed (APP_SHA256), then unpacks it
# into SIGNER_WORK, so Apple notarizes and the Mac staples the same bytes.
set -euo pipefail
: "${APP_SHA256:?}" "${SIGNER_WORK:?}"
if command -v sha256sum >/dev/null 2>&1; then sum=(sha256sum); else sum=(shasum -a 256); fi
echo "$APP_SHA256 signer-app/signed-app.tar" | "${sum[@]}" -c -
mkdir -p "$SIGNER_WORK"
tar -C "$SIGNER_WORK" -xf signer-app/signed-app.tar
Loading
Loading