Description
Has there been any thought as to how bump2version can be used to change the version of an Android project?
Typically an Android project has a <repo>/app/build.gradle
file that has something like:
android {
defaultConfig {
versionCode 1
versionName "1.0"
}
}
Where android.defaultConfig.versionCode
is basically a one-up counter, and android.defaultConfig.versionName
usually follows the form {major}.{minor}
(rarely does it have a patch element) -- per the Android versioning documentation.
I have not yet tested it, but I believe bump2version should be able to handle versionName (major.minor) but I do not know how it can handle versionCode (one-up counter), if it even could. Initially I would write a config with:
[bumpversion]
current_version = 1.0
commit = True
tag = True
tag_name = v{new_version}
message = Bump version: {current_version} → {new_version}
parse = (?P<major>\d+)\.(?P<minor>\d+)
serialize = {major}.{minor}
# The versionCode is a one-up counter.
[bumpversion:file (versionCode):app/build.gradle]
search = versionCode {current_version}
replace = versionCode {new_version}
# The versionName is a {major}.{minor} pair.
[bumpversion:file (versionName):app/build.gradle]
search = versionName "{current_version}"
replace = versionName "{new_version}"
But this won't work for versionCode. Any idea how I can finagle something into versionCode to be consistent with how it is normally handled by Android?