From 2539bc45ef1b43705e4690cb709dd02ab7e270fa Mon Sep 17 00:00:00 2001 From: HagaiBA Date: Fri, 20 Nov 2026 06:51:50 +0200 Subject: [PATCH 01/17] packaging(macos): add macOS .app, .dmg, and CLI bundle packaging scripts --- packaging/env.sh | 80 +++++++++++ packaging/macos/Info.plist.in | 84 ++++++++++++ packaging/macos/entitlements.plist | 8 ++ packaging/macos/import-cert.sh | 49 +++++++ packaging/macos/package.sh | 212 +++++++++++++++++++++++++++++ 5 files changed, 433 insertions(+) create mode 100755 packaging/env.sh create mode 100644 packaging/macos/Info.plist.in create mode 100644 packaging/macos/entitlements.plist create mode 100755 packaging/macos/import-cert.sh create mode 100755 packaging/macos/package.sh diff --git a/packaging/env.sh b/packaging/env.sh new file mode 100755 index 0000000..0902002 --- /dev/null +++ b/packaging/env.sh @@ -0,0 +1,80 @@ +# 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 +# PROJECTCRAFT_BUILD_DATE UTC build date, YYYY-MM-DD +# CARGO_TARGET_DIR cargo's 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. +workspace_version() { + awk ' + /^\[/ { in_pkg = ($0 == "[workspace.package]") ; next } + in_pkg && $1 == "version" { gsub(/[" ]/, "", $3); print $3; 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 + +PROJECTCRAFT_BUILD_SHA="${PROJECTCRAFT_BUILD_SHA:-$(git -C "$ROOT" rev-parse HEAD 2>/dev/null || echo unknown)}" +export PROJECTCRAFT_BUILD_SHA +PROJECTCRAFT_BUILD_DATE="${PROJECTCRAFT_BUILD_DATE:-$(date -u +%Y-%m-%d)}" +export PROJECTCRAFT_BUILD_DATE +export CARGO_TARGET_DIR="${CARGO_TARGET_DIR:-$ROOT/target}" +APP_ID="io.github.ucscaregroup.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 README.md LICENSE LICENSE-MIT LICENSE-APACHE NOTICE ATTRIBUTION.md 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 + if [ -f "$ROOT/crates/visuals/fonts/OFL.txt" ]; then + cp "$ROOT/crates/visuals/fonts/OFL.txt" "$dest/OFL-Inter.txt" + fi + if [ -d "$ROOT/licenses/egui-default-fonts" ]; then + mkdir -p "$dest/egui-default-fonts" + for f in "$ROOT"/licenses/egui-default-fonts/*; do + if [ -f "$f" ]; then cp "$f" "$dest/egui-default-fonts/"; fi + done + fi + [ -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..87a4505 --- /dev/null +++ b/packaging/macos/Info.plist.in @@ -0,0 +1,84 @@ + + + + + + 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. + CFBundleDocumentTypes + + + CFBundleTypeName + ProjectCraft Plan + CFBundleTypeRole + Editor + LSHandlerRank + Owner + CFBundleTypeExtensions + + projectcraft + + + + CFBundleTypeName + Microsoft Project XML + CFBundleTypeRole + Viewer + LSHandlerRank + Alternate + CFBundleTypeExtensions + + xml + + + + CFBundleTypeName + CSV Task Sheet + CFBundleTypeRole + Viewer + LSHandlerRank + Alternate + CFBundleTypeExtensions + + csv + + + + + diff --git a/packaging/macos/entitlements.plist b/packaging/macos/entitlements.plist new file mode 100644 index 0000000..e229f14 --- /dev/null +++ b/packaging/macos/entitlements.plist @@ -0,0 +1,8 @@ + + + + + + + diff --git a/packaging/macos/import-cert.sh b/packaging/macos/import-cert.sh new file mode 100755 index 0000000..3a3ffb3 --- /dev/null +++ b/packaging/macos/import-cert.sh @@ -0,0 +1,49 @@ +#!/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: emits a warning 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 + 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)}" + +trap 'rm -f "$CERT"' EXIT +printf '%s' "$APPLE_CERTIFICATE" | base64 --decode >"$CERT" +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. +# shellcheck disable=SC2046 +security list-keychains -d user -s "$KEYCHAIN" $(security list-keychains -d user | tr -d '"') + +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" +else + echo "MACOS_SIGN_IDENTITY=$IDENTITY" + echo "MACOS_KEYCHAIN=$KEYCHAIN" +fi diff --git a/packaging/macos/package.sh b/packaging/macos/package.sh new file mode 100755 index 0000000..9bbfadf --- /dev/null +++ b/packaging/macos/package.sh @@ -0,0 +1,212 @@ +#!/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. +# MACOS_KEYCHAIN keychain holding MACOS_SIGN_IDENTITY (optional) +# Notarization (env; requires a real identity plus all three): +# APPLE_ID, APPLE_PASSWORD, APPLE_TEAM_ID +set -euo pipefail +# 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,19p' "$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%%-*}" +WORK="$CARGO_TARGET_DIR/macos-package" +APP="$WORK/ProjectCraft.app" +DMG="$DIST/projectcraft-$VERSION-macos-$ARCH.dmg" +CLI_ZIP="$DIST/projectcraft-cli-$VERSION-macos-$ARCH.zip" + +NOTARIZE=0 +SIGNING=adhoc +if [ "$IDENTITY" = "-" ]; then + warn "macOS: ad-hoc signing (no MACOS_SIGN_IDENTITY); artifacts are not notarized" +elif [ -n "${APPLE_ID:-}" ] && [ -n "${APPLE_PASSWORD:-}" ] && [ -n "${APPLE_TEAM_ID:-}" ]; then + NOTARIZE=1 + SIGNING=notarized +else + SIGNING=signed + warn "macOS: APPLE_ID / APPLE_PASSWORD / APPLE_TEAM_ID incomplete; signed but not notarized" +fi + +echo "==> ProjectCraft $VERSION for macOS ($ARCH), identity: $IDENTITY, notarize: $NOTARIZE" + +# ---- build ------------------------------------------------------------------------------------- +if [ "$SKIP_BUILD" = 0 ]; then + args=() + for t in "${TARGETS[@]}"; do args+=(--target "$t"); done + (cd "$ROOT" && cargo build --release --locked -p projectcraft -p projectcraft-cli "${args[@]}") +fi + +if [ "$BUILD_ONLY" = 1 ]; then + echo "==> built; signing and packaging come next" + exit 0 +fi + +rm -rf "$WORK" +mkdir -p "$WORK/bin" +for bin in projectcraft projectcraft-cli; do + inputs=() + for t in "${TARGETS[@]}"; do inputs+=("$CARGO_TARGET_DIR/$t/release/$bin"); 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 + echo "==> notarizing $(basename "$file") (this can take a few minutes)" + out="$(xcrun notarytool submit "$file" --apple-id "$APPLE_ID" --password "$APPLE_PASSWORD" \ + --team-id "$APPLE_TEAM_ID" --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" --apple-id "$APPLE_ID" --password "$APPLE_PASSWORD" --team-id "$APPLE_TEAM_ID" || 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 what="$1" attempt + for attempt in 1 2 3 4 5; do + if hdiutil "$@"; then return 0; fi + [ "$attempt" = 5 ] && { echo "hdiutil $what failed 5 times" >&2; return 1; } + echo "hdiutil $what 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" + +sed -e "s/@APP_ID@/$APP_ID/g" -e "s/@VERSION@/$VERSION/g" -e "s/@SHORT_VERSION@/$SHORT_VERSION/g" \ + -e "s/@BUILD_SHA@/${PROJECTCRAFT_BUILD_SHA:-unknown}/g" -e "s/@MIN_MACOS@/$MACOSX_DEPLOYMENT_TARGET/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 "$DMG" +hdiutil_retry 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 + +if [ "$NO_RUN" = 1 ]; then + echo "==> skipping projectcraft-cli smoke test (--no-run)" +else + "$CLI_DIR/projectcraft-cli" commands >/dev/null +fi +if [ -n "${GITHUB_OUTPUT:-}" ]; then echo "signing=$SIGNING" >>"$GITHUB_OUTPUT"; fi +echo "==> done (signing: $SIGNING)" +ls -lh "$DMG" "$CLI_ZIP" From aba5b356a4f4407142ed1356b0422700c3614a91 Mon Sep 17 00:00:00 2001 From: HagaiBA Date: Fri, 20 Nov 2026 07:07:51 +0200 Subject: [PATCH 02/17] packaging(macos): address review feedback on env, cert import, font licences, and Info.plist --- licenses/egui-default-fonts/Hack-Regular.txt | 31 ++++++ licenses/egui-default-fonts/OFL.txt | 92 ++++++++++++++++++ licenses/egui-default-fonts/UFL.txt | 96 +++++++++++++++++++ .../emoji-icon-font-mit-license.txt | 9 ++ packaging/env.sh | 30 +++--- packaging/macos/Info.plist.in | 41 +------- packaging/macos/import-cert.sh | 16 +++- packaging/macos/package.sh | 11 +++ 8 files changed, 273 insertions(+), 53 deletions(-) create mode 100644 licenses/egui-default-fonts/Hack-Regular.txt create mode 100644 licenses/egui-default-fonts/OFL.txt create mode 100644 licenses/egui-default-fonts/UFL.txt create mode 100644 licenses/egui-default-fonts/emoji-icon-font-mit-license.txt 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/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 index 0902002..0067d2d 100755 --- a/packaging/env.sh +++ b/packaging/env.sh @@ -8,7 +8,7 @@ # DIST output directory for release artifacts (default: $ROOT/dist/release) # PROJECTCRAFT_BUILD_SHA git commit recorded in the macOS Info.plist # PROJECTCRAFT_BUILD_DATE UTC build date, YYYY-MM-DD -# CARGO_TARGET_DIR cargo's target dir (default: $ROOT/target) +# CARGO_TARGET_DIR absolute cargo target dir (default: $ROOT/target) # APP_ID reverse-DNS macOS bundle identifier ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" @@ -38,7 +38,16 @@ PROJECTCRAFT_BUILD_SHA="${PROJECTCRAFT_BUILD_SHA:-$(git -C "$ROOT" rev-parse HEA export PROJECTCRAFT_BUILD_SHA PROJECTCRAFT_BUILD_DATE="${PROJECTCRAFT_BUILD_DATE:-$(date -u +%Y-%m-%d)}" export PROJECTCRAFT_BUILD_DATE -export CARGO_TARGET_DIR="${CARGO_TARGET_DIR:-$ROOT/target}" + +# 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.ucscaregroup.projectcraft" export APP_ID @@ -59,15 +68,14 @@ copy_docs() { # Copy bundled font licences (including optional CRAFT_FONTS_DIR embeds) into dest. copy_font_licences() { local dest="$1" f - if [ -f "$ROOT/crates/visuals/fonts/OFL.txt" ]; then - cp "$ROOT/crates/visuals/fonts/OFL.txt" "$dest/OFL-Inter.txt" - fi - if [ -d "$ROOT/licenses/egui-default-fonts" ]; then - mkdir -p "$dest/egui-default-fonts" - for f in "$ROOT"/licenses/egui-default-fonts/*; do - if [ -f "$f" ]; then cp "$f" "$dest/egui-default-fonts/"; fi - done - fi + mkdir -p "$dest/egui-default-fonts" + for f in Hack-Regular.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 diff --git a/packaging/macos/Info.plist.in b/packaging/macos/Info.plist.in index 87a4505..2204e16 100644 --- a/packaging/macos/Info.plist.in +++ b/packaging/macos/Info.plist.in @@ -41,44 +41,7 @@ NSHumanReadableCopyright Copyright © ProjectCraft contributors. MIT OR Apache-2.0. - CFBundleDocumentTypes - - - CFBundleTypeName - ProjectCraft Plan - CFBundleTypeRole - Editor - LSHandlerRank - Owner - CFBundleTypeExtensions - - projectcraft - - - - CFBundleTypeName - Microsoft Project XML - CFBundleTypeRole - Viewer - LSHandlerRank - Alternate - CFBundleTypeExtensions - - xml - - - - CFBundleTypeName - CSV Task Sheet - CFBundleTypeRole - Viewer - LSHandlerRank - Alternate - CFBundleTypeExtensions - - csv - - - + diff --git a/packaging/macos/import-cert.sh b/packaging/macos/import-cert.sh index 3a3ffb3..7a345cd 100755 --- a/packaging/macos/import-cert.sh +++ b/packaging/macos/import-cert.sh @@ -17,12 +17,21 @@ if [ -z "${APPLE_CERTIFICATE:-}" ]; then fi TMP="${RUNNER_TEMP:-${TMPDIR:-/tmp}}" -KEYCHAIN="$TMP/projectcraft-signing.keychain-db" -CERT="$TMP/projectcraft-signing.p12" +KEYCHAIN="$TMP/projectcraft-signing-$$.keychain-db" +CERT="$TMP/projectcraft-signing-$$.p12" KC_PASS="${KEYCHAIN_PASSWORD:-$(openssl rand -hex 24)}" +KEEP_KEYCHAIN=0 + +cleanup() { + rm -f "$CERT" + if [ "$KEEP_KEYCHAIN" != 1 ]; then + security delete-keychain "$KEYCHAIN" 2>/dev/null || rm -f "$KEYCHAIN" + fi +} +trap cleanup EXIT -trap 'rm -f "$CERT"' EXIT printf '%s' "$APPLE_CERTIFICATE" | base64 --decode >"$CERT" +security delete-keychain "$KEYCHAIN" 2>/dev/null || rm -f "$KEYCHAIN" security create-keychain -p "$KC_PASS" "$KEYCHAIN" security set-keychain-settings -lut 21600 "$KEYCHAIN" security unlock-keychain -p "$KC_PASS" "$KEYCHAIN" @@ -40,6 +49,7 @@ if [ -z "$IDENTITY" ]; then echo "error: no 'Developer ID Application' identity in APPLE_CERTIFICATE" >&2 exit 1 fi +KEEP_KEYCHAIN=1 echo "Imported signing identity $IDENTITY" if [ -n "${GITHUB_ENV:-}" ]; then { echo "MACOS_SIGN_IDENTITY=$IDENTITY"; echo "MACOS_KEYCHAIN=$KEYCHAIN"; } >>"$GITHUB_ENV" diff --git a/packaging/macos/package.sh b/packaging/macos/package.sh index 9bbfadf..6e5b03d 100755 --- a/packaging/macos/package.sh +++ b/packaging/macos/package.sh @@ -49,6 +49,16 @@ if [ "$SKIP_BUILD" = 1 ] && [ "$BUILD_ONLY" = 1 ]; then exit 2 fi +# Validate version and build SHA before Info.plist sed substitution and XML generation. +for value in "$VERSION" "${PROJECTCRAFT_BUILD_SHA:-unknown}"; do + case "$value" in + *[!0-9A-Za-z._+-]*) + echo "error: version and build SHA may contain only letters, digits, '.', '_', '+' and '-': $value" >&2 + exit 2 + ;; + esac +done + # Keep in sync with LSMinimumSystemVersion in Info.plist.in. export MACOSX_DEPLOYMENT_TARGET=11.0 IDENTITY="${MACOS_SIGN_IDENTITY:--}" @@ -94,6 +104,7 @@ for bin in projectcraft projectcraft-cli; do for arch in "${WANT[@]}"; do lipo "$WORK/bin/$bin" -verify_arch "$arch"; done done + # ---- signing helpers --------------------------------------------------------------------------- sign() { local ts=(--timestamp) From 5af7f7d8258146fe86e323eaee89b953f977dd57 Mon Sep 17 00:00:00 2001 From: HagaiBA Date: Fri, 20 Nov 2026 12:18:21 +0200 Subject: [PATCH 03/17] packaging(macos): bundle readable egui default font copyright notices --- licenses/egui-default-fonts/NOTICES.txt | 19 +++++++++++++++++++ packaging/env.sh | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 licenses/egui-default-fonts/NOTICES.txt 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/packaging/env.sh b/packaging/env.sh index 0067d2d..21f788a 100755 --- a/packaging/env.sh +++ b/packaging/env.sh @@ -69,7 +69,7 @@ copy_docs() { copy_font_licences() { local dest="$1" f mkdir -p "$dest/egui-default-fonts" - for f in Hack-Regular.txt OFL.txt UFL.txt emoji-icon-font-mit-license.txt; do + 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 From 992761c691a161c7d8b47fa5edd126cd4ec6c932 Mon Sep 17 00:00:00 2001 From: HagaiBA Date: Fri, 20 Nov 2026 13:45:47 +0200 Subject: [PATCH 04/17] packaging(macos): strip build metadata from SHORT_VERSION --- packaging/macos/package.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/macos/package.sh b/packaging/macos/package.sh index 6e5b03d..fff04ce 100755 --- a/packaging/macos/package.sh +++ b/packaging/macos/package.sh @@ -62,7 +62,7 @@ done # Keep in sync with LSMinimumSystemVersion in Info.plist.in. export MACOSX_DEPLOYMENT_TARGET=11.0 IDENTITY="${MACOS_SIGN_IDENTITY:--}" -SHORT_VERSION="${VERSION%%-*}" +SHORT_VERSION="${VERSION%%[-+]*}" WORK="$CARGO_TARGET_DIR/macos-package" APP="$WORK/ProjectCraft.app" DMG="$DIST/projectcraft-$VERSION-macos-$ARCH.dmg" From c67652851e7a1dcd42cf49ecd57fda14df8b79fe Mon Sep 17 00:00:00 2001 From: HagaiBA Date: Fri, 20 Nov 2026 21:55:30 +0200 Subject: [PATCH 05/17] packaging(macos): harden cargo build check, version parsing, sed escaping, and keychain quoting --- packaging/env.sh | 16 +++++++++++++--- packaging/macos/entitlements.plist | 6 ++++-- packaging/macos/import-cert.sh | 13 ++++++++++--- packaging/macos/package.sh | 26 ++++++++++++++++++++------ 4 files changed, 47 insertions(+), 14 deletions(-) diff --git a/packaging/env.sh b/packaging/env.sh index 21f788a..941c4fe 100755 --- a/packaging/env.sh +++ b/packaging/env.sh @@ -14,11 +14,21 @@ ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" export ROOT -# Read [workspace.package] version from the root Cargo.toml. +# Read [workspace.package] version from the root Cargo.toml, tolerating comments and whitespace. workspace_version() { awk ' - /^\[/ { in_pkg = ($0 == "[workspace.package]") ; next } - in_pkg && $1 == "version" { gsub(/[" ]/, "", $3); print $3; exit } + { + 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" } diff --git a/packaging/macos/entitlements.plist b/packaging/macos/entitlements.plist index e229f14..f3d0d45 100644 --- a/packaging/macos/entitlements.plist +++ b/packaging/macos/entitlements.plist @@ -1,7 +1,9 @@ - + diff --git a/packaging/macos/import-cert.sh b/packaging/macos/import-cert.sh index 7a345cd..c1d1eed 100755 --- a/packaging/macos/import-cert.sh +++ b/packaging/macos/import-cert.sh @@ -40,8 +40,15 @@ 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. -# shellcheck disable=SC2046 -security list-keychains -d user -s "$KEYCHAIN" $(security list-keychains -d user | tr -d '"') +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/"$//') +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 @@ -49,7 +56,6 @@ if [ -z "$IDENTITY" ]; then echo "error: no 'Developer ID Application' identity in APPLE_CERTIFICATE" >&2 exit 1 fi -KEEP_KEYCHAIN=1 echo "Imported signing identity $IDENTITY" if [ -n "${GITHUB_ENV:-}" ]; then { echo "MACOS_SIGN_IDENTITY=$IDENTITY"; echo "MACOS_KEYCHAIN=$KEYCHAIN"; } >>"$GITHUB_ENV" @@ -57,3 +63,4 @@ else echo "MACOS_SIGN_IDENTITY=$IDENTITY" echo "MACOS_KEYCHAIN=$KEYCHAIN" fi +KEEP_KEYCHAIN=1 diff --git a/packaging/macos/package.sh b/packaging/macos/package.sh index fff04ce..5d31b9e 100755 --- a/packaging/macos/package.sh +++ b/packaging/macos/package.sh @@ -49,16 +49,20 @@ if [ "$SKIP_BUILD" = 1 ] && [ "$BUILD_ONLY" = 1 ]; then exit 2 fi -# Validate version and build SHA before Info.plist sed substitution and XML generation. -for value in "$VERSION" "${PROJECTCRAFT_BUILD_SHA:-unknown}"; do +# 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: version and build SHA may contain only letters, digits, '.', '_', '+' and '-': $value" >&2 + 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' +} + # Keep in sync with LSMinimumSystemVersion in Info.plist.in. export MACOSX_DEPLOYMENT_TARGET=11.0 IDENTITY="${MACOS_SIGN_IDENTITY:--}" @@ -86,7 +90,10 @@ echo "==> ProjectCraft $VERSION for macOS ($ARCH), identity: $IDENTITY, notarize if [ "$SKIP_BUILD" = 0 ]; then args=() for t in "${TARGETS[@]}"; do args+=(--target "$t"); done - (cd "$ROOT" && cargo build --release --locked -p projectcraft -p projectcraft-cli "${args[@]}") + if ! (cd "$ROOT" && cargo build --release --locked -p projectcraft -p projectcraft-cli "${args[@]}"); then + echo "error: cargo build failed; aborting packaging" >&2 + exit 1 + fi fi if [ "$BUILD_ONLY" = 1 ]; then @@ -149,8 +156,15 @@ cp "$WORK/bin/projectcraft" "$APP/Contents/MacOS/ProjectCraft" cp "$WORK/bin/projectcraft-cli" "$APP/Contents/MacOS/projectcraft-cli" copy_docs "$APP/Contents/Resources/Licenses" -sed -e "s/@APP_ID@/$APP_ID/g" -e "s/@VERSION@/$VERSION/g" -e "s/@SHORT_VERSION@/$SHORT_VERSION/g" \ - -e "s/@BUILD_SHA@/${PROJECTCRAFT_BUILD_SHA:-unknown}/g" -e "s/@MIN_MACOS@/$MACOSX_DEPLOYMENT_TARGET/g" \ +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="" From 41a292ab6d0b5e24d6222aa8ae8fc7fc973035ae Mon Sep 17 00:00:00 2001 From: HagaiBA Date: Sat, 21 Nov 2026 01:41:22 +0200 Subject: [PATCH 06/17] packaging(macos): initialize version vars before validation and restore keychain list on failure --- packaging/macos/import-cert.sh | 6 ++++++ packaging/macos/package.sh | 15 +++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/packaging/macos/import-cert.sh b/packaging/macos/import-cert.sh index c1d1eed..63f2464 100755 --- a/packaging/macos/import-cert.sh +++ b/packaging/macos/import-cert.sh @@ -21,10 +21,15 @@ 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 } @@ -48,6 +53,7 @@ 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 }')" diff --git a/packaging/macos/package.sh b/packaging/macos/package.sh index 5d31b9e..3bc2cd1 100755 --- a/packaging/macos/package.sh +++ b/packaging/macos/package.sh @@ -49,6 +49,17 @@ if [ "$SKIP_BUILD" = 1 ] && [ "$BUILD_ONLY" = 1 ]; then 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%%[-+]*}" +case "$SHORT_VERSION" in + ''|*[!0-9.]*) + echo "error: version '$VERSION' does not start with a numeric CFBundleShortVersionString prefix" >&2 + exit 2 + ;; +esac + # 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 @@ -63,10 +74,6 @@ escape_sed_repl() { printf '%s' "$1" | sed -e 's/[\\/&]/\\&/g' } -# Keep in sync with LSMinimumSystemVersion in Info.plist.in. -export MACOSX_DEPLOYMENT_TARGET=11.0 -IDENTITY="${MACOS_SIGN_IDENTITY:--}" -SHORT_VERSION="${VERSION%%[-+]*}" WORK="$CARGO_TARGET_DIR/macos-package" APP="$WORK/ProjectCraft.app" DMG="$DIST/projectcraft-$VERSION-macos-$ARCH.dmg" From acbd691957198dd8850ddbc6cdf7dc0df37710c2 Mon Sep 17 00:00:00 2001 From: HagaiBA Date: Sat, 21 Nov 2026 13:42:51 +0200 Subject: [PATCH 07/17] packaging(macos): build targets individually, use BSD base64 -D, and require legal files --- packaging/env.sh | 9 ++++++++- packaging/macos/import-cert.sh | 5 +++-- packaging/macos/package.sh | 12 ++++++------ 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/packaging/env.sh b/packaging/env.sh index 941c4fe..8d4c630 100755 --- a/packaging/env.sh +++ b/packaging/env.sh @@ -69,7 +69,14 @@ warn() { # Copy repository licence and readme files into a package directory. copy_docs() { local dest="$1" f - for f in README.md LICENSE LICENSE-MIT LICENSE-APACHE NOTICE ATTRIBUTION.md COPYRIGHT THIRD-PARTY-LICENSES.txt; do + 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" diff --git a/packaging/macos/import-cert.sh b/packaging/macos/import-cert.sh index 63f2464..abdafb1 100755 --- a/packaging/macos/import-cert.sh +++ b/packaging/macos/import-cert.sh @@ -35,7 +35,7 @@ cleanup() { } trap cleanup EXIT -printf '%s' "$APPLE_CERTIFICATE" | base64 --decode >"$CERT" +printf '%s' "$APPLE_CERTIFICATE" | base64 -D >"$CERT" security delete-keychain "$KEYCHAIN" 2>/dev/null || rm -f "$KEYCHAIN" security create-keychain -p "$KC_PASS" "$KEYCHAIN" security set-keychain-settings -lut 21600 "$KEYCHAIN" @@ -65,8 +65,9 @@ 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 echo "MACOS_SIGN_IDENTITY=$IDENTITY" echo "MACOS_KEYCHAIN=$KEYCHAIN" + echo "note: temporary keychain will be removed on exit" >&2 fi -KEEP_KEYCHAIN=1 diff --git a/packaging/macos/package.sh b/packaging/macos/package.sh index 3bc2cd1..75d0060 100755 --- a/packaging/macos/package.sh +++ b/packaging/macos/package.sh @@ -95,12 +95,12 @@ echo "==> ProjectCraft $VERSION for macOS ($ARCH), identity: $IDENTITY, notarize # ---- build ------------------------------------------------------------------------------------- if [ "$SKIP_BUILD" = 0 ]; then - args=() - for t in "${TARGETS[@]}"; do args+=(--target "$t"); done - if ! (cd "$ROOT" && cargo build --release --locked -p projectcraft -p projectcraft-cli "${args[@]}"); then - echo "error: cargo build failed; aborting packaging" >&2 - exit 1 - 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 + done fi if [ "$BUILD_ONLY" = 1 ]; then From 4235fb45e6626c4db373efcaf4f597697ebc739d Mon Sep 17 00:00:00 2001 From: HagaiBA Date: Sat, 21 Nov 2026 21:51:33 +0200 Subject: [PATCH 08/17] M6: harden macOS packaging smoke test, cert import, and update release docs --- ROADMAP.md | 4 +++- docs/releasing.md | 14 +++++++++----- packaging/macos/import-cert.sh | 6 +++++- packaging/macos/package.sh | 27 +++++++++++++++++++++------ 4 files changed, 38 insertions(+), 13 deletions(-) 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..b3844e7 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), builds `$DIST/projectcraft--macos-.dmg` and `$DIST/projectcraft-cli--macos-.zip`, notarizes/staples when `MACOS_NOTARY_PROFILE` (or `APPLE_ID`, `APPLE_PASSWORD`, `APPLE_TEAM_ID`) is set, 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/packaging/macos/import-cert.sh b/packaging/macos/import-cert.sh index abdafb1..41127d2 100755 --- a/packaging/macos/import-cert.sh +++ b/packaging/macos/import-cert.sh @@ -5,13 +5,17 @@ # (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: emits a warning and exits 0 so package.sh falls back to ad-hoc signing. +# 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 diff --git a/packaging/macos/package.sh b/packaging/macos/package.sh index 75d0060..bc1d1de 100755 --- a/packaging/macos/package.sh +++ b/packaging/macos/package.sh @@ -83,12 +83,12 @@ NOTARIZE=0 SIGNING=adhoc if [ "$IDENTITY" = "-" ]; then warn "macOS: ad-hoc signing (no MACOS_SIGN_IDENTITY); artifacts are not notarized" -elif [ -n "${APPLE_ID:-}" ] && [ -n "${APPLE_PASSWORD:-}" ] && [ -n "${APPLE_TEAM_ID:-}" ]; then +elif [ -n "${MACOS_NOTARY_PROFILE:-}" ] || { [ -n "${APPLE_ID:-}" ] && [ -n "${APPLE_PASSWORD:-}" ] && [ -n "${APPLE_TEAM_ID:-}" ]; }; then NOTARIZE=1 SIGNING=notarized else SIGNING=signed - warn "macOS: APPLE_ID / APPLE_PASSWORD / APPLE_TEAM_ID incomplete; signed but not notarized" + warn "macOS: notarization credentials incomplete (set MACOS_NOTARY_PROFILE or APPLE_ID / APPLE_PASSWORD / APPLE_TEAM_ID); signed but not notarized" fi echo "==> ProjectCraft $VERSION for macOS ($ARCH), identity: $IDENTITY, notarize: $NOTARIZE" @@ -130,15 +130,21 @@ sign() { 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" --apple-id "$APPLE_ID" --password "$APPLE_PASSWORD" \ - --team-id "$APPLE_TEAM_ID" --wait --timeout 1h --output-format json)" || true + 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" --apple-id "$APPLE_ID" --password "$APPLE_PASSWORD" --team-id "$APPLE_TEAM_ID" || true + xcrun notarytool log "$id" "${auth_args[@]}" || true fi echo "error: notarization of $(basename "$file") failed (status: ${status:-unknown})" >&2 exit 1 @@ -234,10 +240,19 @@ 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 - "$CLI_DIR/projectcraft-cli" commands >/dev/null + echo "==> skipping projectcraft-cli smoke test: built ${WANT[*]} on a $host_arch host" fi if [ -n "${GITHUB_OUTPUT:-}" ]; then echo "signing=$SIGNING" >>"$GITHUB_OUTPUT"; fi echo "==> done (signing: $SIGNING)" From c76dabf09d50a6f0d0665c981d7c94607aaecd35 Mon Sep 17 00:00:00 2001 From: HagaiBA Date: Sun, 22 Nov 2026 01:43:27 +0200 Subject: [PATCH 09/17] M6: bound CFBundleShortVersionString to 1-3 integers and fail closed on ad-hoc CI signing --- packaging/macos/package.sh | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/packaging/macos/package.sh b/packaging/macos/package.sh index bc1d1de..ccc317f 100755 --- a/packaging/macos/package.sh +++ b/packaging/macos/package.sh @@ -13,9 +13,11 @@ # --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. +# 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 all three): +# Notarization (env; requires a real identity plus MACOS_NOTARY_PROFILE or all three): +# MACOS_NOTARY_PROFILE notarytool keychain profile (preferred) # APPLE_ID, APPLE_PASSWORD, APPLE_TEAM_ID set -euo pipefail # shellcheck source=../env.sh @@ -53,12 +55,10 @@ fi export MACOSX_DEPLOYMENT_TARGET=11.0 IDENTITY="${MACOS_SIGN_IDENTITY:--}" SHORT_VERSION="${VERSION%%[-+]*}" -case "$SHORT_VERSION" in - ''|*[!0-9.]*) - echo "error: version '$VERSION' does not start with a numeric CFBundleShortVersionString prefix" >&2 - exit 2 - ;; -esac +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 @@ -82,6 +82,10 @@ CLI_ZIP="$DIST/projectcraft-cli-$VERSION-macos-$ARCH.zip" 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 From a099f44dc157258faa8883d24503842c14f37230 Mon Sep 17 00:00:00 2001 From: HagaiBA Date: Sun, 22 Nov 2026 05:42:15 +0200 Subject: [PATCH 10/17] M6: run signing guard after --build-only, print full --help, and avoid exporting deleted keychain --- packaging/macos/import-cert.sh | 4 +--- packaging/macos/package.sh | 36 ++++++++++++++++++---------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/packaging/macos/import-cert.sh b/packaging/macos/import-cert.sh index 41127d2..8a070c4 100755 --- a/packaging/macos/import-cert.sh +++ b/packaging/macos/import-cert.sh @@ -71,7 +71,5 @@ if [ -n "${GITHUB_ENV:-}" ]; then { echo "MACOS_SIGN_IDENTITY=$IDENTITY"; echo "MACOS_KEYCHAIN=$KEYCHAIN"; } >>"$GITHUB_ENV" KEEP_KEYCHAIN=1 else - echo "MACOS_SIGN_IDENTITY=$IDENTITY" - echo "MACOS_KEYCHAIN=$KEYCHAIN" - echo "note: temporary keychain will be removed on exit" >&2 + 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 index ccc317f..ab4e259 100755 --- a/packaging/macos/package.sh +++ b/packaging/macos/package.sh @@ -36,7 +36,7 @@ while [ $# -gt 0 ]; do --skip-build) SKIP_BUILD=1; shift ;; --build-only) BUILD_ONLY=1; shift ;; --no-run) NO_RUN=1; shift ;; - -h | --help) sed -n '2,19p' "$0"; exit 0 ;; + -h | --help) sed -n '2,21p' "$0"; exit 0 ;; *) echo "unknown argument: $1" >&2; exit 2 ;; esac done @@ -79,6 +79,23 @@ 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 + 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 + done +fi + +if [ "$BUILD_ONLY" = 1 ]; then + echo "==> built; signing and packaging come next" + exit 0 +fi + NOTARIZE=0 SIGNING=adhoc if [ "$IDENTITY" = "-" ]; then @@ -95,22 +112,7 @@ else warn "macOS: notarization credentials incomplete (set MACOS_NOTARY_PROFILE or APPLE_ID / APPLE_PASSWORD / APPLE_TEAM_ID); signed but not notarized" fi -echo "==> ProjectCraft $VERSION for macOS ($ARCH), identity: $IDENTITY, notarize: $NOTARIZE" - -# ---- build ------------------------------------------------------------------------------------- -if [ "$SKIP_BUILD" = 0 ]; then - 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 - done -fi - -if [ "$BUILD_ONLY" = 1 ]; then - echo "==> built; signing and packaging come next" - exit 0 -fi +echo "==> packaging ProjectCraft $VERSION for macOS ($ARCH), identity: $IDENTITY, notarize: $NOTARIZE" rm -rf "$WORK" mkdir -p "$WORK/bin" From 7193707a8c23bf635f15b40509f6073f8c0cce99 Mon Sep 17 00:00:00 2001 From: HagaiBA Date: Sun, 22 Nov 2026 09:42:49 +0200 Subject: [PATCH 11/17] M6: document security CLI single-tenant runner requirement and fail closed on incomplete CI notarization credentials --- packaging/macos/import-cert.sh | 3 +++ packaging/macos/package.sh | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packaging/macos/import-cert.sh b/packaging/macos/import-cert.sh index 8a070c4..ad1b1c2 100755 --- a/packaging/macos/import-cert.sh +++ b/packaging/macos/import-cert.sh @@ -41,6 +41,9 @@ 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" diff --git a/packaging/macos/package.sh b/packaging/macos/package.sh index ab4e259..b92b1e5 100755 --- a/packaging/macos/package.sh +++ b/packaging/macos/package.sh @@ -16,7 +16,8 @@ # 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): +# 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 @@ -108,6 +109,10 @@ elif [ -n "${MACOS_NOTARY_PROFILE:-}" ] || { [ -n "${APPLE_ID:-}" ] && [ -n "${A 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 From 1083ea283cdef7aa841a37a65a5946df25c3234a Mon Sep 17 00:00:00 2001 From: HagaiBA Date: Sun, 22 Nov 2026 13:47:16 +0200 Subject: [PATCH 12/17] M6: emit artifact SHA-256 digests, fix --help range, key work dir by arch, and check rustup targets --- packaging/macos/package.sh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/packaging/macos/package.sh b/packaging/macos/package.sh index b92b1e5..ece6b20 100755 --- a/packaging/macos/package.sh +++ b/packaging/macos/package.sh @@ -37,7 +37,7 @@ while [ $# -gt 0 ]; do --skip-build) SKIP_BUILD=1; shift ;; --build-only) BUILD_ONLY=1; shift ;; --no-run) NO_RUN=1; shift ;; - -h | --help) sed -n '2,21p' "$0"; exit 0 ;; + -h | --help) sed -n '2,22p' "$0"; exit 0 ;; *) echo "unknown argument: $1" >&2; exit 2 ;; esac done @@ -75,7 +75,7 @@ escape_sed_repl() { printf '%s' "$1" | sed -e 's/[\\/&]/\\&/g' } -WORK="$CARGO_TARGET_DIR/macos-package" +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" @@ -84,6 +84,15 @@ echo "==> ProjectCraft $VERSION for macOS ($ARCH)" # ---- build ------------------------------------------------------------------------------------- if [ "$SKIP_BUILD" = 0 ]; then + if 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 @@ -265,6 +274,9 @@ elif printf '%s\n' "${WANT[@]}" | grep -qx "$host_arch"; then 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" "$CLI_ZIP" +ls -lh "$DMG" "$DMG.sha256" "$CLI_ZIP" "$CLI_ZIP.sha256" From 2b98f4932456fc9580139f56362ab63d84d3323a Mon Sep 17 00:00:00 2001 From: HagaiBA Date: Sun, 22 Nov 2026 17:43:13 +0200 Subject: [PATCH 13/17] M6: remove unused PROJECTCRAFT_BUILD_DATE export and document CI notarization gate --- docs/releasing.md | 2 +- packaging/env.sh | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/docs/releasing.md b/docs/releasing.md index b3844e7..e35f46d 100644 --- a/docs/releasing.md +++ b/docs/releasing.md @@ -7,7 +7,7 @@ ProjectCraft has no release workflow or published builds yet: build from source ## 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), builds `$DIST/projectcraft--macos-.dmg` and `$DIST/projectcraft-cli--macos-.zip`, notarizes/staples when `MACOS_NOTARY_PROFILE` (or `APPLE_ID`, `APPLE_PASSWORD`, `APPLE_TEAM_ID`) is set, and smoke-tests the packaged CLI on matching host architectures. +- `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). diff --git a/packaging/env.sh b/packaging/env.sh index 8d4c630..f5c05b2 100755 --- a/packaging/env.sh +++ b/packaging/env.sh @@ -7,7 +7,6 @@ # 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 -# PROJECTCRAFT_BUILD_DATE UTC build date, YYYY-MM-DD # CARGO_TARGET_DIR absolute cargo target dir (default: $ROOT/target) # APP_ID reverse-DNS macOS bundle identifier @@ -46,8 +45,6 @@ export DIST PROJECTCRAFT_BUILD_SHA="${PROJECTCRAFT_BUILD_SHA:-$(git -C "$ROOT" rev-parse HEAD 2>/dev/null || echo unknown)}" export PROJECTCRAFT_BUILD_SHA -PROJECTCRAFT_BUILD_DATE="${PROJECTCRAFT_BUILD_DATE:-$(date -u +%Y-%m-%d)}" -export PROJECTCRAFT_BUILD_DATE # Resolve any relative CARGO_TARGET_DIR override against the caller's working directory # before subshells cd into $ROOT for cargo build. From 22b7d3fb5ef3aca3261d5909c59f557e90d4540e Mon Sep 17 00:00:00 2001 From: HagaiBA Date: Mon, 23 Nov 2026 20:52:49 +0200 Subject: [PATCH 14/17] M6: check active rustc sysroot for target preflight --- packaging/macos/package.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packaging/macos/package.sh b/packaging/macos/package.sh index ece6b20..3814805 100755 --- a/packaging/macos/package.sh +++ b/packaging/macos/package.sh @@ -84,7 +84,14 @@ echo "==> ProjectCraft $VERSION for macOS ($ARCH)" # ---- build ------------------------------------------------------------------------------------- if [ "$SKIP_BUILD" = 0 ]; then - if command -v rustup >/dev/null 2>&1; 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 From 9bd7cfac81f12c1bdba3b0e58617177afbec0d75 Mon Sep 17 00:00:00 2001 From: HagaiBA Date: Tue, 24 Nov 2026 16:08:47 +0200 Subject: [PATCH 15/17] M6: verify target binaries exist before lipo on --skip-build --- packaging/macos/package.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packaging/macos/package.sh b/packaging/macos/package.sh index 3814805..56a217f 100755 --- a/packaging/macos/package.sh +++ b/packaging/macos/package.sh @@ -139,7 +139,14 @@ rm -rf "$WORK" mkdir -p "$WORK/bin" for bin in projectcraft projectcraft-cli; do inputs=() - for t in "${TARGETS[@]}"; do inputs+=("$CARGO_TARGET_DIR/$t/release/$bin"); done + 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 From 9eae910f3f24527f5839fdb43f3994bde6cf364e Mon Sep 17 00:00:00 2001 From: HagaiBA Date: Tue, 24 Nov 2026 21:06:12 +0200 Subject: [PATCH 16/17] M6: record build SHA across --skip-build, mark dirty trees, and prune per-arch dist artifacts --- packaging/env.sh | 7 ++++++- packaging/macos/package.sh | 41 +++++++++++++++++++++++++++++++++----- 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/packaging/env.sh b/packaging/env.sh index f5c05b2..417a352 100755 --- a/packaging/env.sh +++ b/packaging/env.sh @@ -43,7 +43,12 @@ mkdir -p "$DIST" DIST="$(cd "$DIST" && pwd)" export DIST -PROJECTCRAFT_BUILD_SHA="${PROJECTCRAFT_BUILD_SHA:-$(git -C "$ROOT" rev-parse HEAD 2>/dev/null || echo unknown)}" +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 diff --git a/packaging/macos/package.sh b/packaging/macos/package.sh index 56a217f..b684e23 100755 --- a/packaging/macos/package.sh +++ b/packaging/macos/package.sh @@ -21,6 +21,7 @@ # 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" @@ -105,7 +106,35 @@ if [ "$SKIP_BUILD" = 0 ]; 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 @@ -187,11 +216,12 @@ notarize() { # hdiutil attaches a device while working, which can briefly fail with "Resource busy" in CI. hdiutil_retry() { - local what="$1" attempt + local label="$1" attempt + shift for attempt in 1 2 3 4 5; do if hdiutil "$@"; then return 0; fi - [ "$attempt" = 5 ] && { echo "hdiutil $what failed 5 times" >&2; return 1; } - echo "hdiutil $what failed (attempt $attempt of 5); retrying in $((attempt * 5))s" >&2 + [ "$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 } @@ -251,8 +281,9 @@ if [ -f "$HERE/dmg/background.tiff" ] && [ -f "$HERE/dmg/dmg-layout.DS_Store" ]; cp "$HERE/dmg/background.tiff" "$STAGE/.background/background.tiff" cp "$HERE/dmg/dmg-layout.DS_Store" "$STAGE/.DS_Store" fi -rm -f "$DMG" -hdiutil_retry create -volname "ProjectCraft" -srcfolder "$STAGE" -fs HFS+ -format UDZO -imagekey zlib-level=9 -ov "$DMG" +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 From bbf4947d6dd7321adbe753126ddcf94cdc149f32 Mon Sep 17 00:00:00 2001 From: HagaiBA Date: Thu, 26 Nov 2026 12:18:32 +0200 Subject: [PATCH 17/17] packaging(macos): update bundle identifier to io.github.ucslabs.projectcraft --- packaging/env.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/env.sh b/packaging/env.sh index 417a352..058f4f8 100755 --- a/packaging/env.sh +++ b/packaging/env.sh @@ -60,7 +60,7 @@ case "${CARGO_TARGET_DIR:-}" in esac export CARGO_TARGET_DIR -APP_ID="io.github.ucscaregroup.projectcraft" +APP_ID="io.github.ucslabs.projectcraft" export APP_ID # Emit a GitHub Actions warning (plain stderr outside Actions).