From 99bf62b62c622e6af633726ba65cc244423e5bda Mon Sep 17 00:00:00 2001 From: Ian Maia Date: Thu, 30 Oct 2025 18:28:51 -0300 Subject: [PATCH 1/2] Update code freeze version mismatch validation to fail build instead of just showing a warning --- fastlane/lanes/release.rb | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/fastlane/lanes/release.rb b/fastlane/lanes/release.rb index aec1edbbf438..b3472e5fb68d 100644 --- a/fastlane/lanes/release.rb +++ b/fastlane/lanes/release.rb @@ -24,15 +24,17 @@ provided_version = version new_version = provided_version || computed_version - # Warn if provided version differs from computed version + # Fail if provided version differs from computed version if provided_version && provided_version != computed_version - warning_message = <<~WARNING - ⚠️ Version mismatch: The explicitly-provided version was '#{provided_version}' while new computed version would have been '#{computed_version}'. - If this is unexpected, you might want to investigate the discrepency. - Continuing with the explicitly-provided verison '#{provided_version}'. - WARNING - UI.important(warning_message) - buildkite_annotate(style: 'warning', context: 'code-freeze-version-mismatch', message: warning_message) if is_ci + error_message = <<~ERROR + ❌ Version mismatch detected! + + The explicitly-provided version from the release tool is '#{provided_version}' but the computed version from the codebase is '#{computed_version}'. + + This mismatch must be resolved before proceeding with the code freeze. Please investigate and ensure the versions are aligned. + ERROR + buildkite_annotate(style: 'error', context: 'code-freeze-version-mismatch', message: error_message) if is_ci + UI.user_error!(error_message) end release_branch_name = compute_release_branch_name(options: { version: version, skip_confirm: skip_confirm }, version: new_version) From aeab5a8bb1c529681876feb5d337ef524721bf86 Mon Sep 17 00:00:00 2001 From: Ian Maia Date: Fri, 7 Nov 2025 17:49:29 -0300 Subject: [PATCH 2/2] Update code to properly use the received version as source of truth throughout code freeze lane --- fastlane/Fastfile | 9 ++++----- fastlane/lanes/release.rb | 30 +++++++++--------------------- 2 files changed, 13 insertions(+), 26 deletions(-) diff --git a/fastlane/Fastfile b/fastlane/Fastfile index b535b4d78560..22600ec29a09 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -128,15 +128,14 @@ end # Returns the build code of the app for the code freeze. It is the release version name plus sets the build number to 0 # -def build_code_code_freeze +def build_code_code_freeze(version_short: nil) + version_short ||= PUBLIC_VERSION_FILE.read_release_version # Read the current build code from the .xcconfig file and parse it into an AppVersion object # The AppVersion is used because WP/JPiOS uses the four part (1.2.3.4) build code format, so the version # calculator can be used to calculate the next four-part version - release_version_current = VERSION_FORMATTER.parse(PUBLIC_VERSION_FILE.read_release_version) - # Calculate the next release version, which will be used as the basis of the new build code - build_code_code_freeze = VERSION_CALCULATOR.next_release_version(version: release_version_current) + release_version_current = VERSION_FORMATTER.parse(version_short) # Return the formatted build code - BUILD_CODE_FORMATTER.build_code(version: build_code_code_freeze) + BUILD_CODE_FORMATTER.build_code(version: release_version_current) end # Returns the build code of the app for the code freeze. It is the hotfix version name plus sets the build number to 0 diff --git a/fastlane/lanes/release.rb b/fastlane/lanes/release.rb index b3472e5fb68d..23550278816a 100644 --- a/fastlane/lanes/release.rb +++ b/fastlane/lanes/release.rb @@ -19,35 +19,23 @@ # Check out the up-to-date default branch, the designated starting point for the code freeze Fastlane::Helper::GitHelper.checkout_and_pull(DEFAULT_BRANCH) - # Use provided version from release tool, or fall back to computed version - computed_version = release_version_next - provided_version = version - new_version = provided_version || computed_version - - # Fail if provided version differs from computed version - if provided_version && provided_version != computed_version - error_message = <<~ERROR - ❌ Version mismatch detected! - - The explicitly-provided version from the release tool is '#{provided_version}' but the computed version from the codebase is '#{computed_version}'. - - This mismatch must be resolved before proceeding with the code freeze. Please investigate and ensure the versions are aligned. - ERROR - buildkite_annotate(style: 'error', context: 'code-freeze-version-mismatch', message: error_message) if is_ci - UI.user_error!(error_message) - end + # If a new version is passed, use it as source of truth from now on + new_version = version || release_version_next + release_branch_name = compute_release_branch_name(options: { version: new_version, skip_confirm: skip_confirm }, version: new_version) + new_build_code = build_code_code_freeze(version_short: new_version) - release_branch_name = compute_release_branch_name(options: { version: version, skip_confirm: skip_confirm }, version: new_version) ensure_branch_does_not_exist!(release_branch_name) # The `release_version_next` is used as the `new internal release version` value because the external and internal # release versions are always the same. message = <<~MESSAGE + Code Freeze: • New release branch from #{DEFAULT_BRANCH}: #{release_branch_name} • Current release version and build code: #{release_version_current} (#{build_code_current}). - • New release version and build code: #{new_version} (#{build_code_code_freeze}). + • New release version and build code: #{new_version} (#{new_build_code}). + MESSAGE UI.important(message) @@ -61,8 +49,8 @@ # Bump the release version and build code and write it to the `xcconfig` file UI.message 'Bumping release version and build code...' PUBLIC_VERSION_FILE.write( - version_short: release_version_next, - version_long: build_code_code_freeze + version_short: new_version, + version_long: new_build_code ) UI.success "Done! New Release Version: #{release_version_current}. New Build Code: #{build_code_current}"