Skip to content
Merged
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
64 changes: 21 additions & 43 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -121,35 +121,25 @@ platform :android 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_beta_version = beta_version_next(version_name: new_version)

message = <<-MESSAGE

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

• Current release version and build code: #{release_version_current} (#{build_code_current}).
• New beta version and build code: #{beta_version_first} (#{build_code_next}).
• New beta version and build code: #{new_beta_version} (#{build_code_next}).

MESSAGE

UI.important(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 @@ -159,7 +149,7 @@ platform :android do
# Bump the version and build code
UI.message 'Bumping beta version and build code...'
VERSION_FILE.write_version(
version_name: beta_version_first,
version_name: new_beta_version,
version_code: build_code_next
)
commit_version_bump
Expand Down Expand Up @@ -190,7 +180,7 @@ platform :android do
copy_branch_protection(
repository: GITHUB_REPO,
from_branch: DEFAULT_BRANCH,
to_branch: "release/#{new_version}"
to_branch: new_release_branch
)

begin
Expand Down Expand Up @@ -1353,29 +1343,17 @@ platform :android do
VERSION_FORMATTER.release_version(release_version_next)
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 beta_version_first
# Read the current release version from `version.properties` 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
beta_version_first = VERSION_CALCULATOR.next_build_number(version: next_version)
# Return the formatted release version
VERSION_FORMATTER.beta_version(beta_version_first)
end

# Returns the beta version of the app in the format `1.2-rc-1`
#
def beta_version_next
# Read the current release version from `version.properties` and parse it into an AppVersion object
current_version = VERSION_FORMATTER.parse(VERSION_FILE.read_version_name)
# Calculate the next beta version
beta_version_next = VERSION_CALCULATOR.next_build_number(version: current_version)
# Return the formatted release version
VERSION_FORMATTER.beta_version(beta_version_next)
# Returns the next beta version in the format `1.2-rc-2` (increments the build number)
#
def beta_version_next(version_name: nil)
# Use provided version or read the current version from version.properties
version_name ||= VERSION_FILE.read_version_name
# Parse the version string (e.g., "1.2-rc-1") into an AppVersion object
current_version = VERSION_FORMATTER.parse(version_name)
# Increment the build number to get the next beta version
next_beta_version = VERSION_CALCULATOR.next_build_number(version: current_version)
# Format as beta version (e.g., "1.2-rc-2")
VERSION_FORMATTER.beta_version(next_beta_version)
end

# Returns the current build code of the app
Expand Down