Friday 11 December 2020

bump2version to increment pre-release while removing post-release segment

How would I use bump2version (with regards to its invocation and/or its configuration) to increment:

1.0.0.a2.post0 # post-release of a pre-release a2

to

1.0.0.a3 # pre-release a3

Reproducible example:

$ python3 -m pip install 'bump2version==1.0.*'

__init__.py:

__version__ = "1.0.0.a2.post0"

setup.cfg:

[bumpversion]
current_version = 1.0.0.a2.post0
parse = ^
    (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)  # minimum major.minor.patch, 1.2.3
    (?:
    \.
    (?P<prerel>a|alpha|b|beta|d|dev|rc)  # pre-release segment
    (?P<prerelversion>\d+)  # pre-release version num
    )?
    (?:\.post(?P<post>\d+))?  # post-release
serialize =
    {major}.{minor}.{patch}.{prerel}{prerelversion}.post{post}
    {major}.{minor}.{patch}.{prerel}{prerelversion}
    {major}.{minor}.{patch}.post{post}
    {major}.{minor}.{patch}

[bumpversion:file:__init__.py]

[bumpversion:part:prerel]
optional_value = dev
values =
    dev
    d
    alpha
    a
    beta
    b
    rc

Examples of valid versions from this scheme, which takes some but not all rules from PEP 440:

1.2.3             # (1) final

1.2.3.dev0        # (2) prerelease
1.2.3.a0
1.2.3.alpha0
1.2.3.b0
1.2.3.beta0
1.2.3.rc0

1.2.3.rc3.post0   # (3) postrelease (of a pre-release version)

1.2.3.post0       # (4) postrelease (of a final version)

I've tried, for example, bump2version --verbose prerelversion or alternatively with --new-version=1.0.0.a3 explicitly. Both of those attempts retain the .post0 rather than dropping it.


Note: I asked this as a usage question issue in the bump2version repo a few weeks back with no luck.



from bump2version to increment pre-release while removing post-release segment

No comments:

Post a Comment