Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 16 additions & 26 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -197,33 +197,23 @@ platform :ios do
# 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
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: 'start-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 || release_version_next
new_release_branch = "release/#{new_version}"
new_build_code = build_code_code_freeze(version_short: new_version)

UI.important <<-MESSAGE

Code Freeze:
• New release branch from #{DEFAULT_BRANCH}: release/#{new_version}
• New release branch from #{DEFAULT_BRANCH}: #{new_release_branch}

• 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.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?')

# Create the release branch
new_release_branch = "release/#{new_version}"
ensure_branch_does_not_exist!(new_release_branch)

UI.message('Creating release branch...')
Expand All @@ -233,8 +223,8 @@ platform :ios do
# Bump the release version and build code and write it to the `xcconfig` file
UI.message('Bumping release version and build code...')
VERSION_FILE.write(
version_short: release_version_next,
version_long: build_code_code_freeze
version_short: new_version,
version_long: new_build_code
)
commit_version_bump
UI.success("Done! New Release Version: #{release_version_current}. New Build Code: #{build_code_current}")
Expand Down Expand Up @@ -1419,9 +1409,10 @@ end

# Returns the next release version of the app in the format `1.2` or `1.2.3` if it is a hotfix
#
def release_version_next
def release_version_next(version_short: nil)
version_short ||= VERSION_FILE.read_release_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_release_version)
current_version = VERSION_FORMATTER.parse(version_short)
# Calculate the next release version
next_calculated_release_version = VERSION_CALCULATOR.next_release_version(version: current_version)
# Return the formatted release version
Expand All @@ -1441,15 +1432,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 ||= 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 WCiOS 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(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 next build code of the app
Expand Down