Skip to content

Commit dcd808e

Browse files
authored
fix: mismatch identifier for update version script (#42)
1 parent 4f5fc26 commit dcd808e

2 files changed

Lines changed: 45 additions & 20 deletions

File tree

RxCode.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,7 +1271,7 @@
12711271
"@executable_path/../Frameworks",
12721272
);
12731273
MACOSX_DEPLOYMENT_TARGET = 26.0;
1274-
MARKETING_VERSION = 1.2.5;
1274+
MARKETING_VERSION = 1.8.0;
12751275
PRODUCT_BUNDLE_IDENTIFIER = com.rxlab.RxCode;
12761276
PRODUCT_NAME = "$(TARGET_NAME)";
12771277
REGISTER_APP_GROUPS = YES;
@@ -1305,7 +1305,7 @@
13051305
"@executable_path/../Frameworks",
13061306
);
13071307
MACOSX_DEPLOYMENT_TARGET = 26.0;
1308-
MARKETING_VERSION = 1.2.5;
1308+
MARKETING_VERSION = 1.8.0;
13091309
PRODUCT_BUNDLE_IDENTIFIER = com.rxlab.RxCode;
13101310
PRODUCT_NAME = "$(TARGET_NAME)";
13111311
REGISTER_APP_GROUPS = YES;

scripts/ci/update-version.sh

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,38 +10,63 @@ if [ -z "$VERSION" ]; then
1010
fi
1111

1212
PROJECT_FILE="RxCode.xcodeproj/project.pbxproj"
13+
BUNDLE_IDENTIFIER="com.rxlab.RxCode"
1314

1415
if [ ! -f "$PROJECT_FILE" ]; then
1516
echo "Error: $PROJECT_FILE not found"
1617
exit 1
1718
fi
1819

19-
echo "Updating MARKETING_VERSION to $VERSION in $PROJECT_FILE"
20+
echo "Updating MARKETING_VERSION to $VERSION in $PROJECT_FILE for $BUNDLE_IDENTIFIER"
2021

2122
# Create a temporary file
2223
TMP_FILE=$(mktemp)
2324

24-
# Use awk to update only the RxCode main target (matched by PRODUCT_BUNDLE_IDENTIFIER)
25-
awk -v new_version="$VERSION" '
26-
/MARKETING_VERSION = / {
27-
# Store the current line
28-
marketing_line = $0
29-
# Read the next line
30-
getline
31-
# Check if this is the main app target (not Tests or UITests)
32-
if ($0 ~ /PRODUCT_BUNDLE_IDENTIFIER = com\.idealapp\.RxCode;$/) {
33-
# Update MARKETING_VERSION
34-
gsub(/MARKETING_VERSION = [^;]+;/, "MARKETING_VERSION = " new_version ";", marketing_line)
35-
print marketing_line
36-
print
37-
} else {
38-
# Keep both lines unchanged
39-
print marketing_line
40-
print
25+
# Update only build settings blocks for the macOS RxCode app target.
26+
# Matching the whole block is safer than assuming MARKETING_VERSION is adjacent
27+
# to PRODUCT_BUNDLE_IDENTIFIER in project.pbxproj.
28+
awk -v new_version="$VERSION" -v bundle_id="$BUNDLE_IDENTIFIER" '
29+
BEGIN {
30+
in_build_settings = 0
31+
block = ""
32+
matched_bundle = 0
33+
updated_count = 0
34+
}
35+
36+
/^[[:space:]]*buildSettings = \{[[:space:]]*$/ {
37+
in_build_settings = 1
38+
block = $0 ORS
39+
matched_bundle = 0
40+
next
41+
}
42+
43+
in_build_settings {
44+
block = block $0 ORS
45+
if (index($0, "PRODUCT_BUNDLE_IDENTIFIER = " bundle_id ";") > 0) {
46+
matched_bundle = 1
47+
}
48+
if ($0 ~ /^[[:space:]]*\};[[:space:]]*$/) {
49+
if (matched_bundle) {
50+
updated_count += gsub(/MARKETING_VERSION = [^;]+;/, "MARKETING_VERSION = " new_version ";", block)
51+
}
52+
printf "%s", block
53+
in_build_settings = 0
54+
block = ""
55+
matched_bundle = 0
4156
}
4257
next
4358
}
59+
4460
{ print }
61+
62+
END {
63+
if (in_build_settings) {
64+
printf "%s", block
65+
}
66+
if (updated_count == 0) {
67+
exit 1
68+
}
69+
}
4570
' "$PROJECT_FILE" > "$TMP_FILE"
4671

4772
# Replace the original file

0 commit comments

Comments
 (0)