Skip to content

Commit d34c401

Browse files
authored
[Tooling] Use ReleasesV2 version as the source of truth during Code Freeze (#24963)
* Update code freeze version mismatch validation to fail build instead of just showing a warning * Update code to properly use the received version as source of truth throughout code freeze lane * Improve code freeze build code util method comments
1 parent 19e2f00 commit d34c401

File tree

2 files changed

+18
-29
lines changed

2 files changed

+18
-29
lines changed

fastlane/Fastfile

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,16 @@ def build_code_current
126126
BUILD_CODE_FORMATTER.build_code(version: version)
127127
end
128128

129-
# Returns the build code of the app for the code freeze. It is the release version name plus sets the build number to 0
129+
# Returns the initial build code for a code freeze (e.g., "1.2.3.0" for release version "1.2.3")
130+
# Takes the release version and formats it as a four-part build code with the build number set to 0
130131
#
131-
def build_code_code_freeze
132-
# Read the current build code from the .xcconfig file and parse it into an AppVersion object
133-
# The AppVersion is used because WP/JPiOS uses the four part (1.2.3.4) build code format, so the version
134-
# calculator can be used to calculate the next four-part version
135-
release_version_current = VERSION_FORMATTER.parse(PUBLIC_VERSION_FILE.read_release_version)
136-
# Calculate the next release version, which will be used as the basis of the new build code
137-
build_code_code_freeze = VERSION_CALCULATOR.next_release_version(version: release_version_current)
138-
# Return the formatted build code
139-
BUILD_CODE_FORMATTER.build_code(version: build_code_code_freeze)
132+
def build_code_code_freeze(version_short: nil)
133+
# Use provided version or read the current release version from the .xcconfig file
134+
version_short ||= PUBLIC_VERSION_FILE.read_release_version
135+
# Parse the release version string (e.g., "1.2.3") into an AppVersion object
136+
release_version_current = VERSION_FORMATTER.parse(version_short)
137+
# Format as four-part build code (e.g., "1.2.3.0")
138+
BUILD_CODE_FORMATTER.build_code(version: release_version_current)
140139
end
141140

142141
# Returns the build code of the app for the code freeze. It is the hotfix version name plus sets the build number to 0

fastlane/lanes/release.rb

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,33 +19,23 @@
1919
# Check out the up-to-date default branch, the designated starting point for the code freeze
2020
Fastlane::Helper::GitHelper.checkout_and_pull(DEFAULT_BRANCH)
2121

22-
# Use provided version from release tool, or fall back to computed version
23-
computed_version = release_version_next
24-
provided_version = version
25-
new_version = provided_version || computed_version
26-
27-
# Warn if provided version differs from computed version
28-
if provided_version && provided_version != computed_version
29-
warning_message = <<~WARNING
30-
⚠️ Version mismatch: The explicitly-provided version was '#{provided_version}' while new computed version would have been '#{computed_version}'.
31-
If this is unexpected, you might want to investigate the discrepency.
32-
Continuing with the explicitly-provided verison '#{provided_version}'.
33-
WARNING
34-
UI.important(warning_message)
35-
buildkite_annotate(style: 'warning', context: 'code-freeze-version-mismatch', message: warning_message) if is_ci
36-
end
22+
# If a new version is passed, use it as source of truth from now on
23+
new_version = version || release_version_next
24+
release_branch_name = compute_release_branch_name(options: { version: new_version, skip_confirm: skip_confirm }, version: new_version)
25+
new_build_code = build_code_code_freeze(version_short: new_version)
3726

38-
release_branch_name = compute_release_branch_name(options: { version: version, skip_confirm: skip_confirm }, version: new_version)
3927
ensure_branch_does_not_exist!(release_branch_name)
4028

4129
# The `release_version_next` is used as the `new internal release version` value because the external and internal
4230
# release versions are always the same.
4331
message = <<~MESSAGE
32+
4433
Code Freeze:
4534
• New release branch from #{DEFAULT_BRANCH}: #{release_branch_name}
4635
4736
• Current release version and build code: #{release_version_current} (#{build_code_current}).
48-
• New release version and build code: #{new_version} (#{build_code_code_freeze}).
37+
• New release version and build code: #{new_version} (#{new_build_code}).
38+
4939
MESSAGE
5040

5141
UI.important(message)
@@ -59,8 +49,8 @@
5949
# Bump the release version and build code and write it to the `xcconfig` file
6050
UI.message 'Bumping release version and build code...'
6151
PUBLIC_VERSION_FILE.write(
62-
version_short: release_version_next,
63-
version_long: build_code_code_freeze
52+
version_short: new_version,
53+
version_long: new_build_code
6454
)
6555
UI.success "Done! New Release Version: #{release_version_current}. New Build Code: #{build_code_current}"
6656

0 commit comments

Comments
 (0)