Bumpversion optional dev version

93 Views Asked by At

I am using the Bumpversion utility (https://github.com/peritus/bumpversion) to increase the version of my application.

And I want to make dev build - add a suffix to a regular version optionally. With the current approach, I can't do bumpversion dev - it says:

ValueError: The part has already the maximum value among ['dev'] and cannot be bumped.

[bumpversion]
current_version = 1.5.3
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(-(?P<dev>.*)-(?P<build>\d+))?
serialize = 
    {major}.{minor}.{patch}-{dev}-{build}
    {major}.{minor}.{patch}

[bumpversion:part:dev]
values = 
    dev

[bumpversion:part:build]
first_value = 1

How to create dev-{build} version optionally?

1

There are 1 best solutions below

0
On

I was able to fix this on my end using "" as the initial state of dev, as in:

[bumpversion:part:dev]
values = 
    ""
    dev

What appears to be happening is that since your part definition only contains one value, bumpversion presumes the part is already in that state and has nowhere to go.

Further evidenced in that you can set the initial state to anything. For instance this also works:

[bumpversion:part:dev]
values = 
    13423423
    dev

Fortunately, version bumps don't appear to be cyclical, so I don't think there's a way to ever get back to the "" or 13423423 state.