Package: bump-my-version
Bump My VersionNOTEThis is a maintained refactor of thebump2version forkof the excellentbumpversion project. The main goals of this refactor were:Add support forpyproject.tomlconfiguration files.Convert toclickfor andrichfor the CLI interfaceAdd better configuration validation usingPydanticMake the code and tests easier to read and maintainOverviewBump My Version's purpose is to:Work as a part of an automated build systemManage project versioning through the project's development life cycleIncrementing version numbersserializing version numbersparsing version numbersModify project files as part of the project's development life cycleWork with the project's source control systemCommitting changesTagging releasesReading version numbers from tagsInstallationYou can download and install the latest version of this software from the Python package index (PyPI) as follows:pip install --upgrade bump-my-versionChangelogPlease find the changelog here:CHANGELOG.mdSemantic versioning exampleCreate a default configurationThe default configuration uses a simplified version ofsemantic versioning.$bump-my-versionsample-config--no-prompt--destination.bumpversion.toml$cat.bumpversion.toml[tool.bumpversion]current_version = "0.1.0"parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"serialize = ["{major}.{minor}.{patch}"]search = "{current_version}"replace = "{new_version}"regex = falseignore_missing_version = falsetag = falsesign_tags = falsetag_name = "v{new_version}"tag_message = "Bump version: {current_version} → {new_version}"allow_dirty = falsecommit = falsemessage = "Bump version: {current_version} → {new_version}"commit_args = ""Visualize the versioning pathYou can see the potential versioning paths with theshow-bumpsubcommand.$bump-my-versionshow-bump0.1.0 ── bump ─┬─ major ─ 1.0.0├─ minor ─ 0.2.0╰─ patch ─ 0.1.1$bump-my-versionshow-bump1.2.31.2.3 ── bump ─┬─ major ─ 2.0.0├─ minor ─ 1.3.0╰─ patch ─ 1.2.4The default configuration only allows bumping the major, minor, or patch version. What if you wanted to support pre-release versions?Add support for pre-release versionsAlter theparseconfiguration to support pre-release versions. Thisparseoption uses an extended (or verbose) regular expression to extract the version parts from the current version.parse="""(?x)(?P<major>0|[1-9]\\d*)\\.(?P<minor>0|[1-9]\\d*)\\.(?P<patch>0|[1-9]\\d*)(?:-                             # dash seperator for pre-release section(?P<pre_l>[a-zA-Z-]+)         # pre-release label(?P<pre_n>0|[1-9]\\d*)        # pre-release version number)?                                # pre-release section is optional"""Alter theserializeconfiguration to support pre-release versions.serialize=["{major}.{minor}.{patch}-{pre_l}{pre_n}","{major}.{minor}.{patch}",]Add a new configuration section for thepre_lpart.[tool.bumpversion.parts.pre_l]values=["dev","rc","final"]optional_value="final"Visualize the new versioning pathNow when you runbump-my-version show-bump, you can see the new pre-release versioning path.$bump-my-versionshow-bump0.1.0 ── bump ─┬─ major ─ 1.0.0-dev0├─ minor ─ 0.2.0-dev0├─ patch ─ 0.1.1-dev0├─ pre_l ─ invalid: The part has already the maximum value among ['dev', 'rc', 'final'] and cannot be bumped.╰─ pre_n ─ 0.1.0-final1Thepre_lis not bump-able because it is already at the maximum value. Thepre_nis bump-able because it is not at the maximum value.If we runbump-my-version show-bump 1.0.0-dev0, we can see the new versioning path for adevstarting version.$bump-my-versionshow-bump1.0.0-dev01.0.0-dev0 ── bump ─┬─ major ─ 2.0.0-dev0├─ minor ─ 1.1.0-dev0├─ patch ─ 1.0.1-dev0├─ pre_l ─ 1.0.0-rc0╰─ pre_n ─ 1.0.0-dev1Finally, we can see the new versioning path for arcstarting version.$bump-my-versionshow-bump1.0.0-rc01.0.0-rc0 ── bump ─┬─ major ─ 2.0.0-dev0├─ minor ─ 1.1.0-dev0├─ patch ─ 1.0.1-dev0├─ pre_l ─ 1.0.0╰─ pre_n ─ 1.0.0-rc1The full development and release path is:1.0.0bump patch→1.0.1-dev0bump pre_n→1.0.1-dev1bump pre_l→1.0.1-rc0bump pre_n→1.0.1-rc1bump pre_l→1.0.1You must decide on the next version before you start developing.Development versions increase usingbump-my-version bump pre_n.Switch from development to release candidate usingbump-my-version bump pre_l.Release candidates increase usingbump-my-version bump pre_n.Switch from the release candidate to the final release usingbump-my-version bump pre_l.Automate the pre-release numberingThepre_nor pre-release number is a number that increases with each pre-release. You can automate this my changing the serialization configuration.serialize=["{major}.{minor}.{patch}-{pre_l}{distance_to_latest_tag}","{major}.{minor}.{patch}",]Thedistance_to_latest_tagis a special value that is replaced with the number of commits since the last tag. This is a good value to use for thepre_nbecause it will always increase with each commit.Visualize the pre_n versioning pathNow when you runbump-my-version show-bump, you can see the new pre-release versioning path.$bump-my-versionshow-bump0.1.0 ── bump ─┬─ major ─ 1.0.0-dev0├─ minor ─ 0.2.0-dev0├─ patch ─ 0.1.1-dev0╰─ pre_l ─ invalid: The part has already the maximum value among ['dev', 'rc', 'final'] and cannot be bumped.$bump-my-versionshow-bump1.0.0-dev01.0.0-dev0 ── bump ─┬─ major ─ 2.0.0-dev0├─ minor ─ 1.1.0-dev0├─ patch ─ 1.0.1-dev0╰─ pre_l ─ 1.0.0-rc0$bump-my-versionshow-bump1.0.0-rc01.0.0-rc0 ── bump ─┬─ major ─ 2.0.0-dev0├─ minor ─ 1.1.0-dev0├─ patch ─ 1.0.1-dev0╰─ pre_l ─ 1.0.0Thepre_npath is now missing because it is automated.The full development and release path now is:1.0.0bump patch→1.0.1-dev0each commit will increase →1.0.1-dev1bump pre_l→1.0.1-rc0each commit will increase →1.0.1-rc1bump pre_l→1.0.1You must decide on the next version before you start developing.Development versions increase automatically with each commit.Switch from development to release candidate usingbump-my-version bump pre_l.Release candidate versions increase automatically with each commit.Switch from the release candidate to the final release usingbump-my-version bump pre_l.Development & ContributingThank you, contributors! You can find a full list here:https://github.com/callowayproject/bump-my-version/graphs/contributorsSee also ourCONTRIBUTING.mdDevelopment of this happens on GitHub, patches including tests, and documentation are very welcome, as well as bug reports! Please open an issue if this tool does not support every aspect of bumping versions in your development
workflow, as it is intended to be very versatile.LicenseBump My Version is licensed under the MIT License - see theLICENSEfile for details