Skip to content

Commit a117dcc

Browse files
committed
fix
1 parent 04befc0 commit a117dcc

File tree

4 files changed

+146
-10
lines changed

4 files changed

+146
-10
lines changed

.github/actions/install/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ runs:
100100
with:
101101
bundler-cache: true
102102

103+
- name: Setup Python
104+
uses: actions/setup-python@v4
105+
with:
106+
python-version: "3.x"
107+
103108
- name: Ensure SPM directory exists
104109
if: inputs.minimal_mode != 'true'
105110
shell: bash
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Simple script for updating CURRENT_PROJECT_VERSION (build number) in Xcode project file.
4+
Can either increment the current build number or set it to a specific value.
5+
"""
6+
7+
import argparse
8+
import os
9+
import re
10+
import sys
11+
12+
13+
def update_build_number(pbxproj_path, config_name, build_number=None):
14+
"""
15+
Update CURRENT_PROJECT_VERSION in specific build configuration.
16+
17+
Args:
18+
pbxproj_path: Path to project.pbxproj file
19+
config_name: Configuration name (e.g., 'Release', 'DevCI')
20+
build_number: If provided, set to this value. If None, increment current value.
21+
22+
Returns:
23+
Tuple of (success: bool, new_build_number: int)
24+
"""
25+
if not os.path.isfile(pbxproj_path):
26+
raise FileNotFoundError(f"Xcode project file not found at {pbxproj_path}")
27+
28+
with open(pbxproj_path, "r", encoding="utf-8", errors="ignore") as f:
29+
content = f.read()
30+
31+
# Find configuration block by name
32+
# Pattern: <config_id> /* <config_name> */ = { ... };
33+
config_pattern = (
34+
rf"(\w{{24}}\s*/\*\s*{re.escape(config_name)}\s*\*/\s*=\s*\{{[^}}]*?\}})"
35+
)
36+
config_match = re.search(config_pattern, content, re.DOTALL)
37+
38+
if not config_match:
39+
raise ValueError(f"Could not find configuration block for '{config_name}'")
40+
41+
# Find current build number in the config block
42+
config_block = config_match.group(0)
43+
build_match = re.search(r"CURRENT_PROJECT_VERSION\s*=\s*(\d+);", config_block)
44+
45+
if not build_match:
46+
raise ValueError(
47+
f"Could not find CURRENT_PROJECT_VERSION in {config_name} configuration"
48+
)
49+
50+
current_build = int(build_match.group(1))
51+
52+
if build_number is not None:
53+
# Set to specific value
54+
new_build = build_number
55+
action = "Set"
56+
else:
57+
# Increment current value
58+
new_build = current_build + 1
59+
action = "Incremented"
60+
61+
# Update build number in the configuration block
62+
def update_block(match):
63+
block = match.group(0)
64+
block = re.sub(
65+
r"(CURRENT_PROJECT_VERSION\s*=\s*)\d+;", rf"\g<1>{new_build};", block
66+
)
67+
return block
68+
69+
new_content = re.sub(config_pattern, update_block, content, flags=re.DOTALL)
70+
71+
with open(pbxproj_path, "w", encoding="utf-8") as f:
72+
f.write(new_content)
73+
74+
print(
75+
f"{action} CURRENT_PROJECT_VERSION: {current_build} -> {new_build} in {config_name} configuration"
76+
)
77+
return True, new_build
78+
79+
80+
def main():
81+
parser = argparse.ArgumentParser(
82+
description="Update CURRENT_PROJECT_VERSION in Xcode project"
83+
)
84+
parser.add_argument("pbxproj", help="Path to project.pbxproj file")
85+
parser.add_argument(
86+
"--config-name",
87+
required=True,
88+
help="Configuration name (e.g., 'Release', 'DevCI')",
89+
)
90+
parser.add_argument(
91+
"--build-number",
92+
type=int,
93+
help="Set build number to this value (if not provided, will increment current value)",
94+
)
95+
parser.add_argument(
96+
"--output-github",
97+
action="store_true",
98+
help="Output in GitHub Actions format to GITHUB_OUTPUT",
99+
)
100+
101+
args = parser.parse_args()
102+
103+
try:
104+
success, new_build = update_build_number(
105+
args.pbxproj, args.config_name, args.build_number
106+
)
107+
108+
if args.output_github and os.environ.get("GITHUB_OUTPUT"):
109+
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
110+
f.write(f"new_build={new_build}\n")
111+
f.write(f"build_updated=true\n")
112+
113+
except Exception as e:
114+
print(f"Error: {e}", file=sys.stderr)
115+
sys.exit(1)
116+
117+
118+
if __name__ == "__main__":
119+
main()

.github/workflows/pull_request.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ name: Build and Test on PR
22

33
on:
44
pull_request:
5-
push:
6-
branches:
7-
- "feat/fastlane-ci"
85

96
concurrency:
107
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}

.github/workflows/push_develop.yml

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
1-
name: Distribute to Firebase (develop)
1+
name: Distribute to Firebase
22

33
on:
44
push:
5-
branches: [develop]
5+
branches:
6+
- 'develop'
7+
- 'feat/fastlane-ci'
68

79
env:
10+
IOS_BUNDLE_ID: "io.novafoundation.novawallet.dev"
11+
IOS_EXTENSION_BUNDLE_ID: "io.novafoundation.novawallet.dev.NovaPushNotificationServiceExtension"
12+
PROVISIONING_PROFILE_SPECIFIER: "match AdHoc io.novafoundation.novawallet.dev"
13+
EXTENSION_PROVISIONING_PROFILE_SPECIFIER: "match AdHoc io.novafoundation.novawallet.dev.NovaPushNotificationServiceExtension"
14+
CODE_SIGN_IDENTITY: "Apple Distribution"
15+
EXPORT_METHOD: "ad-hoc"
16+
FASTLANE_CONFIGURATION: "Dev"
817
BUILD_NUMBER: ${{ github.run_number }}
9-
FIREBASE_GROUPS: dev-team
18+
#FIREBASE_GROUPS: dev-team
19+
FIREBASE_GROUPS: ci-test
1020
RELEASE_NOTES: ${{ github.event.head_commit.message }}
1121
RUN_IN_CI: true
1222

@@ -27,11 +37,16 @@ jobs:
2737
scw_default_project_id: ${{ secrets.SCW_DEFAULT_PROJECT_ID }}
2838
scw_default_organization_id: ${{ secrets.SCW_DEFAULT_ORGANIZATION_ID }}
2939

30-
- name: Set app version if missing
40+
- name: Update build number
41+
env:
42+
PBXPROJ_PATH: novawallet.xcodeproj/project.pbxproj
3143
run: |
32-
if [ -z "$APP_VERSION" ] && [ -n "$IOS_APP_VERSION" ]; then
33-
echo "APP_VERSION=$IOS_APP_VERSION" >> $GITHUB_ENV
34-
fi
44+
set -euo pipefail
45+
46+
echo "Setting build number to ${{ env.BUILD_NUMBER }} in Dev configuration..."
47+
python3 .github/scripts/update_build_number.py "${PBXPROJ_PATH}" \
48+
--config-name "Dev" \
49+
--build-number ${{ env.BUILD_NUMBER }}
3550
3651
- name: Distribute to Firebase via fastlane
3752
run: bundle exec fastlane distribute_app_to_firebase release_notes:"${{ env.RELEASE_NOTES }}"

0 commit comments

Comments
 (0)