Skip to content

Commit 4af8a15

Browse files
committed
Update code to properly use the received version as source of truth throughout code freeze
1 parent 3d5df5a commit 4af8a15

File tree

1 file changed

+11
-24
lines changed

1 file changed

+11
-24
lines changed

fastlane/Fastfile

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -121,18 +121,18 @@ platform :android do
121121
# Check out the up-to-date default branch, the designated starting point for the code freeze
122122
Fastlane::Helper::GitHelper.checkout_and_pull(DEFAULT_BRANCH)
123123

124-
# If version provided by release tool, use it as source of truth
125-
UI.important("Using provided version: #{version}") if version
126-
124+
# If a new version is passed, use it as source of truth from now on
127125
new_version = version || release_version_next
128126
new_release_branch = "release/#{new_version}"
127+
new_beta_version = beta_version_next(version_name: new_version)
129128

130129
message = <<-MESSAGE
131130
132-
Code Freeze:
131+
Code Freeze:
133132
• New release branch from #{DEFAULT_BRANCH}: #{new_release_branch}
133+
134134
• Current release version and build code: #{release_version_current} (#{build_code_current}).
135-
• New beta version and build code: #{beta_version_first} (#{build_code_next}).
135+
• New beta version and build code: #{new_beta_version} (#{build_code_next}).
136136
137137
MESSAGE
138138

@@ -149,7 +149,7 @@ platform :android do
149149
# Bump the version and build code
150150
UI.message 'Bumping beta version and build code...'
151151
VERSION_FILE.write_version(
152-
version_name: beta_version_first,
152+
version_name: new_beta_version,
153153
version_code: build_code_next
154154
)
155155
commit_version_bump
@@ -1343,29 +1343,16 @@ platform :android do
13431343
VERSION_FORMATTER.release_version(release_version_next)
13441344
end
13451345

1346-
# Returns the beta version that is used by the code freeze
1347-
# It first increments the minor number, which also resets the build number to 0
1348-
# It then bumps the build number so the -rc-1 can be appended to the code freeze version
1349-
def beta_version_first
1350-
# Read the current release version from `version.properties` and parse it into an AppVersion object
1351-
current_version = VERSION_FORMATTER.parse(VERSION_FILE.read_version_name)
1352-
# Calculate the next major version number
1353-
next_version = VERSION_CALCULATOR.next_release_version(version: current_version)
1354-
# Calculate the next build number
1355-
beta_version_first = VERSION_CALCULATOR.next_build_number(version: next_version)
1356-
# Return the formatted release version
1357-
VERSION_FORMATTER.beta_version(beta_version_first)
1358-
end
1359-
13601346
# Returns the beta version of the app in the format `1.2-rc-1`
13611347
#
1362-
def beta_version_next
1348+
def beta_version_next(version_name: nil)
1349+
version_name ||= VERSION_FILE.read_version_name
13631350
# Read the current release version from `version.properties` and parse it into an AppVersion object
1364-
current_version = VERSION_FORMATTER.parse(VERSION_FILE.read_version_name)
1351+
current_version = VERSION_FORMATTER.parse(version_name)
13651352
# Calculate the next beta version
1366-
beta_version_next = VERSION_CALCULATOR.next_build_number(version: current_version)
1353+
next_beta_version = VERSION_CALCULATOR.next_build_number(version: current_version)
13671354
# Return the formatted release version
1368-
VERSION_FORMATTER.beta_version(beta_version_next)
1355+
VERSION_FORMATTER.beta_version(next_beta_version)
13691356
end
13701357

13711358
# Returns the current build code of the app

0 commit comments

Comments
 (0)