Files
skylar taylor-barrick 88b71cb141 Add the Apple-silicon Nightly build (#16559)
* Finish the Nightly session in the app's exit hook

On macOS every quit (Cmd+Q, the close button, File > Quit, app.quit) leaves
through craft::quit, which sends -[NSApplication terminate:]. winit's
applicationWillTerminate: delivers LoopExiting, eframe runs the app's
on_exit, and AppKit then ends the process, so eframe::run_native never
returns there and the controlled-return code after it (the Nightly
session finish) never ran: every Mac Nightly start reported the previous
session as unclean.

Services gets an at_exit hook that on_exit runs once, last. The desktop
app finishes the shared Nightly session there, and again after run_native
for the paths that create no window (renderer failure), where the second
call is a no-op.

* Add the Apple-silicon Nightly build, signing and verification scripts

packaging/macos/nightly.sh compiles the GUI-only PhotoCraft Nightly.app
for aarch64 with no signing material (it refuses any) and writes the
unsigned photocraft-<version>-macos-aarch64-nightly.zip: the nightly-common
source and identity checks, nightly_plist.py's Info.plist, the Nightly icon
and notices, no CLI, DMG or document types, zipped without xattrs. It no
longer runs the bundle before signing.

packaging/macos/nightly-sign.sh is the trusted step the shared signer calls
(--arch aarch64 --input <unsigned zip> --output <final zip>). It requires
all six release secrets, imports the Developer ID with import-cert.sh into
a private keychain it deletes on exit, signs inside-out with the hardened
runtime, timestamp and entitlements, notarizes with notarytool, staples the
ticket into the bundle, and checks the final archive as the Launcher
unpacks it (signature, team, ticket, Gatekeeper) before writing it without
replacing anything. It never compiles or runs the payload.

packaging/macos/nightly-verify.sh runs in a job without secrets (it refuses
any): the same archive checks, then the bundle's --version with an empty
environment, for the signed feed artifact or the unsigned compile output.

nightly-common.sh splits the compile from the version query; Linux keeps
both. The new suite runs the scripts against stand-in Apple tools.

* Build the unsigned macOS Nightly in pull-request CI

A hosted macos-15 job, with no secrets or environment, builds the
aarch64 Nightly bundle with packaging/macos/nightly.sh when a pull
request changes the Mac Nightly packaging or flavor, and checks it with
nightly-verify.sh --expect unsigned, including the bundle's version.

* Cap the failure-only notarization log in nightly-sign.sh

The shared signer bounds a step's output at 256 KiB; notarytool's log on a
rejected submission is the one large output, now cut at 128 KiB.

* Address review: macOS-only exit hook, clean-tree recheck, wider refusals

- The Nightly exit hook is installed only on macOS; Linux and Windows keep
  finishing the session after run_native returns.
- nightly_build_gui checks the tree is still clean after --version (Linux).
- nightly_refuse_signing_env also refuses the Windows, Azure and Linux
  signing names release.yml passes.
- nightly-sign.sh drops the single spctl run before the retried final check.
- nightly-macos.yml also runs for Cargo.toml, Cargo.lock and the text and
  ui-egui build scripts.

* List the macOS Nightly signing tests as tests for Sonar

packaging/macos/nightly_sign_tests.py is a fixture runner like the other
nightly suites; without this Sonar counts it as production code.

* Run the macOS Nightly PR build only with the full-ci label

macOS runners are shared with release builds: no path filters, and a pull
request runs the job only when it carries full-ci (a labeled event only
when the added label is full-ci). ci.yml's concurrency pattern keeps other
labels from running or cancelling a run. workflow_dispatch stays.

* Keep the unsigned macOS Nightly archive as a short-lived artifact

Seven-day retention, unsigned zip only, no secrets. It lets keyless signer tests and hand
testing use the exact verified build.

* Keep unlabelled events out of the macOS build's concurrency group

A push to a full-ci PR and the label event arrive together; the event that would be skipped
was sharing the group and cancelling the real build.

* Stop the macOS Nightly scripts' --help at their header comment

* Answer the Launcher's profile-form version query before startup (#16559)

`PhotoCraft --launch-profile nightly-v1 --profile-root <dir> --version`,
the shared producer's smoke, was refused by the strict launch-profile
parser (no `--`), and the refusal opens a native dialog on macOS, which
never returns on a headless runner: the hosted run did not exit in 180 s.

A Nightly build now treats exactly the selector/root pair followed by
`--version` or `-V` as a version query: the same line as plain
`--version`, exit 0, before root validation, process identity, IPC or any
window. Only parse()'s lexical checks apply; every other refusal is
unchanged and `-- --version` stays a file name.

nightly-verify.sh checks both forms, each within 15 seconds and with
nothing on standard error, so the PR's Mac build covers the smoke.

* Harden the Mac Nightly signing helpers (review of #16559)

- nightly_publish_archive runs python3 -I: nightly-sign.sh calls it with
  the signing secrets loaded, so no module from the working directory or
  user site may be imported.
- nightly-sign.sh and nightly-verify.sh list the archive's entries before
  unpacking (python3 -I, zipfile) and refuse absolute paths, `..`, empty
  or backslash components, entries outside PhotoCraft Nightly.app, links
  and special files. The check after unpacking stays.
- The signature check matches the Identifier line literally (grep -F).
2026-11-23 17:28:21 -06:00

52 lines
2.7 KiB
Bash
Executable File

#!/usr/bin/env bash
# App-owned GUI-only Nightly for Apple silicon, compile step only (no signing material):
#
# $DIST/photocraft-<version>-macos-aarch64-nightly.zip PhotoCraft Nightly.app, unsigned
#
# Usage: packaging/macos/nightly.sh --arch aarch64
#
# Required env (nightly-common.sh): PHOTOCRAFT_BUILD_CHANNEL=nightly-v1, PHOTOCRAFT_VERSION,
# PHOTOCRAFT_BUILD_SHA, PHOTOCRAFT_BUILD_DATE, absolute CARGO_TARGET_DIR and DIST; CRAFT_FONTS_DIR optional.
#
# Not publishable by itself: the trusted step (nightly-sign.sh) signs, notarizes and staples it. No CLI,
# DMG, document or URL types, and no stable package.sh. The bundle is not run here; the version query
# runs on the signed bundle (nightly-verify.sh).
set -euo pipefail
ARCH=
while [[ $# -gt 0 ]]; do
case "$1" in
--arch) [[ $# -ge 2 ]] || { echo 'missing --arch value' >&2; exit 2; }; ARCH="$2"; shift 2 ;;
-h|--help) sed -n '2,13p' "$0"; exit 0 ;;
*) echo "unsupported nightly argument: $1" >&2; exit 2 ;;
esac
done
[[ "$ARCH" == aarch64 && "$(uname -s)" == Darwin && "$(uname -m)" == arm64 ]] || { echo 'only native macOS aarch64 nightly packaging is supported' >&2; exit 2; }
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
. "$HERE/../nightly-common.sh"
. "$HERE/nightly-lib.sh"
nightly_refuse_signing_env
nightly_init macos "$ARCH" aarch64-apple-darwin
# Keep in sync with LSMinimumSystemVersion in Info.plist.in (as package.sh).
export MACOSX_DEPLOYMENT_TARGET=11.0
OUTPUT="$DIST/photocraft-$VERSION-macos-aarch64-nightly.zip"
[[ ! -e "$OUTPUT" && ! -L "$OUTPUT" ]] || nightly_die 'refusing to replace an existing nightly archive'
nightly_compile_gui
APP="$NIGHTLY_WORK/stage/$MAC_NIGHTLY_APP"
mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources"
cp "$NIGHTLY_GUI" "$APP/Contents/MacOS/PhotoCraft"
chmod 755 "$APP/Contents/MacOS/PhotoCraft"
cp "$ROOT/assets/app-icon/photocraft-nightly.icns" "$APP/Contents/Resources/photocraft-nightly.icns"
nightly_copy_notices "$APP/Contents/Resources"
# The private mktemp cwd is the helper authority root: stage the template inside it.
cp "$HERE/Info.plist.in" "$NIGHTLY_WORK/Info.plist.in"
(cd "$NIGHTLY_WORK" && python3 "$HERE/nightly_plist.py" --template Info.plist.in \
--output "stage/$MAC_NIGHTLY_APP/Contents/Info.plist" --version "$VERSION" --source-commit "$PHOTOCRAFT_BUILD_SHA")
plutil -lint "$APP/Contents/Info.plist"
printf 'APPL????' >"$APP/Contents/PkgInfo"
mac_nightly_check_bundle "$NIGHTLY_WORK/stage" "$VERSION"
# No resource forks, extended attributes or ACLs: the Launcher restores none, so nothing may depend on them.
ditto -c -k --norsrc --noextattr --noacl --keepParent "$APP" "$NIGHTLY_WORK/archive.zip"
nightly_publish_archive "$NIGHTLY_WORK/archive.zip" "$OUTPUT"