Skip to content

Commit e068039

Browse files
committed
Update code to properly use the received version as source of truth throughout code freeze lane
1 parent 99bf62b commit e068039

File tree

2 files changed

+14
-30
lines changed

2 files changed

+14
-30
lines changed

fastlane/Fastfile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,14 @@ end
128128

129129
# Returns the build code of the app for the code freeze. It is the release version name plus sets the build number to 0
130130
#
131-
def build_code_code_freeze
131+
def build_code_code_freeze(version_short: nil)
132+
version_short ||= PUBLIC_VERSION_FILE.read_release_version
132133
# Read the current build code from the .xcconfig file and parse it into an AppVersion object
133134
# The AppVersion is used because WP/JPiOS uses the four part (1.2.3.4) build code format, so the version
134135
# 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)
136+
release_version_current = VERSION_FORMATTER.parse(version_short)
138137
# Return the formatted build code
139-
BUILD_CODE_FORMATTER.build_code(version: build_code_code_freeze)
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: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,40 +14,25 @@
1414
# Typically auto-provided by ReleasesV2. If nil, computes the new version based on current one.
1515
#
1616
lane :code_freeze do |skip_confirm: false, version: nil|
17-
ensure_git_status_clean
17+
# ensure_git_status_clean
1818

1919
# Check out the up-to-date default branch, the designated starting point for the code freeze
20-
Fastlane::Helper::GitHelper.checkout_and_pull(DEFAULT_BRANCH)
21-
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-
# Fail if provided version differs from computed version
28-
if provided_version && provided_version != computed_version
29-
error_message = <<~ERROR
30-
❌ Version mismatch detected!
31-
32-
The explicitly-provided version from the release tool is '#{provided_version}' but the computed version from the codebase is '#{computed_version}'.
20+
# Fastlane::Helper::GitHelper.checkout_and_pull(DEFAULT_BRANCH)
3321

34-
This mismatch must be resolved before proceeding with the code freeze. Please investigate and ensure the versions are aligned.
35-
ERROR
36-
buildkite_annotate(style: 'error', context: 'code-freeze-version-mismatch', message: error_message) if is_ci
37-
UI.user_error!(error_message)
38-
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)
3926

40-
release_branch_name = compute_release_branch_name(options: { version: version, skip_confirm: skip_confirm }, version: new_version)
4127
ensure_branch_does_not_exist!(release_branch_name)
4228

4329
# The `release_version_next` is used as the `new internal release version` value because the external and internal
4430
# release versions are always the same.
4531
message = <<~MESSAGE
4632
Code Freeze:
47-
• New release branch from #{DEFAULT_BRANCH}: #{release_branch_name}
48-
4933
• Current release version and build code: #{release_version_current} (#{build_code_current}).
50-
• New release version and build code: #{new_version} (#{build_code_code_freeze}).
34+
• New release branch from #{DEFAULT_BRANCH}: #{release_branch_name}
35+
• New release version and build code: #{new_version} (#{new_build_code}).
5136
MESSAGE
5237

5338
UI.important(message)
@@ -61,8 +46,8 @@
6146
# Bump the release version and build code and write it to the `xcconfig` file
6247
UI.message 'Bumping release version and build code...'
6348
PUBLIC_VERSION_FILE.write(
64-
version_short: release_version_next,
65-
version_long: build_code_code_freeze
49+
version_short: new_version,
50+
version_long: new_build_code
6651
)
6752
UI.success "Done! New Release Version: #{release_version_current}. New Build Code: #{build_code_current}"
6853

0 commit comments

Comments
 (0)