diff --git a/ROADMAP.md b/ROADMAP.md index 34bafc7..c1f6364 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -1,6 +1,6 @@ # Roadmap -> **Last reviewed:** 2026-10-17 · **Last updated:** 2026-10-17 · **Change list:** minor (fix: resource-calendar late start before start, #124) · **Target:** Microsoft Project (desktop) +> **Last reviewed:** 2026-11-21 · **Last updated:** 2026-11-21 · **Change list:** minor (macOS .app, .dmg, and CLI bundle packaging scripts, #140) · **Target:** Microsoft Project (desktop) ProjectCraft aims for parity with Microsoft Project's scheduling, as its documentation describes it. Each roadmap milestone has a pass/fail checklist; it is reached when every item passes. @@ -144,6 +144,7 @@ Import gaps, until later work closes them (each is a line in the import report): | 2026-10-17 | M2 reached: every item on its checklist passes, levelling (the stretch) included; 11 / 11 tickets | | 2026-10-17 | M4: As Late As Possible constraint: `task.setConstraint` type `ALAP` (no date), saved in the project file as `"ALAP"` (files without it load as before). The scheduler holds such a task at its late start, as Microsoft's definition has it (ES = calculated LS): as late as it can without delaying its successors, its deadline or the project finish; its successors follow it and lose their slack too, and summaries roll up where it ends up. A subtask is also held to the start its summary's start-to-start and start-to-finish successors allow, the holds are worked out again when moving a subtask changes its summary's span (a few rounds at most), and holds that would still make the project finish later give way (the plan is then scheduled as soon as possible). Plans without it make the same single pass each way. Microsoft Project XML (`ConstraintType` 1) and CSV (`As Late As Possible` or `ALAP`) import it exactly, the Converted report line gone, and Microsoft Project XML export writes it; the orchard parity fixture's As Late As Possible task now matches (its successor's hand-worked dates corrected to follow it, and a task added to set the finish so the branch doesn't run on from another conversion). Worked examples with links, a lag, a start-to-start link, a chain, a milestone, a deadline, a summary and a resource calendar; a property test that it never finishes the project later or moves a task earlier (#122) | | 2026-10-17 | Fix: a task or milestone with no slack never shows a late start before its start when a resource works outside the project calendar's time. Slack counts on the project calendar, so a late start earlier only by time outside it (a Saturday morning one resource works) is no slack: the late start is then the start, and the late finish never before the finish; before, a summary over a milestone could show a Friday late start beside a Monday start, and a task on that resource's calendar a Saturday one. Plans on the project calendar alone schedule as before. Found by the resource-calendar property test; worked-example regression tests, the shrunk case kept (#124) | +| 2026-11-21 | M6: macOS `.app`, `.dmg`, and CLI `.zip` packaging scripts (`packaging/env.sh`, `packaging/macos/*`, bundled `licenses/egui-default-fonts/`) (#140) | ## Revision history | Date | Change | Summary | @@ -192,3 +193,4 @@ Import gaps, until later work closes them (each is a line in the import report): | 2026-10-17 | minor | M2 reached | | 2026-10-17 | minor | As Late As Possible constraint (#122); M4 import gap closed | | 2026-10-17 | minor | Fix: resource-calendar late start before start (#124) | +| 2026-11-21 | minor | macOS packaging scripts (`packaging/macos/`) (#140) | diff --git a/docs/releasing.md b/docs/releasing.md index c5ec77a..e35f46d 100644 --- a/docs/releasing.md +++ b/docs/releasing.md @@ -1,11 +1,14 @@ # Releasing ProjectCraft -> **Last reviewed:** 2026-10-16 · **Last updated:** 2026-10-16 · **Change:** major (first version) · **Status:** no release workflow exists yet; nothing has been released. +> **Last reviewed:** 2026-11-21 · **Last updated:** 2026-11-21 · **Change:** minor (document macOS packaging scripts in `packaging/macos/`) · **Status:** macOS packaging scripts added; no release workflow or published builds yet. -ProjectCraft has no release workflow, no packaging and no signing yet. There are no published -builds: build from source (`README.md`). This file holds the rules the release workflow must -follow when it is written, so that it starts out safe rather than being made safe later. A -release workflow that breaks one of them is a security bug. +ProjectCraft has no release workflow or published builds yet: build from source (`README.md`) or run the macOS packaging scripts (`packaging/macos/package.sh`). This file holds the rules the release workflow must follow when it is written, so that it starts out safe rather than being made safe later. A release workflow that breaks one of them is a security bug. + +## macOS packaging (`packaging/macos/`) + +- `packaging/env.sh` resolves workspace metadata (`VERSION`, `APP_ID`, `DIST`, `CARGO_TARGET_DIR`) and copies legal/licence files (`LICENSE-MIT`, `LICENSE-APACHE`, `ATTRIBUTION.md`, `NOTICE`, bundled `licenses/egui-default-fonts/`, and optional `CRAFT_FONTS_DIR` `OFL.txt` files). +- `packaging/macos/package.sh [--arch universal|aarch64|x86_64] [--skip-build | --build-only] [--no-run]` builds `projectcraft` and `projectcraft-cli`, combines universal slices with `lipo`, renders `packaging/macos/Info.plist.in`, signs inside-out with `packaging/macos/entitlements.plist` (falling back to ad-hoc `-` locally when `MACOS_SIGN_IDENTITY` is unset, and failing closed in GitHub Actions unless `MACOS_ALLOW_ADHOC=1`), builds `$DIST/projectcraft--macos-.dmg` and `$DIST/projectcraft-cli--macos-.zip` with `.sha256` sidecars, notarizes/staples the `.app` and `.dmg` when `MACOS_NOTARY_PROFILE` (or `APPLE_ID`, `APPLE_PASSWORD`, `APPLE_TEAM_ID`) is set (failing closed in GitHub Actions on incomplete notarization credentials unless `MACOS_ALLOW_UNNOTARIZED=1`; prefer `MACOS_NOTARY_PROFILE` on shared machines because `APPLE_PASSWORD` is passed via CLI argv), notarizes the CLI `.zip` for online Gatekeeper verification (`xcrun stapler` only supports bundles/DMGs/pkgs), and smoke-tests the packaged CLI on matching host architectures. +- `packaging/macos/import-cert.sh` imports `APPLE_CERTIFICATE` into a temporary keychain for CI signing and fails closed in GitHub Actions unless `MACOS_ALLOW_ADHOC=1`. The general recipe for a Craft app is [craftrules `release/playbook.md`](https://github.com/storytold/craftrules/blob/main/release/playbook.md). @@ -48,3 +51,4 @@ These are settings, not files, so the workflow can't set them: | Date | Change | Summary | |---|---|---| | 2026-10-16 | major | First version: no release workflow yet; the rules it must follow | +| 2026-11-21 | minor | Document macOS `.app`, `.dmg`, and CLI packaging scripts (`packaging/macos/`) | diff --git a/licenses/egui-default-fonts/Hack-Regular.txt b/licenses/egui-default-fonts/Hack-Regular.txt new file mode 100644 index 0000000..b0ec744 --- /dev/null +++ b/licenses/egui-default-fonts/Hack-Regular.txt @@ -0,0 +1,31 @@ +The work in the Hack project is Copyright 2018 Source Foundry Authors and licensed under the MIT License + +The work in the DejaVu project was committed to the public domain. + +Bitstream Vera Sans Mono Copyright 2003 Bitstream Inc. and licensed under the Bitstream Vera License with Reserved Font Names "Bitstream" and "Vera" +MIT License + +Copyright (c) 2018 Source Foundry Authors + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +BITSTREAM VERA LICENSE + +Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is a trademark of Bitstream, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy of the fonts accompanying this license ("Fonts") and associated documentation files (the "Font Software"), to reproduce and distribute the Font Software, including without limitation the rights to use, copy, merge, publish, distribute, and/or sell copies of the Font Software, and to permit persons to whom the Font Software is furnished to do so, subject to the following conditions: + +The above copyright and trademark notices and this permission notice shall be included in all copies of one or more of the Font Software typefaces. + +The Font Software may be modified, altered, or added to, and in particular the designs of glyphs or characters in the Fonts may be modified and additional glyphs or characters may be added to the Fonts, only if the fonts are renamed to names not containing either the words "Bitstream" or the word "Vera". + +This License becomes null and void to the extent applicable to Fonts or Font Software that has been modified and is distributed under the "Bitstream Vera" names. + +The Font Software may be sold as part of a larger software package but no copy of one or more of the Font Software typefaces may be sold by itself. + +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE. + +Except as contained in this notice, the names of Gnome, the Gnome Foundation, and Bitstream Inc., shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Font Software without prior written authorization from the Gnome Foundation or Bitstream Inc., respectively. For further information, contact: fonts at gnome dot org. diff --git a/licenses/egui-default-fonts/NOTICES.txt b/licenses/egui-default-fonts/NOTICES.txt new file mode 100644 index 0000000..3e4fb0a --- /dev/null +++ b/licenses/egui-default-fonts/NOTICES.txt @@ -0,0 +1,19 @@ +Bundled egui default fonts (epaint_default_fonts 0.36.2): + +- NotoEmoji-Regular.ttf + Copyright 2013 Google Inc. All Rights Reserved. + Licensed under the SIL Open Font License, Version 1.1 (OFL.txt; http://scripts.sil.org/OFL). + +- Ubuntu-Light.ttf + Copyright 2011 Canonical Ltd. + Licensed under the Ubuntu Font Licence 1.0 (UFL.txt). + +- Hack-Regular.ttf + Copyright (c) 2018 Source Foundry Authors (MIT License); + DejaVu project (public domain); + Bitstream Vera Sans Mono Copyright (c) 2003 Bitstream, Inc. All Rights Reserved. + See Hack-Regular.txt. + +- emoji-icon-font.ttf + Copyright (c) 2014 John Slegers. + Licensed under the MIT License (emoji-icon-font-mit-license.txt). diff --git a/licenses/egui-default-fonts/OFL.txt b/licenses/egui-default-fonts/OFL.txt new file mode 100644 index 0000000..d952d62 --- /dev/null +++ b/licenses/egui-default-fonts/OFL.txt @@ -0,0 +1,92 @@ +This Font Software is licensed under the SIL Open Font License, +Version 1.1. + +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font +creation efforts of academic and linguistic communities, and to +provide a free and open framework in which fonts may be shared and +improved in partnership with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply to +any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software +components as distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, +deleting, or substituting -- in part or in whole -- any of the +components of the Original Version, by changing formats or by porting +the Font Software to a new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, +modify, redistribute, and sell modified and unmodified copies of the +Font Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, in +Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the +corresponding Copyright Holder. This restriction only applies to the +primary font name as presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created using +the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/licenses/egui-default-fonts/UFL.txt b/licenses/egui-default-fonts/UFL.txt new file mode 100644 index 0000000..ae78a8f --- /dev/null +++ b/licenses/egui-default-fonts/UFL.txt @@ -0,0 +1,96 @@ +------------------------------- +UBUNTU FONT LICENCE Version 1.0 +------------------------------- + +PREAMBLE +This licence allows the licensed fonts to be used, studied, modified and +redistributed freely. The fonts, including any derivative works, can be +bundled, embedded, and redistributed provided the terms of this licence +are met. The fonts and derivatives, however, cannot be released under +any other licence. The requirement for fonts to remain under this +licence does not require any document created using the fonts or their +derivatives to be published under this licence, as long as the primary +purpose of the document is not to be a vehicle for the distribution of +the fonts. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this licence and clearly marked as such. This may +include source files, build scripts and documentation. + +"Original Version" refers to the collection of Font Software components +as received under this licence. + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to +a new environment. + +"Copyright Holder(s)" refers to all individuals and companies who have a +copyright ownership of the Font Software. + +"Substantially Changed" refers to Modified Versions which can be easily +identified as dissimilar to the Font Software by users of the Font +Software comparing the Original Version with the Modified Version. + +To "Propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification and with or without charging +a redistribution fee), making available to the public, and in some +countries other activities as well. + +PERMISSION & CONDITIONS +This licence does not grant any rights under trademark law and all such +rights are reserved. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of the Font Software, to propagate the Font Software, subject to +the below conditions: + +1) Each copy of the Font Software must contain the above copyright +notice and this licence. These can be included either as stand-alone +text files, human-readable headers or in the appropriate machine- +readable metadata fields within text or binary files as long as those +fields can be easily viewed by the user. + +2) The font name complies with the following: +(a) The Original Version must retain its name, unmodified. +(b) Modified Versions which are Substantially Changed must be renamed to +avoid use of the name of the Original Version or similar names entirely. +(c) Modified Versions which are not Substantially Changed must be +renamed to both (i) retain the name of the Original Version and (ii) add +additional naming elements to distinguish the Modified Version from the +Original Version. The name of such Modified Versions must be the name of +the Original Version, with "derivative X" where X represents the name of +the new work, appended to that name. + +3) The name(s) of the Copyright Holder(s) and any contributor to the +Font Software shall not be used to promote, endorse or advertise any +Modified Version, except (i) as required by this licence, (ii) to +acknowledge the contribution(s) of the Copyright Holder(s) or (iii) with +their explicit written permission. + +4) The Font Software, modified or unmodified, in part or in whole, must +be distributed entirely under this licence, and must not be distributed +under any other licence. The requirement for fonts to remain under this +licence does not affect any document created using the Font Software, +except any version of the Font Software extracted from a document +created using the Font Software may only be distributed under this +licence. + +TERMINATION +This licence becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF +COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER +DEALINGS IN THE FONT SOFTWARE. diff --git a/licenses/egui-default-fonts/emoji-icon-font-mit-license.txt b/licenses/egui-default-fonts/emoji-icon-font-mit-license.txt new file mode 100644 index 0000000..99016e1 --- /dev/null +++ b/licenses/egui-default-fonts/emoji-icon-font-mit-license.txt @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2014 John Slegers + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/packaging/env.sh b/packaging/env.sh new file mode 100755 index 0000000..058f4f8 --- /dev/null +++ b/packaging/env.sh @@ -0,0 +1,107 @@ +# shellcheck shell=bash +# Shared setup for the packaging scripts. Source it: `. "$(dirname "$0")/../env.sh"`. +# Adapted from MailCraft and FieldCraft packaging (MIT OR Apache-2.0). +# +# Exports: +# ROOT workspace root +# VERSION [workspace.package] version from Cargo.toml (override: PROJECTCRAFT_VERSION) +# DIST output directory for release artifacts (default: $ROOT/dist/release) +# PROJECTCRAFT_BUILD_SHA git commit recorded in the macOS Info.plist +# CARGO_TARGET_DIR absolute cargo target dir (default: $ROOT/target) +# APP_ID reverse-DNS macOS bundle identifier + +ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +export ROOT + +# Read [workspace.package] version from the root Cargo.toml, tolerating comments and whitespace. +workspace_version() { + awk ' + { + line = $0 + sub(/[[:space:]]*#.*/, "", line) + gsub(/^[[:space:]]+|[[:space:]]+$/, "", line) + } + line ~ /^\[/ { in_pkg = (line == "[workspace.package]"); next } + in_pkg && line ~ /^version[[:space:]]*=/ { + sub(/^version[[:space:]]*=[[:space:]]*/, "", line) + gsub(/^["'\'']|["'\'']$/, "", line) + print line + exit + } + ' "$ROOT/Cargo.toml" +} + +VERSION="${PROJECTCRAFT_VERSION:-$(workspace_version)}" +if [ -z "$VERSION" ]; then + echo "error: could not read [workspace.package] version from $ROOT/Cargo.toml" >&2 + exit 1 +fi +export VERSION + +DIST="${DIST:-$ROOT/dist/release}" +mkdir -p "$DIST" +DIST="$(cd "$DIST" && pwd)" +export DIST + +if [ -z "${PROJECTCRAFT_BUILD_SHA:-}" ]; then + PROJECTCRAFT_BUILD_SHA="$(git -C "$ROOT" rev-parse HEAD 2>/dev/null || echo unknown)" + if [ "$PROJECTCRAFT_BUILD_SHA" != "unknown" ] && ! git -C "$ROOT" diff-index --quiet HEAD -- 2>/dev/null; then + PROJECTCRAFT_BUILD_SHA="${PROJECTCRAFT_BUILD_SHA}-dirty" + fi +fi +export PROJECTCRAFT_BUILD_SHA + +# Resolve any relative CARGO_TARGET_DIR override against the caller's working directory +# before subshells cd into $ROOT for cargo build. +case "${CARGO_TARGET_DIR:-}" in + "") CARGO_TARGET_DIR="$ROOT/target" ;; + /*) ;; + *) CARGO_TARGET_DIR="$PWD/$CARGO_TARGET_DIR" ;; +esac +export CARGO_TARGET_DIR + +APP_ID="io.github.ucslabs.projectcraft" +export APP_ID + +# Emit a GitHub Actions warning (plain stderr outside Actions). +warn() { + if [ -n "${GITHUB_ACTIONS:-}" ]; then echo "::warning::$*"; else echo "warning: $*" >&2; fi +} + +# Copy repository licence and readme files into a package directory. +copy_docs() { + local dest="$1" f + for f in LICENSE-MIT LICENSE-APACHE ATTRIBUTION.md NOTICE; do + if [ ! -f "$ROOT/$f" ]; then + echo "error: required legal file $ROOT/$f is missing" >&2 + exit 1 + fi + cp "$ROOT/$f" "$dest/" + done + for f in README.md LICENSE COPYRIGHT THIRD-PARTY-LICENSES.txt; do + if [ -f "$ROOT/$f" ]; then cp "$ROOT/$f" "$dest/"; fi + done + copy_font_licences "$dest" +} + +# Copy bundled font licences (including optional CRAFT_FONTS_DIR embeds) into dest. +copy_font_licences() { + local dest="$1" f + mkdir -p "$dest/egui-default-fonts" + for f in Hack-Regular.txt NOTICES.txt OFL.txt UFL.txt emoji-icon-font-mit-license.txt; do + if [ ! -f "$ROOT/licenses/egui-default-fonts/$f" ]; then + echo "error: missing required egui default font licence $ROOT/licenses/egui-default-fonts/$f" >&2 + exit 1 + fi + cp "$ROOT/licenses/egui-default-fonts/$f" "$dest/egui-default-fonts/" + done + [ -n "${CRAFT_FONTS_DIR:-}" ] || return 0 + for f in "$CRAFT_FONTS_DIR"/fonts/*/OFL.txt; do + if [ -f "$f" ]; then cp "$f" "$dest/OFL-$(basename "$(dirname "$f")").txt"; fi + done +} + +# Portable SHA-256 checksum helper. +sha256() { + if command -v sha256sum >/dev/null; then sha256sum "$1" | cut -d' ' -f1; else shasum -a 256 "$1" | cut -d' ' -f1; fi +} diff --git a/packaging/macos/Info.plist.in b/packaging/macos/Info.plist.in new file mode 100644 index 0000000..2204e16 --- /dev/null +++ b/packaging/macos/Info.plist.in @@ -0,0 +1,47 @@ + + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + ProjectCraft + CFBundleName + ProjectCraft + CFBundleExecutable + ProjectCraft + CFBundleIdentifier + @APP_ID@ + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + APPL + CFBundleSignature + ???? + CFBundleShortVersionString + @SHORT_VERSION@ + CFBundleVersion + @SHORT_VERSION@ + ProjectCraftVersion + @VERSION@ + ProjectCraftBuildCommit + @BUILD_SHA@ + LSApplicationCategoryType + public.app-category.productivity + + LSMinimumSystemVersion + @MIN_MACOS@ + NSHighResolutionCapable + + NSSupportsAutomaticGraphicsSwitching + + NSRequiresAquaSystemAppearance + + NSHumanReadableCopyright + Copyright © ProjectCraft contributors. MIT OR Apache-2.0. + + + diff --git a/packaging/macos/entitlements.plist b/packaging/macos/entitlements.plist new file mode 100644 index 0000000..f3d0d45 --- /dev/null +++ b/packaging/macos/entitlements.plist @@ -0,0 +1,10 @@ + + + + + + + diff --git a/packaging/macos/import-cert.sh b/packaging/macos/import-cert.sh new file mode 100755 index 0000000..ad1b1c2 --- /dev/null +++ b/packaging/macos/import-cert.sh @@ -0,0 +1,78 @@ +#!/usr/bin/env bash +# CI only: import the Developer ID certificate into a temporary keychain for codesign. +# +# Inputs (env): APPLE_CERTIFICATE (base64 .p12), APPLE_CERTIFICATE_PASSWORD, KEYCHAIN_PASSWORD +# (optional; random if unset), RUNNER_TEMP (or TMPDIR). +# Outputs: MACOS_SIGN_IDENTITY (SHA-1) and MACOS_KEYCHAIN, appended to $GITHUB_ENV in Actions. +# +# Missing certificate: fails in GitHub Actions unless MACOS_ALLOW_ADHOC=1; locally warns and exits 0 so package.sh falls back to ad-hoc signing. +set -euo pipefail +umask 077 +# shellcheck source=../env.sh +. "$(dirname "${BASH_SOURCE[0]}")/../env.sh" + +if [ -z "${APPLE_CERTIFICATE:-}" ]; then + if [ -n "${GITHUB_ACTIONS:-}" ] && [ "${MACOS_ALLOW_ADHOC:-0}" != 1 ]; then + echo "error: APPLE_CERTIFICATE is not set; refusing to build an unsigned release" >&2 + exit 1 + fi + warn "APPLE_CERTIFICATE is not set: macOS builds will be ad-hoc signed and not notarized" + exit 0 +fi + +TMP="${RUNNER_TEMP:-${TMPDIR:-/tmp}}" +KEYCHAIN="$TMP/projectcraft-signing-$$.keychain-db" +CERT="$TMP/projectcraft-signing-$$.p12" +KC_PASS="${KEYCHAIN_PASSWORD:-$(openssl rand -hex 24)}" +KEEP_KEYCHAIN=0 +KEYCHAIN_LIST_MODIFIED=0 +existing_keychains=() + +cleanup() { + rm -f "$CERT" + if [ "$KEEP_KEYCHAIN" != 1 ]; then + if [ "$KEYCHAIN_LIST_MODIFIED" = 1 ]; then + security list-keychains -d user -s ${existing_keychains[@]+"${existing_keychains[@]}"} 2>/dev/null || true + fi + security delete-keychain "$KEYCHAIN" 2>/dev/null || rm -f "$KEYCHAIN" + fi +} +trap cleanup EXIT + +printf '%s' "$APPLE_CERTIFICATE" | base64 -D >"$CERT" +security delete-keychain "$KEYCHAIN" 2>/dev/null || rm -f "$KEYCHAIN" +# macOS `security` only accepts -p/-P/-k flags non-interactively (no stdin/fd option), so +# passwords are briefly visible in argv; run only on dedicated single-tenant ephemeral runners +# with a rotated CI-only .p12 passphrase, never on shared multi-user hosts. +security create-keychain -p "$KC_PASS" "$KEYCHAIN" +security set-keychain-settings -lut 21600 "$KEYCHAIN" +security unlock-keychain -p "$KC_PASS" "$KEYCHAIN" +security import "$CERT" -P "${APPLE_CERTIFICATE_PASSWORD:-}" -T /usr/bin/codesign -T /usr/bin/security -t cert -f pkcs12 -k "$KEYCHAIN" +rm -f "$CERT" +# Allow codesign to access the private key without a GUI prompt. +security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KC_PASS" "$KEYCHAIN" >/dev/null +# Put it on the search list alongside existing user keychains. +if ! keychain_list="$(security list-keychains -d user)"; then + echo "error: failed to read existing user keychains" >&2 + exit 1 +fi +existing_keychains=() +while IFS= read -r line; do + [ -n "$line" ] && existing_keychains+=("$line") +done < <(printf '%s\n' "$keychain_list" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' -e 's/^"//' -e 's/"$//') +KEYCHAIN_LIST_MODIFIED=1 +security list-keychains -d user -s "$KEYCHAIN" ${existing_keychains[@]+"${existing_keychains[@]}"} + +IDENTITY="$(security find-identity -v -p codesigning "$KEYCHAIN" | awk '/Developer ID Application/ { print $2; exit }')" +if [ -z "$IDENTITY" ]; then + security find-identity -v -p codesigning "$KEYCHAIN" >&2 + echo "error: no 'Developer ID Application' identity in APPLE_CERTIFICATE" >&2 + exit 1 +fi +echo "Imported signing identity $IDENTITY" +if [ -n "${GITHUB_ENV:-}" ]; then + { echo "MACOS_SIGN_IDENTITY=$IDENTITY"; echo "MACOS_KEYCHAIN=$KEYCHAIN"; } >>"$GITHUB_ENV" + KEEP_KEYCHAIN=1 +else + warn "GITHUB_ENV is unset; temporary keychain $KEYCHAIN was verified and will be removed on exit" +fi diff --git a/packaging/macos/package.sh b/packaging/macos/package.sh new file mode 100755 index 0000000..b684e23 --- /dev/null +++ b/packaging/macos/package.sh @@ -0,0 +1,327 @@ +#!/usr/bin/env bash +# Build, sign and (optionally) notarize the macOS release artifacts for ProjectCraft: +# +# $DIST/projectcraft--macos-.dmg ProjectCraft.app on a drag-to-Applications DMG +# $DIST/projectcraft-cli--macos-.zip the headless CLI with licence files +# +# Usage: packaging/macos/package.sh [--arch universal|aarch64|x86_64] [--skip-build | --build-only] [--no-run] +# +# Options: +# --arch Target architecture(s): universal (default), aarch64, or x86_64 +# --skip-build Package binaries already present in $CARGO_TARGET_DIR//release +# --build-only Compile targets and exit before signing/packaging +# --no-run Skip the final CLI smoke check (for isolated signing jobs) +# +# Signing (env): +# MACOS_SIGN_IDENTITY codesign identity (name or SHA-1). Default "-" = ad-hoc signing +# (local only; fails in GitHub Actions unless MACOS_ALLOW_ADHOC=1). +# MACOS_KEYCHAIN keychain holding MACOS_SIGN_IDENTITY (optional) +# Notarization (env; requires a real identity plus MACOS_NOTARY_PROFILE or all three; +# fails in GitHub Actions unless MACOS_ALLOW_UNNOTARIZED=1): +# MACOS_NOTARY_PROFILE notarytool keychain profile (preferred) +# APPLE_ID, APPLE_PASSWORD, APPLE_TEAM_ID +set -euo pipefail +EXPLICIT_BUILD_SHA="${PROJECTCRAFT_BUILD_SHA:-}" +# shellcheck source=../env.sh +. "$(dirname "${BASH_SOURCE[0]}")/../env.sh" +HERE="$ROOT/packaging/macos" + +ARCH=universal +SKIP_BUILD=0 +BUILD_ONLY=0 +NO_RUN=0 +while [ $# -gt 0 ]; do + case "$1" in + --arch) + if [ $# -lt 2 ]; then echo "missing value for --arch" >&2; exit 2; fi + ARCH="$2"; shift 2 ;; + --skip-build) SKIP_BUILD=1; shift ;; + --build-only) BUILD_ONLY=1; shift ;; + --no-run) NO_RUN=1; shift ;; + -h | --help) sed -n '2,22p' "$0"; exit 0 ;; + *) echo "unknown argument: $1" >&2; exit 2 ;; + esac +done +case "$ARCH" in + universal) TARGETS=(aarch64-apple-darwin x86_64-apple-darwin); WANT=(arm64 x86_64) ;; + aarch64) TARGETS=(aarch64-apple-darwin); WANT=(arm64) ;; + x86_64) TARGETS=(x86_64-apple-darwin); WANT=(x86_64) ;; + *) echo "unknown --arch $ARCH" >&2; exit 2 ;; +esac +if [ "$SKIP_BUILD" = 1 ] && [ "$BUILD_ONLY" = 1 ]; then + echo "--skip-build and --build-only can't be used together" >&2 + exit 2 +fi + +# Keep in sync with LSMinimumSystemVersion in Info.plist.in. +export MACOSX_DEPLOYMENT_TARGET=11.0 +IDENTITY="${MACOS_SIGN_IDENTITY:--}" +SHORT_VERSION="${VERSION%%[-+]*}" +if ! [[ "$SHORT_VERSION" =~ ^[0-9]+(\.[0-9]+){0,2}$ ]]; then + echo "error: version '$VERSION' does not yield a one-to-three-integer CFBundleShortVersionString (got '$SHORT_VERSION')" >&2 + exit 2 +fi + +# Validate version, bundle identifier, deployment target, and build SHA before Info.plist substitution. +for value in "$APP_ID" "$VERSION" "$SHORT_VERSION" "$MACOSX_DEPLOYMENT_TARGET" "${PROJECTCRAFT_BUILD_SHA:-unknown}"; do + case "$value" in + *[!0-9A-Za-z._+-]*) + echo "error: Info.plist substitution values may contain only letters, digits, '.', '_', '+' and '-': $value" >&2 + exit 2 + ;; + esac +done + +escape_sed_repl() { + printf '%s' "$1" | sed -e 's/[\\/&]/\\&/g' +} + +WORK="$CARGO_TARGET_DIR/macos-package-$ARCH" +APP="$WORK/ProjectCraft.app" +DMG="$DIST/projectcraft-$VERSION-macos-$ARCH.dmg" +CLI_ZIP="$DIST/projectcraft-cli-$VERSION-macos-$ARCH.zip" + +echo "==> ProjectCraft $VERSION for macOS ($ARCH)" + +# ---- build ------------------------------------------------------------------------------------- +if [ "$SKIP_BUILD" = 0 ]; then + if active_sysroot="$(rustc --print sysroot 2>/dev/null)" && [ -d "$active_sysroot/lib/rustlib" ]; then + for t in "${TARGETS[@]}"; do + if [ ! -d "$active_sysroot/lib/rustlib/$t" ]; then + echo "error: Rust target '$t' is not installed in active sysroot '$active_sysroot'; run 'rustup target add $t' (or put rustup ahead of Homebrew Rust on PATH)" >&2 + exit 1 + fi + done + elif command -v rustup >/dev/null 2>&1; then + installed_targets="$(rustup target list --installed)" + for t in "${TARGETS[@]}"; do + if ! printf '%s\n' "$installed_targets" | grep -qx "$t"; then + echo "error: Rust target '$t' is not installed; run: rustup target add $t" >&2 + exit 1 + fi + done + fi + for t in "${TARGETS[@]}"; do + if ! (cd "$ROOT" && cargo build --release --locked -p projectcraft -p projectcraft-cli --target "$t"); then + echo "error: cargo build failed for $t; aborting packaging" >&2 + exit 1 + fi + printf '%s\n' "$PROJECTCRAFT_BUILD_SHA" >"$CARGO_TARGET_DIR/$t/release/.projectcraft-build-sha" + done +elif [ -z "$EXPLICIT_BUILD_SHA" ]; then + recorded_sha="" + for t in "${TARGETS[@]}"; do + stamp_file="$CARGO_TARGET_DIR/$t/release/.projectcraft-build-sha" + if [ -f "$stamp_file" ]; then + stamp_sha="$(tr -d '[:space:]' <"$stamp_file")" + if [ -n "$recorded_sha" ] && [ "$stamp_sha" != "$recorded_sha" ]; then + echo "error: target binaries have mismatched build SHAs ('$recorded_sha' vs '$stamp_sha'); rebuild without --skip-build" >&2 + exit 1 + fi + recorded_sha="$stamp_sha" + elif [ -n "${GITHUB_ACTIONS:-}" ]; then + echo "error: --skip-build requires $stamp_file or explicit PROJECTCRAFT_BUILD_SHA in GitHub Actions" >&2 + exit 1 + else + warn "--skip-build: missing $stamp_file; stamping checkout SHA $PROJECTCRAFT_BUILD_SHA" + fi + done + if [ -n "$recorded_sha" ]; then + PROJECTCRAFT_BUILD_SHA="$recorded_sha" + case "$PROJECTCRAFT_BUILD_SHA" in + *[!0-9A-Za-z._+-]*) + echo "error: Info.plist substitution values may contain only letters, digits, '.', '_', '+' and '-': $PROJECTCRAFT_BUILD_SHA" >&2 + exit 2 + ;; + esac + fi +fi + +if [ "$BUILD_ONLY" = 1 ]; then + echo "==> built; signing and packaging come next" + exit 0 +fi + +NOTARIZE=0 +SIGNING=adhoc +if [ "$IDENTITY" = "-" ]; then + if [ -n "${GITHUB_ACTIONS:-}" ] && [ "${MACOS_ALLOW_ADHOC:-0}" != 1 ]; then + echo "error: MACOS_SIGN_IDENTITY is not set; refusing to package an unsigned release" >&2 + exit 1 + fi + warn "macOS: ad-hoc signing (no MACOS_SIGN_IDENTITY); artifacts are not notarized" +elif [ -n "${MACOS_NOTARY_PROFILE:-}" ] || { [ -n "${APPLE_ID:-}" ] && [ -n "${APPLE_PASSWORD:-}" ] && [ -n "${APPLE_TEAM_ID:-}" ]; }; then + NOTARIZE=1 + SIGNING=notarized +else + if [ -n "${GITHUB_ACTIONS:-}" ] && [ "${MACOS_ALLOW_UNNOTARIZED:-0}" != 1 ]; then + echo "error: notarization credentials incomplete; set MACOS_NOTARY_PROFILE or all of APPLE_ID/APPLE_PASSWORD/APPLE_TEAM_ID (or MACOS_ALLOW_UNNOTARIZED=1)" >&2 + exit 1 + fi + SIGNING=signed + warn "macOS: notarization credentials incomplete (set MACOS_NOTARY_PROFILE or APPLE_ID / APPLE_PASSWORD / APPLE_TEAM_ID); signed but not notarized" +fi + +echo "==> packaging ProjectCraft $VERSION for macOS ($ARCH), identity: $IDENTITY, notarize: $NOTARIZE" + +rm -rf "$WORK" +mkdir -p "$WORK/bin" +for bin in projectcraft projectcraft-cli; do + inputs=() + for t in "${TARGETS[@]}"; do + input="$CARGO_TARGET_DIR/$t/release/$bin" + if [ ! -x "$input" ]; then + echo "error: $input is missing; build it first or drop --skip-build" >&2 + exit 1 + fi + inputs+=("$input") + done + lipo -create -output "$WORK/bin/$bin" "${inputs[@]}" + lipo -info "$WORK/bin/$bin" + for arch in "${WANT[@]}"; do lipo "$WORK/bin/$bin" -verify_arch "$arch"; done +done + + +# ---- signing helpers --------------------------------------------------------------------------- +sign() { + local ts=(--timestamp) + [ "$IDENTITY" = "-" ] && ts=(--timestamp=none) + local kc=() + [ -n "${MACOS_KEYCHAIN:-}" ] && kc=(--keychain "$MACOS_KEYCHAIN") + codesign --force --sign "$IDENTITY" ${kc[@]+"${kc[@]}"} "${ts[@]}" "$@" +} + +notarize() { + local file="$1" out id status + local auth_args=() + if [ -n "${MACOS_NOTARY_PROFILE:-}" ]; then + auth_args=(--keychain-profile "$MACOS_NOTARY_PROFILE") + else + auth_args=(--apple-id "$APPLE_ID" --password "$APPLE_PASSWORD" --team-id "$APPLE_TEAM_ID") + fi + echo "==> notarizing $(basename "$file") (this can take a few minutes)" + out="$(xcrun notarytool submit "$file" "${auth_args[@]}" \ + --wait --timeout 1h --output-format json)" || true + echo "$out" + id="$(printf '%s' "$out" | plutil -extract id raw -o - - 2>/dev/null || true)" + status="$(printf '%s' "$out" | plutil -extract status raw -o - - 2>/dev/null || true)" + if [ "$status" != "Accepted" ]; then + if [ -n "$id" ]; then + xcrun notarytool log "$id" "${auth_args[@]}" || true + fi + echo "error: notarization of $(basename "$file") failed (status: ${status:-unknown})" >&2 + exit 1 + fi +} + +# hdiutil attaches a device while working, which can briefly fail with "Resource busy" in CI. +hdiutil_retry() { + local label="$1" attempt + shift + for attempt in 1 2 3 4 5; do + if hdiutil "$@"; then return 0; fi + [ "$attempt" = 5 ] && { echo "hdiutil $label failed 5 times" >&2; return 1; } + echo "hdiutil $label failed (attempt $attempt of 5); retrying in $((attempt * 5))s" >&2 + sleep $((attempt * 5)) + done +} + +# ---- ProjectCraft.app ---------------------------------------------------------------------------- +echo "==> assembling $APP" +mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources/Licenses" +cp "$WORK/bin/projectcraft" "$APP/Contents/MacOS/ProjectCraft" +cp "$WORK/bin/projectcraft-cli" "$APP/Contents/MacOS/projectcraft-cli" +copy_docs "$APP/Contents/Resources/Licenses" + +escaped_app_id="$(escape_sed_repl "$APP_ID")" +escaped_version="$(escape_sed_repl "$VERSION")" +escaped_short_version="$(escape_sed_repl "$SHORT_VERSION")" +escaped_build_sha="$(escape_sed_repl "${PROJECTCRAFT_BUILD_SHA:-unknown}")" +escaped_min_macos="$(escape_sed_repl "$MACOSX_DEPLOYMENT_TARGET")" + +sed -e "s/@APP_ID@/$escaped_app_id/g" -e "s/@VERSION@/$escaped_version/g" \ + -e "s/@SHORT_VERSION@/$escaped_short_version/g" -e "s/@BUILD_SHA@/$escaped_build_sha/g" \ + -e "s/@MIN_MACOS@/$escaped_min_macos/g" \ + "$HERE/Info.plist.in" >"$APP/Contents/Info.plist" + +ICON_SRC="" +for candidate in "$ROOT/assets/app-icon/projectcraft.icns" "$ROOT/assets/app-icon/icon.icns"; do + if [ -f "$candidate" ]; then ICON_SRC="$candidate"; break; fi +done +if [ -n "$ICON_SRC" ]; then + cp "$ICON_SRC" "$APP/Contents/Resources/ProjectCraft.icns" + /usr/libexec/PlistBuddy -c "Add :CFBundleIconFile string ProjectCraft" "$APP/Contents/Info.plist" +fi + +plutil -lint "$APP/Contents/Info.plist" +printf 'APPL????' >"$APP/Contents/PkgInfo" + +# Sign inside-out: nested executables first, then the bundle itself. +sign --options runtime --identifier "$APP_ID.cli" "$APP/Contents/MacOS/projectcraft-cli" +sign --options runtime --entitlements "$HERE/entitlements.plist" "$APP/Contents/MacOS/ProjectCraft" +sign --options runtime --entitlements "$HERE/entitlements.plist" "$APP" +codesign --verify --strict --deep --verbose=2 "$APP" + +if [ "$NOTARIZE" = 1 ]; then + ditto -c -k --keepParent "$APP" "$WORK/ProjectCraft-notarize.zip" + notarize "$WORK/ProjectCraft-notarize.zip" + xcrun stapler staple "$APP" + xcrun stapler validate "$APP" + spctl --assess --type execute -vvv "$APP" +fi + +# ---- DMG --------------------------------------------------------------------------------------- +echo "==> building $DMG" +STAGE="$WORK/dmg" +mkdir -p "$STAGE" +ditto "$APP" "$STAGE/ProjectCraft.app" +ln -s /Applications "$STAGE/Applications" +if [ -f "$HERE/dmg/background.tiff" ] && [ -f "$HERE/dmg/dmg-layout.DS_Store" ]; then + mkdir -p "$STAGE/.background" + cp "$HERE/dmg/background.tiff" "$STAGE/.background/background.tiff" + cp "$HERE/dmg/dmg-layout.DS_Store" "$STAGE/.DS_Store" +fi +rm -f "$DIST"/projectcraft-*-macos-"$ARCH".dmg "$DIST"/projectcraft-*-macos-"$ARCH".dmg.sha256 \ + "$DIST"/projectcraft-cli-*-macos-"$ARCH".zip "$DIST"/projectcraft-cli-*-macos-"$ARCH".zip.sha256 +hdiutil_retry create create -volname "ProjectCraft" -srcfolder "$STAGE" -fs HFS+ -format UDZO -imagekey zlib-level=9 -ov "$DMG" +sign "$DMG" +codesign --verify --strict --verbose=2 "$DMG" +if [ "$NOTARIZE" = 1 ]; then + notarize "$DMG" + xcrun stapler staple "$DMG" + xcrun stapler validate "$DMG" + spctl --assess --type open --context context:primary-signature -vvv "$DMG" +fi + +# ---- CLI --------------------------------------------------------------------------------------- +echo "==> building $CLI_ZIP" +CLI_DIR="$WORK/projectcraft-cli-$VERSION-macos-$ARCH" +mkdir -p "$CLI_DIR" +cp "$WORK/bin/projectcraft-cli" "$CLI_DIR/" +copy_docs "$CLI_DIR" +sign --options runtime --identifier "$APP_ID.cli" "$CLI_DIR/projectcraft-cli" +codesign --verify --strict --verbose=2 "$CLI_DIR/projectcraft-cli" +rm -f "$CLI_ZIP" +ditto -c -k --norsrc --noextattr --keepParent "$CLI_DIR" "$CLI_ZIP" +if [ "$NOTARIZE" = 1 ]; then notarize "$CLI_ZIP"; fi + +host_arch="$(uname -m)" +if [ "$NO_RUN" = 1 ]; then + echo "==> skipping projectcraft-cli smoke test (--no-run)" +elif printf '%s\n' "${WANT[@]}" | grep -qx "$host_arch"; then + smoke_dir="$(mktemp -d)" + ditto -x -k "$CLI_ZIP" "$smoke_dir" + if ! "$smoke_dir/$(basename "$CLI_DIR")/projectcraft-cli" commands >/dev/null; then + rm -rf "$smoke_dir" + exit 1 + fi + rm -rf "$smoke_dir" +else + echo "==> skipping projectcraft-cli smoke test: built ${WANT[*]} on a $host_arch host" +fi +for artifact in "$DMG" "$CLI_ZIP"; do + printf '%s %s\n' "$(sha256 "$artifact")" "$(basename "$artifact")" >"$artifact.sha256" +done +if [ -n "${GITHUB_OUTPUT:-}" ]; then echo "signing=$SIGNING" >>"$GITHUB_OUTPUT"; fi +echo "==> done (signing: $SIGNING)" +ls -lh "$DMG" "$DMG.sha256" "$CLI_ZIP" "$CLI_ZIP.sha256"