Skip to content

Commit 4f7ba8e

Browse files
committed
Update code to properly use the received version as source of truth throughout code freeze
1 parent 7b97d04 commit 4f7ba8e

File tree

1 file changed

+14
-25
lines changed

1 file changed

+14
-25
lines changed

fastlane/Fastfile

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -197,35 +197,22 @@ platform :ios do
197197
# Check out the up-to-date default branch, the designated starting point for the code freeze
198198
Fastlane::Helper::GitHelper.checkout_and_pull(DEFAULT_BRANCH)
199199

200-
# Use provided version from release tool, or fall back to computed version
201-
computed_version = release_version_next
202-
new_version = version || computed_version
203-
204-
# Fail if provided version differs from computed version
205-
if version && version != computed_version
206-
error_message = <<~ERROR
207-
❌ Version mismatch detected!
208-
209-
The explicitly-provided version from the release tool is '#{version}' but the computed version from the codebase is '#{computed_version}'.
210-
211-
This mismatch must be resolved before proceeding with the code freeze. Please investigate and ensure the versions are aligned.
212-
ERROR
213-
buildkite_annotate(style: 'error', context: 'start-code-freeze-version-mismatch', message: error_message) if is_ci
214-
UI.user_error!(error_message)
215-
end
200+
# If a new version is passed, use it as source of truth from now on
201+
new_version = version || release_version_next
202+
new_release_branch = "release/#{new_version}"
203+
new_build_code = build_code_code_freeze(version_short: new_version)
216204

217205
UI.important <<-MESSAGE
218206
219207
Code Freeze:
220-
• New release branch from #{DEFAULT_BRANCH}: release/#{new_version}
208+
• New release branch from #{DEFAULT_BRANCH}: #{new_release_branch}
221209
• Current release version and build code: #{release_version_current} (#{build_code_current}).
222-
• New release version and build code: #{new_version} (#{build_code_code_freeze}).
210+
• New release version and build code: #{new_version} (#{new_build_code}).
223211
224212
MESSAGE
225213
UI.user_error!("Terminating as requested. Don't forget to run the remainder of this automation manually.") unless skip_confirm || UI.confirm('Do you want to continue?')
226214

227215
# Create the release branch
228-
new_release_branch = "release/#{new_version}"
229216
ensure_branch_does_not_exist!(new_release_branch)
230217

231218
UI.message('Creating release branch...')
@@ -235,8 +222,8 @@ platform :ios do
235222
# Bump the release version and build code and write it to the `xcconfig` file
236223
UI.message('Bumping release version and build code...')
237224
VERSION_FILE.write(
238-
version_short: release_version_next,
239-
version_long: build_code_code_freeze
225+
version_short: new_version,
226+
version_long: new_build_code
240227
)
241228
commit_version_bump
242229
UI.success("Done! New Release Version: #{release_version_current}. New Build Code: #{build_code_current}")
@@ -1421,9 +1408,10 @@ end
14211408

14221409
# Returns the next release version of the app in the format `1.2` or `1.2.3` if it is a hotfix
14231410
#
1424-
def release_version_next
1411+
def release_version_next(version_short: nil)
1412+
version_short ||= VERSION_FILE.read_release_version
14251413
# Read the current release version from the .xcconfig file and parse it into an AppVersion object
1426-
current_version = VERSION_FORMATTER.parse(VERSION_FILE.read_release_version)
1414+
current_version = VERSION_FORMATTER.parse(version_short)
14271415
# Calculate the next release version
14281416
next_calculated_release_version = VERSION_CALCULATOR.next_release_version(version: current_version)
14291417
# Return the formatted release version
@@ -1443,11 +1431,12 @@ end
14431431

14441432
# Returns the build code of the app for the code freeze. It is the release version name plus sets the build number to 0
14451433
#
1446-
def build_code_code_freeze
1434+
def build_code_code_freeze(version_short: nil)
1435+
version_short ||= VERSION_FILE.read_release_version
14471436
# Read the current build code from the .xcconfig file and parse it into an AppVersion object
14481437
# The AppVersion is used because WCiOS uses the four part (1.2.3.4) build code format, so the version
14491438
# calculator can be used to calculate the next four-part version
1450-
release_version_current = VERSION_FORMATTER.parse(VERSION_FILE.read_release_version)
1439+
release_version_current = VERSION_FORMATTER.parse(version_short)
14511440
# Calculate the next release version, which will be used as the basis of the new build code
14521441
build_code_code_freeze = VERSION_CALCULATOR.next_release_version(version: release_version_current)
14531442
# Return the formatted build code

0 commit comments

Comments
 (0)