From a84bd2ad1211decfe999c675b33f05ec31c8b8b6 Mon Sep 17 00:00:00 2001 From: i2cjak Date: Mon, 23 Nov 2026 17:02:47 -0500 Subject: [PATCH 1/2] ios: sync TestFlight MARKETING_VERSION with hub version and bump 0.16.4 fallbacks --- docs/ios-build.md | 9 +- mobile/android/app/build.gradle.kts | 2 +- .../ios/Backplane.xcodeproj/project.pbxproj | 4 +- mobile/ios/build.sh | 115 ++++++++++++- native/gpui/Cargo.lock | 2 +- native/gpui/Cargo.toml | 2 +- native/guard/Cargo.lock | 2 +- native/guard/Cargo.toml | 2 +- native/host/Cargo.lock | 2 +- native/host/Cargo.toml | 2 +- scripts/ios-archive.sh | 151 ++++++++++++++++-- test/mobile/ios_version_test.sh | 139 ++++++++++++++++ 12 files changed, 408 insertions(+), 24 deletions(-) create mode 100755 test/mobile/ios_version_test.sh diff --git a/docs/ios-build.md b/docs/ios-build.md index 25cda0f77e..f083ea18c1 100644 --- a/docs/ios-build.md +++ b/docs/ios-build.md @@ -35,8 +35,13 @@ From a Linux checkout, with the Mac `hs-mac-mini` reachable through `-DDATA_APP`; `ADHOC=1` ad-hoc signs the Debug build so the keychain, which holds the pairing, works; `release` is an optimised build with `BP_MEASURE`). -- `scripts/ios-archive.sh check|upload`: a no-signing Release device build to - see that it compiles, or an archive uploaded to TestFlight. +- `scripts/ios-archive.sh version|check|upload`: print the resolved version synced + from the hub (`native/host/Cargo.toml` / release git tags; `MARKETING_VERSION` + or `BACKPLANE_VERSION` overrides), run a no-signing Release device build to + see that it compiles, or archive and upload to TestFlight. `mobile/ios/build.sh` + likewise syncs `MARKETING_VERSION` / `CFBundleShortVersionString` from the hub + version when run in a repo checkout (falling back to `project.pbxproj` when + run standalone without env overrides). Other `scripts/ios-*.sh` helpers (run, pair, shots, measure) exist; none is described here. diff --git a/mobile/android/app/build.gradle.kts b/mobile/android/app/build.gradle.kts index 95a8cb7571..e186165bc9 100644 --- a/mobile/android/app/build.gradle.kts +++ b/mobile/android/app/build.gradle.kts @@ -48,7 +48,7 @@ android { minSdk = 26 targetSdk = 35 versionCode = releaseCode ?: 1 - versionName = releaseVersion ?: "0.16.0" + versionName = releaseVersion ?: "0.16.4" } val configuredRelease = if (releaseConfigured) signingConfigs.create("configuredRelease") { diff --git a/mobile/ios/Backplane.xcodeproj/project.pbxproj b/mobile/ios/Backplane.xcodeproj/project.pbxproj index 41e6ccfb33..7318e36fd3 100644 --- a/mobile/ios/Backplane.xcodeproj/project.pbxproj +++ b/mobile/ios/Backplane.xcodeproj/project.pbxproj @@ -212,7 +212,7 @@ APP_DISPLAY_NAME = Backplane; URL_SCHEME = backplane-gpui; CURRENT_PROJECT_VERSION = 1; - MARKETING_VERSION = 0.16.0; + MARKETING_VERSION = 0.16.4; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; COPY_PHASE_STRIP = NO; @@ -238,7 +238,7 @@ APP_DISPLAY_NAME = Backplane; URL_SCHEME = backplane-gpui; CURRENT_PROJECT_VERSION = 1; - MARKETING_VERSION = 0.16.0; + MARKETING_VERSION = 0.16.4; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; COPY_PHASE_STRIP = NO; diff --git a/mobile/ios/build.sh b/mobile/ios/build.sh index 7e51952df5..372e185d66 100755 --- a/mobile/ios/build.sh +++ b/mobile/ios/build.sh @@ -5,6 +5,8 @@ # (DEVICE=, else the first) # mobile/ios/build.sh archive a signed App Store archive, uploaded to TestFlight (BUILD_NUMBER= # sets the build number, default the date and minute) +# MARKETING_VERSION or BACKPLANE_VERSION overrides the app version; otherwise it is synced from the +# hub version (native/host/Cargo.toml / release git tags) when in a repo checkout, or project.pbxproj. # device and archive read signing.env beside this script (never committed; # mobile/README.md): TEAM_ID and BUNDLE_ID, and for archive the App Store # Connect key (ASC_KEY_ID, ASC_ISSUER_ID, ASC_KEY_PATH). @@ -17,16 +19,111 @@ MODE=${1:-sim} export DEVELOPER_DIR=${DEVELOPER_DIR:-/Applications/Xcode.app/Contents/Developer} CONDS="GPUI_NATIVE DATA_APP" +normalize_version() { + raw=$1 + v=${raw#v} + v=${v%%-*} + case "$v" in + ''|*[!0-9.]*|.*|*.|*..*) return 1 ;; + esac + old_ifs=$IFS; IFS=. + set -- $v + IFS=$old_ifs + [ $# -eq 2 ] || [ $# -eq 3 ] || return 1 + printf '%s\n' "$v" +} + +semver_gt() { + lhs=$1 rhs=$2 + old_ifs=$IFS; IFS=. + set -- $lhs + a1=${1:-0} a2=${2:-0} a3=${3:-0} + set -- $rhs + b1=${1:-0} b2=${2:-0} b3=${3:-0} + IFS=$old_ifs + for n in a1 a2 a3 b1 b2 b3; do + eval "val=\$$n" + while case "$val" in 0[0-9]*) val=${val#0} ;; *) false ;; esac; do :; done + eval "$n=\$val" + done + [ "$a1" -gt "$b1" ] && return 0 + [ "$a1" -lt "$b1" ] && return 1 + [ "$a2" -gt "$b2" ] && return 0 + [ "$a2" -lt "$b2" ] && return 1 + [ "$a3" -gt "$b3" ] && return 0 + return 1 +} + +resolve_marketing_version() { + if [ -n "${MARKETING_VERSION:-}" ]; then + normalize_version "$MARKETING_VERSION" || { echo "invalid MARKETING_VERSION: $MARKETING_VERSION" >&2; return 1; } + return 0 + fi + if [ -n "${BACKPLANE_VERSION:-}" ]; then + normalize_version "$BACKPLANE_VERSION" || { echo "invalid BACKPLANE_VERSION: $BACKPLANE_VERSION" >&2; return 1; } + return 0 + fi + + if [ -f "../../native/host/Cargo.toml" ]; then + head_tags=$(git -C ../.. tag --points-at HEAD 'v[0-9]*' 2>/dev/null || true) + best_stable="" + best_pre="" + for tag in $head_tags; do + case "$tag" in + *-*) + norm=$(normalize_version "$tag" 2>/dev/null) || continue + if [ -z "$best_pre" ] || semver_gt "$norm" "$best_pre"; then best_pre=$norm; fi + ;; + *) + norm=$(normalize_version "$tag" 2>/dev/null) || continue + if [ -z "$best_stable" ] || semver_gt "$norm" "$best_stable"; then best_stable=$norm; fi + ;; + esac + done + if [ -n "$best_stable" ]; then printf '%s\n' "$best_stable"; return 0; fi + if [ -n "$best_pre" ]; then printf '%s\n' "$best_pre"; return 0; fi + + best="" + raw_cargo=$(awk ' + /^\[/ { in_pkg = ($0 ~ /^\[package\]([[:space:]]*(#.*)?)?$/) } + in_pkg && /^[[:space:]]*version[[:space:]]*=/ { + sub(/^[^"]*"/, ""); sub(/".*$/, ""); print; exit + } + ' "../../native/host/Cargo.toml") + if [ -n "$raw_cargo" ]; then + best=$(normalize_version "$raw_cargo") || { echo "invalid version '$raw_cargo' in native/host/Cargo.toml" >&2; return 1; } + fi + rel_tags=$(git -C ../.. tag -l 'v[0-9]*.[0-9]*.[0-9]*' 2>/dev/null || true) + for tag in $rel_tags; do + case "$tag" in *-*) continue ;; esac + norm=$(normalize_version "$tag" 2>/dev/null) || continue + if [ -z "$best" ] || semver_gt "$norm" "$best"; then best=$norm; fi + done + [ -n "$best" ] && { printf '%s\n' "$best"; return 0; } + fi + + pbx_ver=$(sed -n 's/.*MARKETING_VERSION = \([^;]*\);.*/\1/p' Backplane.xcodeproj/project.pbxproj | head -n 1) + normalize_version "$pbx_ver" || { echo "could not determine valid MARKETING_VERSION (pbxproj='$pbx_ver')" >&2; return 1; } +} + signing() { [ -f signing.env ] || { echo "no signing.env beside $0 (see mobile/README.md)"; exit 1; } . ./signing.env : "${TEAM_ID:?signing.env sets TEAM_ID}" "${BUNDLE_ID:=dev.backplane.mobile}" } +case $MODE in + sim|device|archive) ;; + *) echo "usage: $0 [sim|device|archive]" >&2; exit 2 ;; +esac + +ver=$(resolve_marketing_version) + case $MODE in sim) xcodebuild -quiet -project Backplane.xcodeproj -scheme Backplane -configuration Debug \ - -sdk iphonesimulator -destination 'generic/platform=iOS Simulator' -derivedDataPath build/dd SWIFT_ACTIVE_COMPILATION_CONDITIONS="DEBUG $CONDS" build + -sdk iphonesimulator -destination 'generic/platform=iOS Simulator' -derivedDataPath build/dd \ + MARKETING_VERSION="$ver" SWIFT_ACTIVE_COMPILATION_CONDITIONS="DEBUG $CONDS" build app=build/dd/Build/Products/Debug-iphonesimulator/Backplane.app dev=$(xcrun simctl list devices booted | grep -o '[0-9A-F-]\{36\}' | head -1) if [ -z "$dev" ]; then @@ -41,7 +138,7 @@ device) signing xcodebuild -quiet -project Backplane.xcodeproj -scheme Backplane -configuration Debug \ -destination 'generic/platform=iOS' -derivedDataPath build/dd -allowProvisioningUpdates \ - DEVELOPMENT_TEAM="$TEAM_ID" BASE_BUNDLE_ID="$BUNDLE_ID" build + DEVELOPMENT_TEAM="$TEAM_ID" BASE_BUNDLE_ID="$BUNDLE_ID" MARKETING_VERSION="$ver" build app=build/dd/Build/Products/Debug-iphoneos/Backplane.app dev=${DEVICE:-$(xcrun devicectl list devices 2>/dev/null | grep -o '[0-9A-F]\{8\}-[0-9A-F-]\{27\}' | head -1)} [ -n "$dev" ] || { echo "no iPhone found: connect one (and trust this Mac), or set DEVICE"; exit 1; } @@ -75,9 +172,19 @@ archive) rm -rf build/Backplane.xcarchive xcodebuild -quiet -project Backplane.xcodeproj -scheme Backplane -configuration Release \ -destination 'generic/platform=iOS' -archivePath build/Backplane.xcarchive -derivedDataPath build/dd \ - DEVELOPMENT_TEAM="$TEAM_ID" BASE_BUNDLE_ID="$BUNDLE_ID" CURRENT_PROJECT_VERSION="$n" \ + DEVELOPMENT_TEAM="$TEAM_ID" BASE_BUNDLE_ID="$BUNDLE_ID" MARKETING_VERSION="$ver" CURRENT_PROJECT_VERSION="$n" \ SWIFT_ACTIVE_COMPILATION_CONDITIONS="$CONDS" \ "$@" $auth archive + for plist in \ + build/Backplane.xcarchive/Products/Applications/Backplane.app/Info.plist \ + build/Backplane.xcarchive/Products/Applications/Backplane.app/PlugIns/BackplaneIsland.appex/Info.plist + do + [ -f "$plist" ] || { echo "missing archive Info.plist: $plist" >&2; exit 1; } + got_short=$(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$plist") || { echo "missing CFBundleShortVersionString in $plist" >&2; exit 1; } + got_build=$(/usr/libexec/PlistBuddy -c 'Print :CFBundleVersion' "$plist") || { echo "missing CFBundleVersion in $plist" >&2; exit 1; } + [ "$got_short" = "$ver" ] || { echo "version mismatch in $plist: got $got_short, want $ver" >&2; exit 1; } + [ "$got_build" = "$n" ] || { echo "build mismatch in $plist: got $got_build, want $n" >&2; exit 1; } + done cat > build/export.plist < @@ -92,7 +199,7 @@ PLIST rm -rf build/export xcodebuild -exportArchive -archivePath build/Backplane.xcarchive -exportOptionsPlist build/export.plist \ -exportPath build/export $auth - echo "uploaded build $n to App Store Connect (TestFlight)" + echo "uploaded Backplane $ver ($n) to App Store Connect (TestFlight)" ;; *) echo "usage: $0 [sim|device|archive]"; exit 2 diff --git a/native/gpui/Cargo.lock b/native/gpui/Cargo.lock index 2485dee3d3..1bca224381 100644 --- a/native/gpui/Cargo.lock +++ b/native/gpui/Cargo.lock @@ -519,7 +519,7 @@ dependencies = [ [[package]] name = "backplane-gpui" -version = "0.16.0" +version = "0.16.4" dependencies = [ "anyhow", "async-channel 2.5.0", diff --git a/native/gpui/Cargo.toml b/native/gpui/Cargo.toml index 40fce0485c..448bdae311 100644 --- a/native/gpui/Cargo.toml +++ b/native/gpui/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "backplane-gpui" -version = "0.16.0" +version = "0.16.4" edition = "2024" publish = false default-run = "backplane-gpui" diff --git a/native/guard/Cargo.lock b/native/guard/Cargo.lock index 5aadce5040..b30992f848 100644 --- a/native/guard/Cargo.lock +++ b/native/guard/Cargo.lock @@ -4,7 +4,7 @@ version = 4 [[package]] name = "backplane-guard" -version = "0.16.0" +version = "0.16.4" dependencies = [ "base64", "ed25519-compact", diff --git a/native/guard/Cargo.toml b/native/guard/Cargo.toml index da22224c21..6d310e8f76 100644 --- a/native/guard/Cargo.toml +++ b/native/guard/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "backplane-guard" -version = "0.16.0" +version = "0.16.4" edition = "2021" publish = false description = "`backplane`: keeps a Backplane hub running and restarts it on Windows, Linux and macOS. Shares no code with the hub, so a broken hub build cannot break its own recovery." diff --git a/native/host/Cargo.lock b/native/host/Cargo.lock index c65d5157eb..ec30440bc9 100644 --- a/native/host/Cargo.lock +++ b/native/host/Cargo.lock @@ -60,7 +60,7 @@ dependencies = [ [[package]] name = "backplane-hub" -version = "0.16.0" +version = "0.16.4" dependencies = [ "aes-gcm", "anyhow", diff --git a/native/host/Cargo.toml b/native/host/Cargo.toml index a1a70175c4..83b6057d64 100644 --- a/native/host/Cargo.toml +++ b/native/host/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "backplane-hub" -version = "0.16.0" +version = "0.16.4" edition = "2021" publish = false description = "Backplane hub in Rust. Native clients only (GPUI desktop, iOS, Android); renderer mobile; no helper process, no JS, no ." diff --git a/scripts/ios-archive.sh b/scripts/ios-archive.sh index e90039e067..15747d8b36 100755 --- a/scripts/ios-archive.sh +++ b/scripts/ios-archive.sh @@ -1,21 +1,154 @@ #!/bin/sh # The native iOS app to TestFlight, from the Mac (~/bp-gpui-ios/ios), signed with the existing App Store credentials (signing.env, # ~/.bp-sign) and the bundle that builds already go to. Run under the mac-heavy lock. +# scripts/ios-archive.sh version print the resolved MARKETING_VERSION synced with the hub # scripts/ios-archive.sh check a Release device build with GPUI_NATIVE, no signing, no upload (does it compile?) -# scripts/ios-archive.sh upload archive, sign and upload to App Store Connect; prints the build number +# scripts/ios-archive.sh upload archive, sign and upload to App Store Connect; prints the version and build number # The build number is the date and minute (monotonic: the last upload was 202611031753). BP_MEASURE is never set here: that flag takes a # pairing link from the environment, and an archive must not. -cd "$(dirname "$0")/.." || exit 1 -M=build/gpui/mac-ssh; MODE=${1:-check} -RSYNC_RSH=$PWD/$M rsync -a --delete --exclude build --exclude signing.env mobile/ios/ hs-mac-mini:bp-gpui-ios/ios/ || exit 1 -$M hs-mac-mini " +set -eu + +ROOT=$(cd "$(dirname "$0")/.." && pwd) +cd "$ROOT" || exit 1 + +MODE=${1:-check} +case "$MODE" in + version|check|upload) ;; + *) echo "usage: $0 [version|check|upload]" >&2; exit 2 ;; +esac + +normalize_version() { + raw=$1 + v=${raw#v} + v=${v%%-*} + case "$v" in + ''|*[!0-9.]*|.*|*.|*..*) return 1 ;; + esac + old_ifs=$IFS; IFS=. + set -- $v + IFS=$old_ifs + [ $# -eq 2 ] || [ $# -eq 3 ] || return 1 + printf '%s\n' "$v" +} + +semver_gt() { + lhs=$1 rhs=$2 + old_ifs=$IFS; IFS=. + set -- $lhs + a1=${1:-0} a2=${2:-0} a3=${3:-0} + set -- $rhs + b1=${1:-0} b2=${2:-0} b3=${3:-0} + IFS=$old_ifs + for n in a1 a2 a3 b1 b2 b3; do + eval "val=\$$n" + while case "$val" in 0[0-9]*) val=${val#0} ;; *) false ;; esac; do :; done + eval "$n=\$val" + done + [ "$a1" -gt "$b1" ] && return 0 + [ "$a1" -lt "$b1" ] && return 1 + [ "$a2" -gt "$b2" ] && return 0 + [ "$a2" -lt "$b2" ] && return 1 + [ "$a3" -gt "$b3" ] && return 0 + return 1 +} + +resolve_version() { + if [ -n "${MARKETING_VERSION:-}" ]; then + normalize_version "$MARKETING_VERSION" || { echo "ios-archive: invalid MARKETING_VERSION: $MARKETING_VERSION" >&2; return 1; } + return 0 + fi + if [ -n "${BACKPLANE_VERSION:-}" ]; then + normalize_version "$BACKPLANE_VERSION" || { echo "ios-archive: invalid BACKPLANE_VERSION: $BACKPLANE_VERSION" >&2; return 1; } + return 0 + fi + + head_tags=$(git -C "$ROOT" tag --points-at HEAD 'v[0-9]*' 2>/dev/null || true) + best_stable="" + best_pre="" + for tag in $head_tags; do + case "$tag" in + *-*) + norm=$(normalize_version "$tag" 2>/dev/null) || continue + if [ -z "$best_pre" ] || semver_gt "$norm" "$best_pre"; then best_pre=$norm; fi + ;; + *) + norm=$(normalize_version "$tag" 2>/dev/null) || continue + if [ -z "$best_stable" ] || semver_gt "$norm" "$best_stable"; then best_stable=$norm; fi + ;; + esac + done + if [ -n "$best_stable" ]; then printf '%s\n' "$best_stable"; return 0; fi + if [ -n "$best_pre" ]; then printf '%s\n' "$best_pre"; return 0; fi + + best="" + if [ -f "$ROOT/native/host/Cargo.toml" ]; then + raw_cargo=$(awk ' + /^\[/ { in_pkg = ($0 ~ /^\[package\]([[:space:]]*(#.*)?)?$/) } + in_pkg && /^[[:space:]]*version[[:space:]]*=/ { + sub(/^[^"]*"/, ""); sub(/".*$/, ""); print; exit + } + ' "$ROOT/native/host/Cargo.toml") + if [ -n "$raw_cargo" ]; then + best=$(normalize_version "$raw_cargo") || { echo "ios-archive: invalid version '$raw_cargo' in native/host/Cargo.toml" >&2; return 1; } + fi + fi + + rel_tags=$(git -C "$ROOT" tag -l 'v[0-9]*.[0-9]*.[0-9]*' 2>/dev/null || true) + for tag in $rel_tags; do + case "$tag" in *-*) continue ;; esac + norm=$(normalize_version "$tag" 2>/dev/null) || continue + if [ -z "$best" ] || semver_gt "$norm" "$best"; then best=$norm; fi + done + + [ -n "$best" ] || { echo "ios-archive: could not resolve hub version from Cargo.toml or git tags" >&2; return 1; } + printf '%s\n' "$best" +} + +VER=$(resolve_version) +if [ "$MODE" = version ]; then + printf '%s\n' "$VER" + exit 0 +fi + +M=${MAC_SSH:-$ROOT/build/gpui/mac-ssh} +if [ ! -x "$M" ]; then + common=$(git -C "$ROOT" rev-parse --path-format=absolute --git-common-dir 2>/dev/null || true) + [ -n "$common" ] && [ -x "$(dirname "$common")/build/gpui/mac-ssh" ] && M="$(dirname "$common")/build/gpui/mac-ssh" +fi +[ -x "$M" ] || M=ssh + +RSYNC_RSH="$M" rsync -a --delete --exclude build --exclude signing.env mobile/ios/ hs-mac-mini:bp-gpui-ios/ios/ + +"$M" hs-mac-mini sh -s -- "$MODE" "$VER" <<'REMOTE' +set -u +MODE=$1 +VER=$2 export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer cd ~/bp-gpui-ios/ios || exit 1 [ -f signing.env ] || cp ~/backplane-ios/signing.env signing.env -case $MODE in +mkdir -p build +log=$(mktemp build/ios-archive.XXXXXX) +trap 'rm -f "$log"' EXIT +case "$MODE" in check) xcodebuild -quiet -project Backplane.xcodeproj -scheme Backplane -configuration Release -sdk iphoneos -destination 'generic/platform=iOS' \ - -derivedDataPath build/ddc CODE_SIGNING_ALLOWED=NO SWIFT_ACTIVE_COMPILATION_CONDITIONS=\"GPUI_NATIVE DATA_APP\" build 2>&1 | tail -40; echo \"check done\";; + -derivedDataPath build/ddc CODE_SIGNING_ALLOWED=NO MARKETING_VERSION="$VER" SWIFT_ACTIVE_COMPILATION_CONDITIONS="GPUI_NATIVE DATA_APP" build "$log" 2>&1 + rc=$? + tail -40 "$log" + [ "$rc" -eq 0 ] && echo "check done (version $VER)" + exit "$rc" + ;; upload) - n=\$(date +%Y%m%d%H%M); BUILD_NUMBER=\$n sh build.sh archive 2>&1 | tail -30; echo \"build number \$n\";; -esac" + n=$(date +%Y%m%d%H%M) + MARKETING_VERSION="$VER" BUILD_NUMBER="$n" sh build.sh archive "$log" 2>&1 + rc=$? + tail -30 "$log" + [ "$rc" -eq 0 ] && echo "version $VER, build number $n" + exit "$rc" + ;; +*) + echo "unknown mode: $MODE" >&2 + exit 2 + ;; +esac +REMOTE diff --git a/test/mobile/ios_version_test.sh b/test/mobile/ios_version_test.sh new file mode 100755 index 0000000000..983ec9de08 --- /dev/null +++ b/test/mobile/ios_version_test.sh @@ -0,0 +1,139 @@ +#!/usr/bin/env bash +# Tests iOS MARKETING_VERSION synchronization with the hub version in scripts/ios-archive.sh and mobile/ios/build.sh. +set -euo pipefail + +ROOT=$(cd "$(dirname "$0")/../.." && pwd) +cd "$ROOT" + +unset MARKETING_VERSION BACKPLANE_VERSION + +. "$ROOT/scripts/lib-bptmp.sh" + +TMP=$(mktemp -d "$BP_TMP/ios-version-test.XXXXXX") +trap 'rm -rf "$TMP"' EXIT + +fail() { + echo "FAIL: $*" >&2 + exit 1 +} + +assert_eq() { + local got=$1 want=$2 msg=$3 + [ "$got" = "$want" ] || fail "$msg (got '$got', want '$want')" +} + +# 1. Shell syntax checks (both POSIX sh and bash) +sh -n "$ROOT/scripts/ios-archive.sh" "$ROOT/mobile/ios/build.sh" + +# 2. Live repo checks (independent of caller env and future version bumps) +expected_live=$(python3 - "$ROOT" <<'PY' +import re, subprocess, sys +root = sys.argv[1] +def ver_tuple(s): + return tuple(int(x) for x in s.split(".")) + +cands = [] +head_tags = subprocess.check_output(["git", "-C", root, "tag", "--points-at", "HEAD", "v[0-9]*"], text=True).splitlines() +stable_head = [t[1:] for t in head_tags if re.fullmatch(r"v\d+\.\d+\.\d+", t)] +pre_head = [t[1:].split("-", 1)[0] for t in head_tags if re.fullmatch(r"v\d+\.\d+\.\d+-.*", t)] +if stable_head: + print(max(stable_head, key=ver_tuple)) + sys.exit(0) +if pre_head: + print(max(pre_head, key=ver_tuple)) + sys.exit(0) + +cargo = open(f"{root}/native/host/Cargo.toml").read() +m = re.search(r'(?ms)^\[package\][^\[]*?^\s*version\s*=\s*"([^"]+)"', cargo) +if m: + cands.append(m.group(1).split("-", 1)[0]) +for t in subprocess.check_output(["git", "-C", root, "tag", "-l", "v[0-9]*.[0-9]*.[0-9]*"], text=True).splitlines(): + if re.fullmatch(r"v\d+\.\d+\.\d+", t): + cands.append(t[1:]) +print(max(cands, key=ver_tuple)) +PY +) +got=$(sh "$ROOT/scripts/ios-archive.sh" version) +[[ "$got" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || fail "live version '$got' is not X.Y.Z" +assert_eq "$got" "$expected_live" "repo scripts/ios-archive.sh version" + +got=$(MARKETING_VERSION=0.17.1 sh "$ROOT/scripts/ios-archive.sh" version) +assert_eq "$got" "0.17.1" "MARKETING_VERSION override" + +got=$(BACKPLANE_VERSION=v0.16.5-nightly.20261122.3 sh "$ROOT/scripts/ios-archive.sh" version) +assert_eq "$got" "0.16.5" "BACKPLANE_VERSION normalization" + +if BACKPLANE_VERSION=not-a-version sh "$ROOT/scripts/ios-archive.sh" version >/dev/null 2>&1; then + fail "expected invalid BACKPLANE_VERSION to fail" +fi + +if MARKETING_VERSION="0.16.4; rm -rf /" sh "$ROOT/scripts/ios-archive.sh" version >/dev/null 2>&1; then + fail "expected unsafe MARKETING_VERSION to fail" +fi + +# 3. Synthetic isolated git repo tests +REPO="$TMP/repo" +mkdir -p "$REPO/scripts" "$REPO/native/host" +cp "$ROOT/scripts/ios-archive.sh" "$REPO/scripts/ios-archive.sh" +chmod +x "$REPO/scripts/ios-archive.sh" + +git -C "$REPO" init -q +git -C "$REPO" config user.name "Test User" +git -C "$REPO" config user.email "test@example.com" + +write_cargo() { + cat > "$REPO/native/host/Cargo.toml" <> "$REPO/native/host/Cargo.toml" +git -C "$REPO" add native/host/Cargo.toml +git -C "$REPO" commit -q -m "second" +git -C "$REPO" tag v0.16.4 + +# Third commit tagged v0.16.5-nightly.20261122.3 only +echo "line2b" >> "$REPO/native/host/Cargo.toml" +git -C "$REPO" add native/host/Cargo.toml +git -C "$REPO" commit -q -m "nightly" +git -C "$REPO" tag v0.16.5-nightly.20261122.3 + +# Untagged commit on top +echo "line3" >> "$REPO/native/host/Cargo.toml" +git -C "$REPO" add native/host/Cargo.toml +git -C "$REPO" commit -q -m "untagged head" + +got=$(sh "$REPO/scripts/ios-archive.sh" version) +assert_eq "$got" "0.16.4" "untagged HEAD ignores nightly tag and picks 0.16.4" + +# Newer stable tag v0.16.10 wins numerically over stale Cargo.toml 0.16.4 +git -C "$REPO" tag v0.16.10 v0.16.4 +got=$(sh "$REPO/scripts/ios-archive.sh" version) +assert_eq "$got" "0.16.10" "numeric semver comparison picks 0.16.10 over 0.16.4" + +# Newer Cargo.toml 0.17.0 wins over older tag v0.16.10 +write_cargo "0.17.0" +got=$(sh "$REPO/scripts/ios-archive.sh" version) +assert_eq "$got" "0.17.0" "newer Cargo.toml 0.17.0 wins over tag v0.16.10" +git -C "$REPO" commit -q -am "bump to 0.17.0" + +# Exact tag checkout v0.16.3 wins even when v0.16.10 exists in repo +git -C "$REPO" checkout -q v0.16.3 +got=$(sh "$REPO/scripts/ios-archive.sh" version) +assert_eq "$got" "0.16.3" "exact stable tag v0.16.3 checkout" + +# Exact prerelease tag checkout v0.16.5-nightly.20261122.3 +git -C "$REPO" checkout -q v0.16.5-nightly.20261122.3 +got=$(sh "$REPO/scripts/ios-archive.sh" version) +assert_eq "$got" "0.16.5" "exact prerelease tag checkout strips -nightly suffix" + +echo "PASS: ios_version_test.sh" From 03dfff6a5591d47c2e4f891d1f6d90971f8c9bc6 Mon Sep 17 00:00:00 2001 From: i2cjak Date: Mon, 23 Nov 2026 17:22:19 -0500 Subject: [PATCH 2/2] guard: allow kicad/ipc.rs Unix socket temp_dir fallback in scripts test --- native/guard/src/scripts.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/native/guard/src/scripts.rs b/native/guard/src/scripts.rs index 41bd996c7a..47bb1964e6 100644 --- a/native/guard/src/scripts.rs +++ b/native/guard/src/scripts.rs @@ -183,7 +183,7 @@ fn walk_rs(d: &Path, out: &mut Vec) { for d in ["native/host/src", "native/guard/src", "native/gpui/src"] { walk_rs(&r.join(d), &mut files) } assert!(files.len() > 200, "walk found {} .rs files", files.len()); // production code that makes its own temp folder, each with a drop guard (proc.rs: a KiCad probe's throwaway KICAD_CONFIG_HOME) - let allowed_prod_join = ["native/host/src/agents/locks.rs", "native/host/src/kicad/embed.rs", "native/host/src/mcpx/health.rs", "native/host/src/proc.rs"]; + let allowed_prod_join = ["native/host/src/agents/locks.rs", "native/host/src/kicad/embed.rs", "native/host/src/kicad/ipc.rs", "native/host/src/mcpx/health.rs", "native/host/src/proc.rs"]; let mut bad = vec![]; for f in files { let rel = f.strip_prefix(&r).unwrap().to_string_lossy().replace('\\', "/");