Open deliberist opened 2 years ago
This should work:
[bumpversion]
current_version = 1.0
parse = (?P<major>\d+).(?P<minor>\d+)
serialize =
{major}.{minor}
[bumpversion:file (versionName):build.gradle]
search = versionName "{current_version}"
replace = versionName "{new_version}"
[bumpversion:file (versionCode):build.gradle]
serialize =
{major}
search = versionCode {current_version}
replace = versionCode {new_version}
This should work:
[bumpversion] current_version = 1.0 parse = (?P<major>\d+).(?P<minor>\d+) serialize = {major}.{minor} [bumpversion:file (versionName):build.gradle] search = versionName "{current_version}" replace = versionName "{new_version}" [bumpversion:file (versionCode):build.gradle] serialize = {major} search = versionCode {current_version} replace = versionCode {new_version}
@Maccheroni I do not believe that will work. It will only set versionCode
to the major version. The major version (and versionCode
in that sample) does not increment when there are minor releases.
If hypothetically we released an Android application starting with 1.0 we'd want to maintain versionName
and versionCode
consistent with Android conventions:
# new major release
# new major release
# new major release
Bumpversion, as it stands, does not have a way to get a handle on what Android apps need as the versionCode
.
Hope that makes sense.
@rbprogrammer the unreleased version 1.0.2-dev has a configuration option indepenent for a part. By default when parent part is bumped, children part is set to its first value, and if part is independent, it retains the previous value. If I understand correctly, you want the part to increment every time the parent part changes.
I added configuration option _alwaysincrement in my fork
https://github.com/olutra/bump2version/tree/feature-always-increment
You can try to install it with
pip install git+https://github.com/olutra/bump2version.git@feature-always-increment
and test with config like
[bumpversion]
current_version = '15.4#19'
parse = '(?P<major>\d+).(?P<minor>\d+)\#(?P<counter>\d+)'
serialize = '{major}.{minor}#{counter}'
[bumpversion:file (versionName):build.gradle]
serialize = {major}.{minor}
search = versionName "{current_version}"
replace = versionName "{new_version}"
[bumpversion:file (versionCode):build.gradle]
serialize = {counter}
search = versionCode {current_version}
replace = versionCode {new_version}
[bumpversion:part:counter]
always_increment = True
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:Where
android.defaultConfig.versionCode
is basically a one-up counter, andandroid.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:
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?