openclaw/scripts/ios-write-version-xcconfig.sh
Peter Steinberger 299ea7c393
fix(scripts): run macOS tooling under /bin/bash and make the framework-merge fixture self-contained (#141884)
* fix(scripts): use system Bash for macOS tooling and owned Mach-O fixtures

Pin native entrypoints and package commands to /bin/bash, guard portable heredoc callers on Darwin, and preserve Bash 3.2 boolean parsing. Streamed installers explain how to use system Bash when their input cannot be replayed.

Generate deterministic x86_64, arm64, and arm64e framework fixtures instead of borrowing /bin/ls. Preserve the existing framework pipeline repair from #141056 and verify merged slice bytes.

* fix(scripts): keep guarded portable scripts bash 3.2 compatible

* fix(scripts): keep macOS Bash CI coverage green

Distinguish sourced installer returns from stdin exits without ShellCheck unreachable-code warnings. Retain the shebang regression suite in changed-target routing, and repartition hosted tooling tails toward 50-second groups within the existing 150-second budget and 80-job cap.

Validation: 635 interpreter and routing tests plus 53 planner tests passed; ShellCheck, targeted lint, formatting, and fresh Codex review passed. The broader local changed-file check hit an unrelated existing dependency graph crossing through extensions/reef/node_modules/@noble/hashes; exact-head hosted CI remains required.

* docs(install): use system Bash in install and recovery commands

Align macOS-facing copy-and-paste commands and emitted installer guidance with the supported streamed interpreter. This addresses the remaining installer-command review finding without changing the PR body.

Validation: streamed help for both installers, install.sh dry-run, 16 selected fresh-install and upgrade lifecycle tests, formatting, diff check, and fresh Codex review passed. Landing remains blocked by unrelated provider-transport integration CI failure caused by an unchanged incomplete plugin-registry mock.

* fix(scripts): preserve streamed installs and CI packing

Keep public installer commands portable while replaying Darwin Bash 5.3+
stdin under system Bash through an immediately unlinked private temp file.
Retain actionable sourced-install rejection and the SC2317-safe check.

Restore the original CI packing policy and move the Bash policy scan into
its existing macOS tooling owner without adding a routed test file.

Validation: real Homebrew Bash streamed help and cleanup; 642 scan/routing
tests; 23 selected installer tests under both PATH orders; planner cap and
coverage tests; 139 Bash syntax checks; ShellCheck; 1,135 changed-gate tests;
focused lint/changed-check repair; fresh Codex review with no P0/P1 findings.
2026-09-08 01:21:30 -07:00

148 lines
3.8 KiB
Bash
Executable file

#!/bin/bash
set -euo pipefail
usage() {
cat <<'EOF'
Usage:
scripts/ios-write-version-xcconfig.sh [--version 2026.7.2] [--revision 1] [--build-number 3]
Writes apps/ios/build/Version.xcconfig from apps/mobile/version.json or explicit --version:
- OPENCLAW_IOS_VERSION = exact canonical iOS version
- OPENCLAW_MARKETING_VERSION = short iOS/App Store version
- OPENCLAW_BUILD_VERSION = explicit build number or local numeric fallback
EOF
}
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
source "${ROOT_DIR}/scripts/lib/build-metadata.sh"
IOS_DIR="${ROOT_DIR}/apps/ios"
BUILD_DIR="${IOS_DIR}/build"
VERSION_XCCONFIG="${IOS_DIR}/build/Version.xcconfig"
VERSION_HELPER="${ROOT_DIR}/scripts/ios-version.ts"
IOS_VERSION=""
MARKETING_VERSION=""
BUILD_NUMBER=""
APP_STORE_REVISION=""
RELEASE_VERSION=""
RESOLVED_GIT_COMMIT=""
RESOLVED_BUILD_TIMESTAMP=""
require_option_value() {
local option="$1"
local value="${2-}"
if [[ -z "${value}" || "${value}" == --* ]]; then
echo "Missing value for ${option}." >&2
usage >&2
exit 1
fi
}
prepare_build_dir() {
if [[ -L "${BUILD_DIR}" ]]; then
echo "Refusing to use symlinked build directory: ${BUILD_DIR}" >&2
exit 1
fi
mkdir -p "${BUILD_DIR}"
}
write_generated_file() {
local output_path="$1"
local tmp_file=""
if [[ -e "${output_path}" && -L "${output_path}" ]]; then
echo "Refusing to overwrite symlinked file: ${output_path}" >&2
exit 1
fi
tmp_file="$(mktemp "${output_path}.XXXXXX")"
cat >"${tmp_file}"
mv -f "${tmp_file}" "${output_path}"
}
while [[ $# -gt 0 ]]; do
case "$1" in
--)
shift
;;
--build-number)
require_option_value "$1" "${2-}"
BUILD_NUMBER="${2:-}"
shift 2
;;
--revision)
require_option_value "$1" "${2-}"
APP_STORE_REVISION="${2:-}"
shift 2
;;
--version)
require_option_value "$1" "${2-}"
RELEASE_VERSION="${2:-}"
shift 2
;;
-h|--help)
usage
exit 0
;;
*)
echo "Unknown argument: $1" >&2
usage
exit 1
;;
esac
done
VERSION_HELPER_ARGS=(--shell)
if [[ -n "${RELEASE_VERSION}" ]]; then
VERSION_HELPER_ARGS+=(--version "${RELEASE_VERSION}")
fi
if [[ -n "${APP_STORE_REVISION}" ]]; then
if [[ -z "${RELEASE_VERSION}" ]]; then
echo "--revision requires an explicit --version." >&2
exit 1
fi
VERSION_HELPER_ARGS+=(--revision "${APP_STORE_REVISION}")
fi
while IFS='=' read -r key value; do
case "${key}" in
OPENCLAW_IOS_VERSION)
IOS_VERSION="${value}"
;;
OPENCLAW_MARKETING_VERSION)
MARKETING_VERSION="${value}"
;;
esac
done < <(cd "${ROOT_DIR}" && node --import tsx "${VERSION_HELPER}" "${VERSION_HELPER_ARGS[@]}")
if [[ -z "${IOS_VERSION}" || -z "${MARKETING_VERSION}" ]]; then
echo "Unable to resolve iOS version metadata." >&2
exit 1
fi
if [[ -z "${BUILD_NUMBER}" ]]; then
BUILD_NUMBER="$(cd "${ROOT_DIR}" && git rev-list --count HEAD 2>/dev/null || printf '0')"
fi
if [[ ! "${BUILD_NUMBER}" =~ ^[0-9]+$ ]]; then
echo "Invalid build number '${BUILD_NUMBER}'. Expected digits only." >&2
exit 1
fi
RESOLVED_GIT_COMMIT="$(openclaw_resolve_git_commit "${ROOT_DIR}")"
RESOLVED_BUILD_TIMESTAMP="$(openclaw_resolve_build_timestamp)"
prepare_build_dir
write_generated_file "${VERSION_XCCONFIG}" <<EOF
// Auto-generated by scripts/ios-write-version-xcconfig.sh.
// Local version override; do not commit.
OPENCLAW_IOS_VERSION = ${IOS_VERSION}
OPENCLAW_MARKETING_VERSION = ${MARKETING_VERSION}
OPENCLAW_BUILD_VERSION = ${BUILD_NUMBER}
OPENCLAW_GIT_COMMIT = ${RESOLVED_GIT_COMMIT}
OPENCLAW_BUILD_TIMESTAMP = ${RESOLVED_BUILD_TIMESTAMP}
EOF
echo "Prepared iOS version settings: ios=${IOS_VERSION} marketing=${MARKETING_VERSION} build=${BUILD_NUMBER} commit=${RESOLVED_GIT_COMMIT} built=${RESOLVED_BUILD_TIMESTAMP}"