mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-27 21:07:01 -06:00
fix(mac): share Swift packaging preflight
This commit is contained in:
@@ -69,7 +69,7 @@ const ANDROID_VERSION_SYNC_PATHS = new Set([
|
||||
"apps/android/version.json",
|
||||
]);
|
||||
const MACOS_APP_CI_PATH_RE =
|
||||
/^(?:apps\/(?:macos|macos-mlx-tts|shared|swabble)\/|Swabble\/|scripts\/(?:codesign-mac-app|create-dmg|notarize-mac-artifact|package-mac-app|package-mac-dist)\.sh$|scripts\/lib\/plistbuddy\.sh$|test\/scripts\/(?:codesign-mac-app|create-dmg|notarize-mac-artifact|package-mac-app|package-mac-dist)\.test\.ts$)/u;
|
||||
/^(?:apps\/(?:macos|macos-mlx-tts|shared|swabble)\/|Swabble\/|scripts\/(?:codesign-mac-app|create-dmg|notarize-mac-artifact|package-mac-app|package-mac-dist)\.sh$|scripts\/lib\/(?:plistbuddy|swift-toolchain)\.sh$|test\/scripts\/(?:codesign-mac-app|create-dmg|notarize-mac-artifact|package-mac-app|package-mac-dist)\.test\.ts$)/u;
|
||||
let corepackPnpmShimDir;
|
||||
let corepackPnpmShimCleanupRegistered = false;
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ const NATIVE_PROTOCOL_GEN_RE = /^apps\/shared\/OpenClawKit\/Sources\/OpenClawPro
|
||||
const MACOS_NATIVE_RE =
|
||||
/^(apps\/macos\/|apps\/macos-mlx-tts\/|apps\/ios\/|apps\/shared\/|apps\/swabble\/|Swabble\/)/;
|
||||
const MACOS_SCRIPT_SCOPE_RE =
|
||||
/^(?:scripts\/(?:codesign-mac-app|create-dmg|notarize-mac-artifact|package-mac-app|package-mac-dist)\.sh|scripts\/lib\/plistbuddy\.sh|test\/scripts\/(?:codesign-mac-app|create-dmg|notarize-mac-artifact|package-mac-app|package-mac-dist)\.test\.ts)$/;
|
||||
/^(?:scripts\/(?:codesign-mac-app|create-dmg|notarize-mac-artifact|package-mac-app|package-mac-dist)\.sh|scripts\/lib\/(?:plistbuddy|swift-toolchain)\.sh|test\/scripts\/(?:codesign-mac-app|create-dmg|notarize-mac-artifact|package-mac-app|package-mac-dist)\.test\.ts)$/;
|
||||
const IOS_BUILD_RE =
|
||||
/^(apps\/ios\/|apps\/shared\/|apps\/swabble\/|Swabble\/|config\/(?:swiftformat|swiftlint\.yml)$|scripts\/ios-(?:configure-signing|team-id|write-version-xcconfig)\.sh$|scripts\/ios-version\.ts$|scripts\/lib\/(?:ios-version\.ts|npm-publish-plan\.mjs|version-script-args\.ts)$)/;
|
||||
const ANDROID_NATIVE_RE = /^(apps\/android\/|apps\/shared\/)/;
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
REQUIRED_SWIFT_TOOLS_MAJOR=6
|
||||
REQUIRED_SWIFT_TOOLS_MINOR=2
|
||||
|
||||
require_swift_toolchain() {
|
||||
local swift_version
|
||||
if ! swift_version="$(swift --version 2>&1)"; then
|
||||
printf '%s\n' "$swift_version" >&2
|
||||
echo "ERROR: OpenClaw macOS app packaging requires Swift tools ${REQUIRED_SWIFT_TOOLS_MAJOR}.${REQUIRED_SWIFT_TOOLS_MINOR}+." >&2
|
||||
echo " Install/select Xcode 26.x or newer before running macOS packaging scripts." >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
local major_minor
|
||||
major_minor="$(printf '%s\n' "$swift_version" | sed -nE 's/.*Apple Swift version ([0-9]+)\.([0-9]+).*/\1 \2/p' | head -n 1)"
|
||||
if [[ -z "$major_minor" ]]; then
|
||||
printf '%s\n' "$swift_version" >&2
|
||||
echo "ERROR: Could not parse selected Swift toolchain version." >&2
|
||||
echo " OpenClaw macOS app packaging requires Swift tools ${REQUIRED_SWIFT_TOOLS_MAJOR}.${REQUIRED_SWIFT_TOOLS_MINOR}+." >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
local major minor
|
||||
read -r major minor <<< "$major_minor"
|
||||
if (( major < REQUIRED_SWIFT_TOOLS_MAJOR )) ||
|
||||
(( major == REQUIRED_SWIFT_TOOLS_MAJOR && minor < REQUIRED_SWIFT_TOOLS_MINOR )); then
|
||||
printf '%s\n' "$swift_version" >&2
|
||||
echo "ERROR: OpenClaw macOS app packaging requires Swift tools ${REQUIRED_SWIFT_TOOLS_MAJOR}.${REQUIRED_SWIFT_TOOLS_MINOR}+." >&2
|
||||
echo " Current Swift is ${major}.${minor}; install/select Xcode 26.x or newer." >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
@@ -6,6 +6,7 @@ set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
source "$ROOT_DIR/scripts/lib/plistbuddy.sh"
|
||||
source "$ROOT_DIR/scripts/lib/swift-toolchain.sh"
|
||||
APP_ROOT="$ROOT_DIR/dist/OpenClaw.app"
|
||||
BUILD_ROOT="$ROOT_DIR/apps/macos/.build"
|
||||
PRODUCT="OpenClaw"
|
||||
@@ -40,8 +41,6 @@ if [[ "$BUNDLE_ID" == *.debug ]]; then
|
||||
SPARKLE_FEED_URL=""
|
||||
AUTO_CHECKS=false
|
||||
fi
|
||||
REQUIRED_SWIFT_TOOLS_MAJOR=6
|
||||
REQUIRED_SWIFT_TOOLS_MINOR=2
|
||||
|
||||
sparkle_canonical_build_from_version() {
|
||||
(cd "$ROOT_DIR" && node --import tsx "$ROOT_DIR/scripts/sparkle-build.ts" canonical-build "$1")
|
||||
@@ -91,35 +90,6 @@ run_pnpm() {
|
||||
(cd "$ROOT_DIR" && "${PNPM_CMD[@]}" "$@")
|
||||
}
|
||||
|
||||
require_swift_toolchain() {
|
||||
local swift_version
|
||||
if ! swift_version="$(swift --version 2>&1)"; then
|
||||
printf '%s\n' "$swift_version" >&2
|
||||
echo "ERROR: OpenClaw macOS app packaging requires Swift tools ${REQUIRED_SWIFT_TOOLS_MAJOR}.${REQUIRED_SWIFT_TOOLS_MINOR}+." >&2
|
||||
echo " Install/select Xcode 26.x or newer before running scripts/package-mac-app.sh." >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
local major_minor
|
||||
major_minor="$(printf '%s\n' "$swift_version" | sed -nE 's/.*Apple Swift version ([0-9]+)\.([0-9]+).*/\1 \2/p' | head -n 1)"
|
||||
if [[ -z "$major_minor" ]]; then
|
||||
printf '%s\n' "$swift_version" >&2
|
||||
echo "ERROR: Could not parse selected Swift toolchain version." >&2
|
||||
echo " OpenClaw macOS app packaging requires Swift tools ${REQUIRED_SWIFT_TOOLS_MAJOR}.${REQUIRED_SWIFT_TOOLS_MINOR}+." >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
local major minor
|
||||
read -r major minor <<< "$major_minor"
|
||||
if (( major < REQUIRED_SWIFT_TOOLS_MAJOR )) ||
|
||||
(( major == REQUIRED_SWIFT_TOOLS_MAJOR && minor < REQUIRED_SWIFT_TOOLS_MINOR )); then
|
||||
printf '%s\n' "$swift_version" >&2
|
||||
echo "ERROR: OpenClaw macOS app packaging requires Swift tools ${REQUIRED_SWIFT_TOOLS_MAJOR}.${REQUIRED_SWIFT_TOOLS_MINOR}+." >&2
|
||||
echo " Current Swift is ${major}.${minor}; install/select Xcode 26.x or newer." >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
merge_framework_machos() {
|
||||
local primary="$1"
|
||||
local dest="$2"
|
||||
|
||||
@@ -10,11 +10,12 @@ set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
source "$ROOT_DIR/scripts/lib/plistbuddy.sh"
|
||||
source "$ROOT_DIR/scripts/lib/swift-toolchain.sh"
|
||||
|
||||
BUILD_ROOT="$ROOT_DIR/apps/macos/.build"
|
||||
PRODUCT="OpenClaw"
|
||||
BUILD_CONFIG="${BUILD_CONFIG:-release}"
|
||||
APP_VERSION_INPUT="${APP_VERSION:-$(cd "$ROOT_DIR" && node -p "require('./package.json').version" 2>/dev/null || echo "0.0.0")}"
|
||||
APP_VERSION_INPUT="${APP_VERSION:-}"
|
||||
|
||||
# Default to universal binary for distribution builds (supports both Apple Silicon and Intel Macs)
|
||||
export BUILD_ARCHS="${BUILD_ARCHS:-all}"
|
||||
@@ -128,6 +129,12 @@ correction_build_from_exact_tag() {
|
||||
|
||||
# Local fallback releases must not silently fall back to a git-rev-count build number.
|
||||
# For correction tags, pass a higher explicit APP_BUILD than the canonical floor.
|
||||
require_swift_toolchain
|
||||
|
||||
if [[ -z "$APP_VERSION_INPUT" ]]; then
|
||||
APP_VERSION_INPUT="$(cd "$ROOT_DIR" && node -p "require('./package.json').version" 2>/dev/null || echo "0.0.0")"
|
||||
fi
|
||||
|
||||
if [[ -z "${APP_BUILD:-}" && "$BUILD_CONFIG" == "release" ]]; then
|
||||
CANONICAL_APP_BUILD="$(require_canonical_sparkle_build "$APP_VERSION_INPUT")"
|
||||
APP_BUILD="$(correction_build_from_exact_tag "$APP_VERSION_INPUT" "$CANONICAL_APP_BUILD")"
|
||||
|
||||
@@ -1233,6 +1233,10 @@ const TOOLING_SOURCE_TEST_TARGETS = new Map([
|
||||
"test/scripts/package-mac-dist.test.ts",
|
||||
],
|
||||
],
|
||||
[
|
||||
"scripts/lib/swift-toolchain.sh",
|
||||
["test/scripts/package-mac-app.test.ts", "test/scripts/package-mac-dist.test.ts"],
|
||||
],
|
||||
[
|
||||
"scripts/lib/plugin-npm-runtime-build.mjs",
|
||||
["test/scripts/plugin-npm-runtime-build-args.test.ts", "test/plugin-npm-runtime-build.test.ts"],
|
||||
|
||||
Reference in New Issue
Block a user