Skip to content

Commit 1b4908c

Browse files
authored
[Tooling] Use ReleasesV2 version as the source of truth during Code Freeze (#16296)
2 parents 7275f21 + 9336d5f commit 1b4908c

File tree

1 file changed

+19
-30
lines changed

1 file changed

+19
-30
lines changed

fastlane/Fastfile

Lines changed: 19 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -197,33 +197,23 @@ 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-
# Warn if provided version differs from computed version
205-
if version && version != computed_version
206-
warning_message = <<~WARNING
207-
⚠️ Version mismatch: The explicitly-provided version was '#{version}' while new computed version would have been '#{computed_version}'.
208-
If this is unexpected, you might want to investigate the discrepency.
209-
Continuing with the explicitly-provided verison '#{version}'.
210-
WARNING
211-
UI.important(warning_message)
212-
buildkite_annotate(style: 'warning', context: 'start-code-freeze-version-mismatch', message: warning_message) if is_ci
213-
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)
214204

215205
UI.important <<-MESSAGE
216206
217207
Code Freeze:
218-
• New release branch from #{DEFAULT_BRANCH}: release/#{new_version}
208+
• New release branch from #{DEFAULT_BRANCH}: #{new_release_branch}
209+
219210
• Current release version and build code: #{release_version_current} (#{build_code_current}).
220-
• New release version and build code: #{new_version} (#{build_code_code_freeze}).
211+
• New release version and build code: #{new_version} (#{new_build_code}).
221212
222213
MESSAGE
223214
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?')
224215

225216
# Create the release branch
226-
new_release_branch = "release/#{new_version}"
227217
ensure_branch_does_not_exist!(new_release_branch)
228218

229219
UI.message('Creating release branch...')
@@ -233,8 +223,8 @@ platform :ios do
233223
# Bump the release version and build code and write it to the `xcconfig` file
234224
UI.message('Bumping release version and build code...')
235225
VERSION_FILE.write(
236-
version_short: release_version_next,
237-
version_long: build_code_code_freeze
226+
version_short: new_version,
227+
version_long: new_build_code
238228
)
239229
commit_version_bump
240230
UI.success("Done! New Release Version: #{release_version_current}. New Build Code: #{build_code_current}")
@@ -258,7 +248,7 @@ platform :ios do
258248
copy_branch_protection(
259249
repository: GITHUB_REPO,
260250
from_branch: DEFAULT_BRANCH,
261-
to_branch: "release/#{new_version}"
251+
to_branch: new_release_branch
262252
)
263253

264254
begin
@@ -1439,17 +1429,16 @@ def build_code_current
14391429
BUILD_CODE_FORMATTER.build_code(version: version)
14401430
end
14411431

1442-
# Returns the build code of the app for the code freeze. It is the release version name plus sets the build number to 0
1432+
# Returns the initial build code for a code freeze (e.g., "1.2.3.0" for release version "1.2.3")
1433+
# Takes the release version and formats it as a four-part build code with the build number set to 0
14431434
#
1444-
def build_code_code_freeze
1445-
# Read the current build code from the .xcconfig file and parse it into an AppVersion object
1446-
# The AppVersion is used because WCiOS uses the four part (1.2.3.4) build code format, so the version
1447-
# calculator can be used to calculate the next four-part version
1448-
release_version_current = VERSION_FORMATTER.parse(VERSION_FILE.read_release_version)
1449-
# Calculate the next release version, which will be used as the basis of the new build code
1450-
build_code_code_freeze = VERSION_CALCULATOR.next_release_version(version: release_version_current)
1451-
# Return the formatted build code
1452-
BUILD_CODE_FORMATTER.build_code(version: build_code_code_freeze)
1435+
def build_code_code_freeze(version_short: nil)
1436+
# Use provided version or read the current release version from the .xcconfig file
1437+
version_short ||= VERSION_FILE.read_release_version
1438+
# Parse the release version string (e.g., "1.2.3") into an AppVersion object
1439+
release_version_current = VERSION_FORMATTER.parse(version_short)
1440+
# Format as four-part build code (e.g., "1.2.3.0")
1441+
BUILD_CODE_FORMATTER.build_code(version: release_version_current)
14531442
end
14541443

14551444
# Returns the next build code of the app

0 commit comments

Comments
 (0)