diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 978ce3e3f6e5..a93b66eb00a1 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -108,25 +108,12 @@ def current_beta_version VERSION_FORMATTER.beta_version(current_version) end -# Returns the beta version that is used by the code freeze -# It first increments the minor number, which also resets the build number to 0 -# It then bumps the build number so the -rc-1 can be appended to the code freeze version -def code_freeze_beta_version - # Read the current release version from the .xcconfig file and parse it into an AppVersion object - current_version = VERSION_FORMATTER.parse(VERSION_FILE.read_version_name) - # Calculate the next major version number - next_version = VERSION_CALCULATOR.next_release_version(version: current_version) - # Calculate the next build number - code_freeze_beta_version = VERSION_CALCULATOR.next_build_number(version: next_version) - # Return the formatted release version - VERSION_FORMATTER.beta_version(code_freeze_beta_version) -end - # Returns the beta version of the app in the format `1.2-rc-1` # -def next_beta_version +def next_beta_version(version_name: nil) + version_name ||= VERSION_FILE.read_version_name # Read the current release version from the .xcconfig file and parse it into an AppVersion object - current_version = VERSION_FORMATTER.parse(VERSION_FILE.read_version_name) + current_version = VERSION_FORMATTER.parse(version_name) # Calculate the next beta version next_beta_version = VERSION_CALCULATOR.next_build_number(version: current_version) # Return the formatted release version diff --git a/fastlane/lanes/release.rb b/fastlane/lanes/release.rb index 347de45c1e43..9d234d8032ce 100644 --- a/fastlane/lanes/release.rb +++ b/fastlane/lanes/release.rb @@ -9,32 +9,22 @@ # lane :code_freeze do |version: nil, skip_confirm: false| ensure_git_status_clean + Fastlane::Helper::GitHelper.checkout_and_pull(DEFAULT_BRANCH) - ensure_git_branch(branch: DEFAULT_BRANCH) - - # Use provided version from release tool, or fall back to computed version - computed_version = next_release_version - new_version = version || computed_version - - # Warn if provided version differs from computed version - if version && version != computed_version - warning_message = <<~WARNING - ⚠️ Version mismatch: The explicitly-provided version was '#{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 '#{version}'. - WARNING - UI.important(warning_message) - buildkite_annotate(style: 'warning', context: 'code-freeze-version-mismatch', message: warning_message) if is_ci - end + + # If a new version is passed, use it as source of truth from now on + new_version = version || next_release_version + release_branch_name = "release/#{new_version}" + new_beta_version = next_beta_version(version_name: new_version) + new_build_code = next_build_code message = <<-MESSAGE Code Freeze: - • New release branch from #{DEFAULT_BRANCH}: release/#{new_version} - • Current release version and build code: #{current_release_version} (#{current_build_code}). - • New release version and build code: #{code_freeze_beta_version} (#{next_build_code}). + • New release branch from #{DEFAULT_BRANCH}: #{release_branch_name} - Do you want to continue? + • Current release version and build code: #{current_release_version} (#{current_build_code}). + • New release version and build code: #{new_beta_version} (#{new_build_code}). MESSAGE @@ -42,7 +32,6 @@ UI.user_error!('Aborted by user request') unless skip_confirm || UI.confirm('Do you want to continue?') - release_branch_name = "release/#{new_version}" ensure_branch_does_not_exist!(release_branch_name) # Create the release branch @@ -54,8 +43,8 @@ # Bump the version and build code UI.message 'Bumping beta version and build code...' VERSION_FILE.write_version( - version_name: code_freeze_beta_version, - version_code: next_build_code + version_name: new_beta_version, + version_code: new_build_code ) commit_version_bump UI.success "Done! New Beta Version: #{current_beta_version}. New Build Code: #{current_build_code}" @@ -87,7 +76,7 @@ copy_branch_protection( repository: GITHUB_REPO, from_branch: DEFAULT_BRANCH, - to_branch: "release/#{new_version}" + to_branch: release_branch_name ) begin