@@ -19,8 +19,9 @@ VERSION_FILE = Fastlane::Wpmreleasetoolkit::Versioning::AndroidVersionFile.new(v
1919
2020VERSION_CALCULATOR = Fastlane ::Wpmreleasetoolkit ::Versioning ::SemanticVersionCalculator . new
2121VERSION_FORMATTER = Fastlane ::Wpmreleasetoolkit ::Versioning ::RCNotationVersionFormatter . new
22- BUILD_CODE_CALCULATOR = Fastlane ::Wpmreleasetoolkit ::Versioning ::SimpleBuildCodeCalculator . new
23- BUILD_CODE_FORMATTER = Fastlane ::Wpmreleasetoolkit ::Versioning ::SimpleBuildCodeFormatter . new
22+ # Using DerivedBuildCodeFormatter to derive build codes from version name (format: 1XXYYZZNNN)
23+ # This eliminates the need for manual build code incrementing and provides deterministic versioning
24+ BUILD_CODE_FORMATTER = Fastlane ::Wpmreleasetoolkit ::Versioning ::DerivedBuildCodeFormatter . new
2425
2526PROTOTYPE_BUILD_DOMAIN = 'https://cdn.a8c-ci.services'
2627RELEASE_BUILD_TYPE = 'Release'
211212# Versioning utils
212213#####################################################################################
213214
214- # Updates the build code in version.properties to the next build code and commits the change
215+ # Updates the build code in version.properties by incrementing the build number and deriving the new build code
215216#
216217def bump_build_code
217218 VERSION_FILE . write_version (
@@ -260,19 +261,25 @@ def release_version_next
260261 VERSION_FORMATTER . release_version ( release_version_next )
261262end
262263
263- # Returns the current build code of the app
264+ # Returns the current build code of the app derived from the current version
264265#
265266def build_code_current
266- build_code_current = VERSION_FILE . read_version_code
267- BUILD_CODE_FORMATTER . build_code ( build_code : build_code_current )
267+ current_version = VERSION_FORMATTER . parse ( version_name_current )
268+ BUILD_CODE_FORMATTER . build_code ( version : current_version )
268269end
269270
270- # Returns the next build code of the app
271+ # Returns the next build code of the app derived from the current version with incremented build number
271272#
272273def build_code_next
273- build_code_current = VERSION_FILE . read_version_code
274- build_code_next = BUILD_CODE_CALCULATOR . next_build_code ( build_code : build_code_current )
275- BUILD_CODE_FORMATTER . build_code ( build_code : build_code_next )
274+ current_version = VERSION_FORMATTER . parse ( version_name_current )
275+ # Create a new version with incremented build number
276+ next_version = Fastlane ::Models ::AppVersion . new (
277+ current_version . major ,
278+ current_version . minor ,
279+ current_version . patch ,
280+ current_version . build_number + 1
281+ )
282+ BUILD_CODE_FORMATTER . build_code ( version : next_version )
276283end
277284
278285# Generates a build number for the prototype build
0 commit comments