diff --git a/scripts/package-mac-app.sh b/scripts/package-mac-app.sh index 182eb3f0188..c0a910c8670 100755 --- a/scripts/package-mac-app.sh +++ b/scripts/package-mac-app.sh @@ -34,20 +34,6 @@ sparkle_canonical_build_from_version() { node --import tsx "$ROOT_DIR/scripts/sparkle-build.ts" canonical-build "$1" } -if [[ -z "${APP_BUILD:-}" ]]; then - APP_BUILD="$GIT_BUILD_NUMBER" - if CANONICAL_BUILD="$(sparkle_canonical_build_from_version "$APP_VERSION" 2>/dev/null)"; then - if [[ "$CANONICAL_BUILD" =~ ^[0-9]+$ ]] && (( CANONICAL_BUILD > APP_BUILD )); then - APP_BUILD="$CANONICAL_BUILD" - fi - fi -fi - -if [[ "$AUTO_CHECKS" == "true" && ! "$APP_BUILD" =~ ^[0-9]+$ ]]; then - echo "ERROR: APP_BUILD must be numeric for Sparkle compare (CFBundleVersion). Got: $APP_BUILD" >&2 - exit 1 -fi - build_path_for_arch() { echo "$BUILD_ROOT/$1" } @@ -123,6 +109,25 @@ merge_framework_machos() { echo "📦 Ensuring deps (pnpm install)" (cd "$ROOT_DIR" && pnpm install --no-frozen-lockfile --config.node-linker=hoisted) + +if [[ -z "${APP_BUILD:-}" ]]; then + APP_BUILD="$GIT_BUILD_NUMBER" + if [[ "$APP_VERSION" =~ ^[0-9]{4}\.[0-9]{1,2}\.[0-9]{1,2}([.-].*)?$ ]]; then + CANONICAL_BUILD="$(sparkle_canonical_build_from_version "$APP_VERSION")" || { + echo "ERROR: Failed to derive canonical Sparkle APP_BUILD from APP_VERSION '$APP_VERSION'." >&2 + exit 1 + } + if [[ "$CANONICAL_BUILD" =~ ^[0-9]+$ ]] && (( CANONICAL_BUILD > APP_BUILD )); then + APP_BUILD="$CANONICAL_BUILD" + fi + fi +fi + +if [[ "$AUTO_CHECKS" == "true" && ! "$APP_BUILD" =~ ^[0-9]+$ ]]; then + echo "ERROR: APP_BUILD must be numeric for Sparkle compare (CFBundleVersion). Got: $APP_BUILD" >&2 + exit 1 +fi + if [[ "${SKIP_TSC:-0}" != "1" ]]; then echo "📦 Building JS (pnpm build)" (cd "$ROOT_DIR" && pnpm build)