Skip to content

Commit 2a7e973

Browse files
committed
fix(ci): separate android and ios version bump
1 parent 2b87395 commit 2a7e973

File tree

2 files changed

+46
-27
lines changed

2 files changed

+46
-27
lines changed

.github/workflows/release.yml

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,22 +56,20 @@ jobs:
5656
ruby-version: '3.2.3' # Specify a Ruby version
5757
bundler-cache: true
5858

59-
# Step 5: Bump version using Fastlane
60-
- name: Bump version
61-
run: bundle exec fastlane bump_version version_type:${{ github.event_name == 'workflow_dispatch' && github.event.inputs.version_type || 'patch' }}
59+
# Step 5: Bump Android version
60+
- name: Bump Android version
61+
run: bundle exec fastlane bump_version_android version_type:${{ github.event_name == 'workflow_dispatch' && github.event.inputs.version_type || 'patch' }}
6262

63-
# Step 6: Commit and push version changes
64-
- name: Commit and push version changes
63+
# Step 6: Commit and push Android version changes
64+
- name: Commit and push Android version changes
6565
env:
6666
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6767
run: |
6868
git config user.name "GitHub Actions"
6969
git config user.email "[email protected]"
70-
git add .version package.json android/app/build.gradle ios/**/Info.plist
71-
git commit -m "Bump version to $(cat .version)"
70+
git add .version package.json android/app/build.gradle
71+
git commit -m "Bump Android version to $(cat .version)"
7272
git push
73-
git tag "v$(cat .version)"
74-
git push origin "v$(cat .version)"
7573
7674
# Step 7: Set up Android Keystore
7775
- name: Set up Android Keystore
@@ -145,7 +143,24 @@ jobs:
145143
working-directory: ios
146144
run: pod install
147145

148-
# Step 6: Build and upload iOS app to TestFlight
146+
# Step 6: Bump iOS version
147+
- name: Bump iOS version
148+
run: bundle exec fastlane bump_version_ios
149+
150+
# Step 7: Commit, push, and tag iOS version changes
151+
- name: Commit, push, and tag iOS version changes
152+
env:
153+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
154+
run: |
155+
git config user.name "GitHub Actions"
156+
git config user.email "[email protected]"
157+
git add ios/**/Info.plist
158+
git commit -m "Bump iOS version to $(cat .version)"
159+
git push
160+
git tag "v$(cat .version)"
161+
git push origin "v$(cat .version)"
162+
163+
# Step 8: Build and upload iOS app to TestFlight
149164
- name: Build and upload iOS app
150165
working-directory: ios
151166
env:

fastlane/Fastfile

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,38 @@
1-
desc "Bump version for both Android and iOS"
2-
lane :bump_version do |options|
3-
version_type = options[:version_type] || "patch" # Default to "patch" if not provided
1+
desc "Bump version for Android"
2+
lane :bump_version_android do |options|
3+
version_type = options[:version_type] || "patch"
44

55
# Bump version in package.json using Yarn
6-
begin
7-
sh("yarn version --#{version_type} --no-git-tag-version")
8-
new_version = JSON.parse(File.read('package.json'))['version']
9-
sh("echo #{new_version} > .version")
10-
rescue => e
11-
UI.user_error!("Failed to bump version: #{e.message}")
12-
end
13-
14-
# Bump iOS version
15-
increment_version_number(version_number: new_version)
16-
increment_build_number
6+
sh("yarn version --#{version_type} --no-git-tag-version")
7+
new_version = JSON.parse(File.read('package.json'))['version']
8+
sh("echo #{new_version} > .version")
179

1810
# Bump Android version
1911
gradle_file = "./android/app/build.gradle"
2012
android_version_code = get_version_code_from_gradle(gradle_file: gradle_file).to_i + 1
21-
android_version_name = new_version
13+
2214
update_gradle_property(
2315
property: "versionCode",
2416
value: android_version_code.to_s,
2517
gradle_file: gradle_file
2618
)
2719
update_gradle_property(
2820
property: "versionName",
29-
value: "\"#{android_version_name}\"",
21+
value: "\"#{new_version}\"",
3022
gradle_file: gradle_file
3123
)
3224

33-
UI.message("Bumped version to #{new_version}")
25+
UI.message("Bumped Android version to #{new_version}")
26+
end
27+
28+
desc "Bump version for iOS"
29+
lane :bump_version_ios do |options|
30+
# Read the version from package.json
31+
new_version = JSON.parse(File.read('package.json'))['version']
32+
33+
# Bump iOS version
34+
increment_version_number(version_number: new_version)
35+
increment_build_number
36+
37+
UI.message("Bumped iOS version to #{new_version}")
3438
end

0 commit comments

Comments
 (0)