mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-05-26 01:04:30 +00:00
ios: add "update" scripts (#7004)
This commit is contained in:
Executable
+88
@@ -0,0 +1,88 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Updates libHSsimplex-chat-*.a references in project.pbxproj to match the
|
||||
# libraries currently in apps/ios/Libraries/ios (populated by prepare.sh).
|
||||
# Handles both the plain .a and the -ghc*.a variant.
|
||||
|
||||
set -e
|
||||
|
||||
PBXPROJ=./apps/ios/SimpleX.xcodeproj/project.pbxproj
|
||||
LIB_DIR=./apps/ios/Libraries/ios
|
||||
|
||||
if [ ! -f "$PBXPROJ" ]; then
|
||||
echo "Error: $PBXPROJ not found. Run from repo root." >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -d "$LIB_DIR" ]; then
|
||||
echo "Error: $LIB_DIR not found. Run prepare.sh first." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# New filenames from the prepared Libraries directory.
|
||||
NEW_PLAIN=
|
||||
NEW_GHC=
|
||||
for f in "$LIB_DIR"/libHSsimplex-chat-*.a; do
|
||||
[ -f "$f" ] || continue
|
||||
base=$(basename "$f")
|
||||
case "$base" in
|
||||
*-ghc*) NEW_GHC=$base ;;
|
||||
*) NEW_PLAIN=$base ;;
|
||||
esac
|
||||
done
|
||||
if [ -z "$NEW_PLAIN" ] || [ -z "$NEW_GHC" ]; then
|
||||
echo "Error: expected libHSsimplex-chat-*.a and -ghc*.a in $LIB_DIR." >&2
|
||||
echo "Run prepare.sh first." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Current filenames referenced in project.pbxproj.
|
||||
OLD_PLAIN=
|
||||
OLD_GHC=
|
||||
for ref in $(grep -hoE 'libHSsimplex-chat-[^ "/]+\.a' "$PBXPROJ" | sort -u); do
|
||||
case "$ref" in
|
||||
*-ghc*) OLD_GHC=$ref ;;
|
||||
*) OLD_PLAIN=$ref ;;
|
||||
esac
|
||||
done
|
||||
if [ -z "$OLD_PLAIN" ] || [ -z "$OLD_GHC" ]; then
|
||||
echo "Error: no libHSsimplex-chat references found in $PBXPROJ." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$OLD_PLAIN" = "$NEW_PLAIN" ] && [ "$OLD_GHC" = "$NEW_GHC" ]; then
|
||||
echo "Already up to date: $NEW_PLAIN"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Sanity check before mutating: pbxproj must have exactly 4 lines per variant.
|
||||
OLD_PLAIN_LINES=$(grep -cF "$OLD_PLAIN" "$PBXPROJ" || true)
|
||||
OLD_GHC_LINES=$(grep -cF "$OLD_GHC" "$PBXPROJ" || true)
|
||||
if [ "$OLD_PLAIN_LINES" -ne 4 ] || [ "$OLD_GHC_LINES" -ne 4 ]; then
|
||||
echo "Error: expected 4 + 4 lines, found $OLD_PLAIN_LINES plain and $OLD_GHC_LINES ghc." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Replacing in $PBXPROJ:"
|
||||
echo " $OLD_PLAIN -> $NEW_PLAIN"
|
||||
echo " $OLD_GHC -> $NEW_GHC"
|
||||
|
||||
# Escape regex metachar '.' so versions match literally (no other metachars present).
|
||||
escape_dots() { printf '%s' "$1" | sed 's/\./\\./g'; }
|
||||
OLD_PLAIN_RE=$(escape_dots "$OLD_PLAIN")
|
||||
OLD_GHC_RE=$(escape_dots "$OLD_GHC")
|
||||
|
||||
# Put TMP next to PBXPROJ so the final mv is an atomic rename (same filesystem).
|
||||
TMP=$(mktemp "$PBXPROJ.XXXXXX")
|
||||
trap 'rm -f "$TMP"' EXIT
|
||||
# Replace ghc variant first (longer, more specific), then plain.
|
||||
sed -e "s|$OLD_GHC_RE|$NEW_GHC|g" -e "s|$OLD_PLAIN_RE|$NEW_PLAIN|g" "$PBXPROJ" > "$TMP"
|
||||
mv "$TMP" "$PBXPROJ"
|
||||
|
||||
# Verify result: exactly 4 plain lines and 4 ghc lines.
|
||||
NEW_PLAIN_LINES=$(grep -cF "$NEW_PLAIN" "$PBXPROJ" || true)
|
||||
NEW_GHC_LINES=$(grep -cF "$NEW_GHC" "$PBXPROJ" || true)
|
||||
if [ "$NEW_PLAIN_LINES" -ne 4 ] || [ "$NEW_GHC_LINES" -ne 4 ]; then
|
||||
echo "Error: post-replacement: $NEW_PLAIN_LINES plain + $NEW_GHC_LINES ghc (expected 4+4)." >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "Updated 8 lines (4 plain + 4 ghc)."
|
||||
Executable
+84
@@ -0,0 +1,84 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Bumps CURRENT_PROJECT_VERSION (build number) and MARKETING_VERSION in
|
||||
# apps/ios/SimpleX.xcodeproj/project.pbxproj. Each appears in 10 places.
|
||||
#
|
||||
# Usage: ./scripts/ios/update-version.sh <build_number> <marketing_version>
|
||||
# Example: ./scripts/ios/update-version.sh 333 6.5.3
|
||||
|
||||
set -e
|
||||
|
||||
if [ $# -ne 2 ]; then
|
||||
echo "Usage: $0 <build_number> <marketing_version>" >&2
|
||||
echo "Example: $0 333 6.5.3" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
NEW_BUILD=$1
|
||||
NEW_MARKETING=$2
|
||||
|
||||
if ! echo "$NEW_BUILD" | grep -qE '^[0-9]+$'; then
|
||||
echo "Error: build_number must be a positive integer (got: $NEW_BUILD)." >&2
|
||||
exit 1
|
||||
fi
|
||||
if ! echo "$NEW_MARKETING" | grep -qE '^[0-9]+(\.[0-9]+)+$'; then
|
||||
echo "Error: marketing_version must be like 6.5.3 (got: $NEW_MARKETING)." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PBXPROJ=./apps/ios/SimpleX.xcodeproj/project.pbxproj
|
||||
if [ ! -f "$PBXPROJ" ]; then
|
||||
echo "Error: $PBXPROJ not found. Run from repo root." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Detect current values; head -1 covers the (unexpected) mixed-values case,
|
||||
# which the 10-line sanity check below will reject.
|
||||
OLD_BUILD=$(grep -hoE 'CURRENT_PROJECT_VERSION = [^;]+;' "$PBXPROJ" \
|
||||
| sed -E 's/^.*= ([^;]+);$/\1/' | sort -u | head -1)
|
||||
OLD_MARKETING=$(grep -hoE 'MARKETING_VERSION = [^;]+;' "$PBXPROJ" \
|
||||
| sed -E 's/^.*= ([^;]+);$/\1/' | sort -u | head -1)
|
||||
if [ -z "$OLD_BUILD" ] || [ -z "$OLD_MARKETING" ]; then
|
||||
echo "Error: CURRENT_PROJECT_VERSION or MARKETING_VERSION not found in $PBXPROJ." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$OLD_BUILD" = "$NEW_BUILD" ] && [ "$OLD_MARKETING" = "$NEW_MARKETING" ]; then
|
||||
echo "Already up to date: build $NEW_BUILD, version $NEW_MARKETING"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Each field must appear in exactly 10 lines with a single uniform value.
|
||||
OLD_BUILD_LINES=$(grep -cF "CURRENT_PROJECT_VERSION = $OLD_BUILD;" "$PBXPROJ" || true)
|
||||
OLD_MARKETING_LINES=$(grep -cF "MARKETING_VERSION = $OLD_MARKETING;" "$PBXPROJ" || true)
|
||||
if [ "$OLD_BUILD_LINES" -ne 10 ] || [ "$OLD_MARKETING_LINES" -ne 10 ]; then
|
||||
echo "Error: expected 10 + 10 lines, found $OLD_BUILD_LINES CURRENT_PROJECT_VERSION and $OLD_MARKETING_LINES MARKETING_VERSION (mixed values?)." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Bumping in $PBXPROJ:"
|
||||
if [ "$OLD_BUILD" != "$NEW_BUILD" ]; then
|
||||
echo " CURRENT_PROJECT_VERSION: $OLD_BUILD -> $NEW_BUILD"
|
||||
fi
|
||||
if [ "$OLD_MARKETING" != "$NEW_MARKETING" ]; then
|
||||
echo " MARKETING_VERSION: $OLD_MARKETING -> $NEW_MARKETING"
|
||||
fi
|
||||
|
||||
# Escape '.' in OLD_MARKETING so version dots match literally.
|
||||
OLD_MARKETING_RE=$(printf '%s' "$OLD_MARKETING" | sed 's/\./\\./g')
|
||||
|
||||
TMP=$(mktemp "$PBXPROJ.XXXXXX")
|
||||
trap 'rm -f "$TMP"' EXIT
|
||||
sed \
|
||||
-e "s|CURRENT_PROJECT_VERSION = $OLD_BUILD;|CURRENT_PROJECT_VERSION = $NEW_BUILD;|g" \
|
||||
-e "s|MARKETING_VERSION = $OLD_MARKETING_RE;|MARKETING_VERSION = $NEW_MARKETING;|g" \
|
||||
"$PBXPROJ" > "$TMP"
|
||||
mv "$TMP" "$PBXPROJ"
|
||||
|
||||
NEW_BUILD_LINES=$(grep -cF "CURRENT_PROJECT_VERSION = $NEW_BUILD;" "$PBXPROJ" || true)
|
||||
NEW_MARKETING_LINES=$(grep -cF "MARKETING_VERSION = $NEW_MARKETING;" "$PBXPROJ" || true)
|
||||
if [ "$NEW_BUILD_LINES" -ne 10 ] || [ "$NEW_MARKETING_LINES" -ne 10 ]; then
|
||||
echo "Error: post-replacement: $NEW_BUILD_LINES CURRENT_PROJECT_VERSION + $NEW_MARKETING_LINES MARKETING_VERSION (expected 10+10)." >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "Updated 20 lines (10 + 10)."
|
||||
Reference in New Issue
Block a user