Skip to content

Commit 077ed62

Browse files
committed
Update code to properly use the received version as source of truth throughout code freeze lane
1 parent f6b5eb1 commit 077ed62

File tree

2 files changed

+15
-41
lines changed

2 files changed

+15
-41
lines changed

fastlane/Fastfile

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -108,25 +108,12 @@ def current_beta_version
108108
VERSION_FORMATTER.beta_version(current_version)
109109
end
110110

111-
# Returns the beta version that is used by the code freeze
112-
# It first increments the minor number, which also resets the build number to 0
113-
# It then bumps the build number so the -rc-1 can be appended to the code freeze version
114-
def code_freeze_beta_version
115-
# Read the current release version from the .xcconfig file and parse it into an AppVersion object
116-
current_version = VERSION_FORMATTER.parse(VERSION_FILE.read_version_name)
117-
# Calculate the next major version number
118-
next_version = VERSION_CALCULATOR.next_release_version(version: current_version)
119-
# Calculate the next build number
120-
code_freeze_beta_version = VERSION_CALCULATOR.next_build_number(version: next_version)
121-
# Return the formatted release version
122-
VERSION_FORMATTER.beta_version(code_freeze_beta_version)
123-
end
124-
125111
# Returns the beta version of the app in the format `1.2-rc-1`
126112
#
127-
def next_beta_version
113+
def next_beta_version(version_name: nil)
114+
version_name ||= VERSION_FILE.read_version_name
128115
# Read the current release version from the .xcconfig file and parse it into an AppVersion object
129-
current_version = VERSION_FORMATTER.parse(VERSION_FILE.read_version_name)
116+
current_version = VERSION_FORMATTER.parse(version_name)
130117
# Calculate the next beta version
131118
next_beta_version = VERSION_CALCULATOR.next_build_number(version: current_version)
132119
# Return the formatted release version

fastlane/lanes/release.rb

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,42 +9,29 @@
99
#
1010
lane :code_freeze do |version: nil, skip_confirm: false|
1111
ensure_git_status_clean
12-
Fastlane::Helper::GitHelper.checkout_and_pull(DEFAULT_BRANCH)
13-
ensure_git_branch(branch: DEFAULT_BRANCH)
14-
15-
# Use provided version from release tool, or fall back to computed version
16-
computed_version = next_release_version
17-
new_version = version || computed_version
18-
19-
# Fail if provided version differs from computed version
20-
if version && version != computed_version
21-
error_message = <<~ERROR
22-
❌ Version mismatch detected!
2312

24-
The explicitly-provided version from the release tool is '#{version}' but the computed version from the codebase is '#{computed_version}'.
13+
Fastlane::Helper::GitHelper.checkout_and_pull(DEFAULT_BRANCH)
2514

26-
This mismatch must be resolved before proceeding with the code freeze. Please investigate and ensure the versions are aligned.
27-
ERROR
28-
buildkite_annotate(style: 'error', context: 'code-freeze-version-mismatch', message: error_message) if is_ci
29-
UI.user_error!(error_message)
30-
end
15+
# If a new version is passed, use it as source of truth from now on
16+
new_version = version || next_release_version
17+
release_branch_name = "release/#{new_version}"
18+
new_beta_version = next_beta_version(version_name: new_version)
19+
new_build_code = next_build_code
3120

3221
message = <<-MESSAGE
3322
3423
Code Freeze:
35-
• New release branch from #{DEFAULT_BRANCH}: release/#{new_version}
36-
• Current release version and build code: #{current_release_version} (#{current_build_code}).
37-
• New release version and build code: #{code_freeze_beta_version} (#{next_build_code}).
24+
• New release branch from #{DEFAULT_BRANCH}: #{release_branch_name}
3825
39-
Do you want to continue?
26+
• Current release version and build code: #{current_release_version} (#{current_build_code}).
27+
• New release version and build code: #{new_beta_version} (#{new_build_code}).
4028
4129
MESSAGE
4230

4331
UI.important(message)
4432

4533
UI.user_error!('Aborted by user request') unless skip_confirm || UI.confirm('Do you want to continue?')
4634

47-
release_branch_name = "release/#{new_version}"
4835
ensure_branch_does_not_exist!(release_branch_name)
4936

5037
# Create the release branch
@@ -56,8 +43,8 @@
5643
# Bump the version and build code
5744
UI.message 'Bumping beta version and build code...'
5845
VERSION_FILE.write_version(
59-
version_name: code_freeze_beta_version,
60-
version_code: next_build_code
46+
version_name: new_beta_version,
47+
version_code: new_build_code
6148
)
6249
commit_version_bump
6350
UI.success "Done! New Beta Version: #{current_beta_version}. New Build Code: #{current_build_code}"
@@ -89,7 +76,7 @@
8976
copy_branch_protection(
9077
repository: GITHUB_REPO,
9178
from_branch: DEFAULT_BRANCH,
92-
to_branch: "release/#{new_version}"
79+
to_branch: release_branch_name
9380
)
9481

9582
begin

0 commit comments

Comments
 (0)