Skip to main content

Version-bump your software with a single command!

Project description


This Fork

This is a fork (**ADVbumpversion**) of a fork (**bump2version**).

The excellent original project that can be found here:
Unfortunately it seems like development has been stuck for some time and no activity has been seen from the

Christian Verkerk has made some Pull Request merges and this project (renamed **bump2version**) can be found here:

I have merged other Push Requests, in particular the ability to have more than one rule for a file,
in a new project **ADVbumpversion**. The major differences are:

- It is possible to have more than one set of rules (``parse``, ``serialize``, ``search`` and ``replace``) for the
same file

- Some parts of the version can be independent of the others: They are not incremented with the other parts. It is in
particular useful when you have a build number that is incremented independently of the version

- Several examples of usage

- More testing cases

Look at ``CHANGELOG.rst`` to see all the changes.

**Note**: For compatibility, this project declares ``advbumpversion``, ``bump2version`` and ``bumpversion``. They are
identical. The remaining of this document uses ``bumpversion`` in command-line examples.


Version-bump your software with a single command!

A small command line tool to simplify releasing software by updating all
version strings in your source code by the correct increment. Also creates
commits and tags:

- version formats are highly configurable
- works without any VCS, but happily reads tag information from and writes
commits and tags to Git and Mercurial if available
- just handles text files, so it's not specific to any programming language


You can download and install the latest version of this software from the Python package index (PyPI) as follows::

pip install --upgrade advbumpversion


**Note**: I have compiled several usage examples in ``EXAMPLES.rst``.

There are two modes of operation: On the command line for single-file operation
and using a `configuration file <#configuration>`_ for more complex multi-file


bumpversion [options] part [file]

``part`` (required)
The part of the version to increase, e.g. ``minor``.

Valid values include those given in the ``--serialize`` / ``--parse`` option.

Example bumping ``0.5.1`` to ``0.6.0``::

bumpversion --current-version 0.5.1 minor src/VERSION

**default: none** (optional)

The file that will be modified.

If not given, the list of ``[bumpversion:file:…]`` sections from the
configuration file will be used. If no files are mentioned on the
configuration file either, are no files will be modified.

Example bumping ``1.1.9`` to ``2.0.0``::

bumpversion --current-version 1.1.9 major


All options can optionally be specified in a config file called
``.bumpversion.cfg`` so that once you know how ``bumpversion`` needs to be
configured for one particular software package, you can run it without
specifying options later. You should add that file to VCS so others can also
bump versions.

Options on the command line take precedence over those from the config file,
which take precedence over those derived from the environment and then from the

Example ``.bumpversion.cfg``::

current_version = 0.2.9
commit = True
tag = True


If no ``.bumpversion.cfg`` exists, ``bumpversion`` will also look into
``setup.cfg`` for configuration.

Global configuration

General configuration is grouped in a ``[bumpversion]`` section.

``current_version =``
**no default value** (required)

The current version of the software package before bumping.

Also available as ``--current-version`` (e.g. ``bumpversion --current-version 0.5.1 patch``)

``new_version =``
**no default value** (optional)

The version of the software package after the increment. If not given will be
automatically determined.

Also available as ``--new-version`` (e.g. to go from 0.5.1 directly to
0.6.1: ``bumpversion --current-version 0.5.1 --new-version 0.6.1 patch``).

``tag = (True | False)``
**default:** False (`Don't create a tag`)

Whether to create a tag, that is the new version, prefixed with the character
"``v``". If you are using git, don't forget to ``git-push`` with the
``--tags`` flag.

Also available on the command line as ``(--tag | --no-tag)``.

``sign_tags = (True | False)``
**default:** False (`Don't sign tags`)

Whether to sign tags.

Also available on the command line as ``(--sign-tags | --no-sign-tags)``.

``tag_name =``
**default:** ``v{new_version}``

The name of the tag that will be created. Only valid when using ``--tag`` / ``tag = True``.

This is templated using the `Python Format String Syntax
Available in the template context are ``current_version`` and ``new_version``
as well as all environment variables (prefixed with ``$``). You can also use
the variables ``now`` or ``utcnow`` to get a current timestamp. Both accept
datetime formatting (when used like as in ``{now:%d.%m.%Y}``).

Also available as ``--tag-name`` (e.g. ``bumpversion --message 'Jenkins Build
{$BUILD_NUMBER}: {new_version}' patch``).

``tag_message =``
**default:** ``Bump version: {current_version} -> {new_version}``

The annotation of the tag that will be created. Only valid when using ``--tag`` / ``tag = True``.

This is templated using the `Python Format String Syntax
Available in the template context are ``current_version`` and ``new_version``
as well as all environment variables (prefixed with ``$``). You can also use
the variables ``now`` or ``utcnow`` to get a current timestamp. Both accept
datetime formatting (when used like as in ``{now:%d.%m.%Y}``).

Also available as ``--tag-message``.

``commit = (True | False)``
**default:** ``False`` (`Don't create a commit`)

Whether to create a commit using git or Mercurial.

Also available as ``(--commit | --no-commit)``.

``message =``
**default:** ``Bump version: {current_version} -> {new_version}``

The commit message to use when creating a commit. Only valid when using ``--commit`` / ``commit = True``.

This is templated using the `Python Format String Syntax
Available in the template context are ``current_version`` and ``new_version``
as well as all environment variables (prefixed with ``$``). You can also use
the variables ``now`` or ``utcnow`` to get a current timestamp. Both accept
datetime formatting (when used like as in ``{now:%d.%m.%Y}``).

Also available as ``--message`` (e.g.: ``bumpversion --message
'[{now:%Y-%m-%d}] Jenkins Build {$BUILD_NUMBER}: {new_version}' patch``)

Part specific configuration

A version string consists of one or more parts, e.g. the version ``1.0.2``
has three parts, separated by a dot (``.``) character. In the default
configuration these parts are named `major`, `minor`, `patch`, however you can
customize that using the ``parse``/``serialize`` option.

By default all parts considered numeric, that is their initial value is ``0``
and they are increased as integers. Also, the value ``0`` is considered to be
optional if it's not needed for serialization, i.e. the version ``1.4.0`` is
equal to ``1.4`` if ``{major}.{minor}`` is given as a ``serialize`` value.

For advanced versioning schemes, non-numeric parts may be desirable (e.g. to
identify `alpha or beta versions
to indicate the stage of development, the flavor of the software package or
a release name). To do so, you can use a ``[bumpversion:part:…]`` section
containing the part's name (e.g. a part named ``release_name`` is configured in
a section called ``[bumpversion:part:release_name]``.

The following options are valid inside a part configuration:

``values =``
**default**: numeric (i.e. ``0``, ``1``, ``2``, …)

Explicit list of all values that will be iterated when bumping that specific


values =

``optional_value =``
**default**: The first entry in ``values =``.

If the value of the part matches this value it is considered optional, i.e.
it's representation in a ``--serialize`` possibility is not required.


current_version = 1.alpha
parse = (?P<num>\d+)(\.(?P<release>.*))?
serialize =

optional_value = gamma
values =

Here, ``bumpversion release`` would bump ``1.alpha`` to ``1.beta``. Executing
``bumpversion release`` again would bump ``1.beta`` to ``1``, because
`release` being ``gamma`` is configured optional.

``first_value =``
**default**: The first entry in ``values =``.

When the part is reset, the value will be set to the value specified here.

``independent = ``
**default**: False

When this value is set to True, the part is not reset when other parts are incremented. Its incrementation is
independent of the other parts. It is in particular useful when you have a build number in your version that is
incremented independently of the actual version.

File specific configuration


**Note**: If you want to specify different options (``parse``, ...) for the same file, you can have several sections for the same file.
To distinguish these sections, append ``:`` and an identifier (its value has no importance) after the file name::

parse = ...

parse = ...

``parse =``
**default:** ``(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)``

Regular expression (using `Python regular expression syntax
<>`_) on
how to find and parse the version string.

Is required to parse all strings produced by ``serialize =``. Named matching
groups ("``(?P<name>...)``") provide values to as the ``part`` argument.

Also available as ``--parse``

``serialize =``
**default:** ``{major}.{minor}.{patch}``

Template specifying how to serialize the version parts back to a version

This is templated using the `Python Format String Syntax
Available in the template context are parsed values of the named groups
specified in ``parse =`` as well as all environment variables (prefixed with

Can be specified multiple times, bumpversion will try the serialization
formats beginning with the first and choose the last one where all values can
be represented like this::

serialize =

Given the example above, the new version *1.9* it will be serialized as
``1.9``, but the version *2.0* will be serialized as ``2``.

Also available as ``--serialize``. Multiple values on the command line are
given like ``--serialize {major}.{minor} --serialize {major}``

``search =``
**default:** ``{current_version}``

Template string how to search for the string to be replaced in the file.
Useful if the remotest possibility exists that the current version number
might be multiple times in the file and you mean to only bump one of the
occurrences. Can be multiple lines, templated using `Python Format String Syntax

``replace =``
**default:** ``{new_version}``

Template to create the string that will replace the current version number in
the file.

Given this ``requirements.txt``::


using this ``.bumpversion.cfg`` will ensure only the line containing
``MyProject`` will be changed::

current_version = 1.5.6

search = MyProject=={current_version}
replace = MyProject=={new_version}

Can be multiple lines, templated using `Python Format String Syntax


Most of the configuration values above can also be given as an option.
Additionally, the following options are available:

``--dry-run, -n``
Don't touch any files, just pretend. Best used with ``--verbose``.

Normally, bumpversion will abort if the working directory is dirty to protect
yourself from releasing unversioned files and/or overwriting unsaved changes.
Use this option to override this check.

Print useful information to stderr

List machine readable information to stdout for consumption by other

Example output::


``-h, --help``
Print help and exit

Using bumpversion in a script

If you need to use the version generated by bumpversion in a script you can make use of
the `--list` option, combined with `grep` and `sed`.

Say for example that you are using git-flow to manage your project and want to automatically
create a release. When you issue `git flow release start` you already need to know the
new version, before applying the change.

The standard way to get it in a bash script is

bumpversion --dry-run --list <part> | grep <field name> | sed -r s,"^.*=",,

where <part> is as usual the part of the version number you are updating. You need to specify
`--dry-run` to avoid bumpversion actually bumping the version number.

For example, if you are updating the minor number and looking for the new version number this becomes

bumpversion --dry-run --list minor | grep new_version | sed -r s,"^.*=",,


Development of this happens on GitHub, patches including tests, documentation
are very welcome, as well as bug reports! Also 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.

How to release bumpversion itself

Execute the following commands::

git checkout master
git pull
make test
bumpversion release
python sdist bdist_wheel upload
bumpversion --no-tag patch
git push origin master --tags


**ADVbumpversion** is licensed under the MIT License - see the LICENSE.rst file for details

.. _changelog:



- Add ``independent`` flag for version parts. This part is not reset when other parts are incremented. For example, for
build numbers
- Add EXAMPLES.rst with several test cases
- Add new test cases: update version and build date, build number, annotated tags, test cases for almost all cases in


- Fix a bug with PR#117: allow multiple config sections per file. Add a test case.


- Compatibility with Travis CI
- Publish on PyPi


Fork of fork. The project is renamed **advbumpversion** to avoid confusion with other forks.
The following Push requests are merged in this project:

- `PR#8 <>`_ from @ekoh: Add Python 3.5 and 3.6 to the supported versions: Add Python 3.5 and 3.6 to the supported versions
- `PR#117 <>`_ from from @chadawagner: allow multiple config sections per file
- `PR#136 <>`_ from @vadeg: Fix documentation example with 'optional_value'
- `PR#138 <>`_ from @smsearcy: Fixes TypeError in Python 3 on Windows
- `PR#157 <>`_ from todd-dembrey: Fix verbose tags

I consider this project stable enough to raise the version to 1.0.0.


- Added support for signing tags (git tag -s)
thanks: @Californian (`#6 <>`_)


- Added compatibility with `bumpversion` by making script install as `bumpversion` as well
thanks: @the-allanc (`#2 <>`_)


- Added support for annotated tags
thanks: @ekohl @gvangool (`#58 <>`_)


- Renamed to bump2version to ensure no conflicts with original package


- Fix bug where ``--new-version`` value was not used when config was present
(thanks @cscetbon @ecordell (`#60 <>`_)
- Preserve case of keys config file
(thanks theskumar `#75 <>`_)
- Windows CRLF improvements (thanks @thebjorn)


- Document file specific options ``search =`` and ``replace =`` (introduced in 0.5.0)
- Fix parsing individual labels from ``serialize =`` config even if there are
characters after the last label (thanks @mskrajnowski `#56
- Fix: Don't crash in git repositories that have tags that contain hyphens
(`#51 <>`_) (`#52
- Fix: Log actual content of the config file, not what ConfigParser prints
after reading it.
- Fix: Support multiline values in ``search =``
- also load configuration from ``setup.cfg`` (thanks @t-8ch `#57


This is a major one, containing two larger features, that require some changes
in the configuration format. This release is fully backwards compatible to
*v0.4.1*, however deprecates two uses that will be removed in a future version.

- New feature: `Part specific configuration <#part-specific-configuration>`_
- New feature: `File specific configuration <#file-specific-configuration>`_
- New feature: parse option can now span multiple line (allows to comment complex
regular expressions. See `re.VERBOSE in the Python documentation
<>`_ for details, `this
as an example.)
- New feature: ``--allow-dirty`` (`#42 <>`_).
- Fix: Save the files in binary mode to avoid mutating newlines (thanks @jaraco `#45 <>`_).
- License: bumpversion is now licensed under the MIT License (`#47 <>`_)

- Deprecate multiple files on the command line (use a `configuration file <#configuration>`_ instead, or invoke ``bumpversion`` multiple times)
- Deprecate 'files =' configuration (use `file specific configuration <#file-specific-configuration>`_ instead)


- Add --list option (`#39 <>`_)
- Use temporary files for handing over commit/tag messages to git/hg (`#36 <>`_)
- Fix: don't encode stdout as utf-8 on py3 (`#40 <>`_)
- Fix: logging of content of config file was wrong


- Add --verbose option (`#21 <>`_ `#30 <>`_)
- Allow option --serialize multiple times


- Fix: --parse/--serialize didn't work from cfg (`#34 <>`_)


- Don't fail if git or hg is not installed (thanks @keimlink)
- "files" option is now optional (`#16 <>`_)
- Fix bug related to dirty work dir (`#28 <>`_)


- Fix --tag default (thanks @keimlink)


- add {now} and {utcnow} to context
- use correct file encoding writing to config file. NOTE: If you are using
Python2 and want to use UTF-8 encoded characters in your config file, you
need to update ConfigParser like using 'pip install -U configparser'
- leave current_version in config even if available from vcs tags (was
- print own version number in usage
- allow bumping parts that contain non-numerics
- various fixes regarding file encoding


- bugfix: tag_name and message in .bumpversion.cfg didn't have an effect (`#9 <>`_)


- add --tag-name option
- now works on Python 3.2, 3.3 and PyPy


- bugfix: Read only tags from `git describe` that look like versions


- bugfix: ``--help`` in git workdir raising AssertionError
- bugfix: fail earlier if one of files does not exist
- bugfix: ``commit = True`` / ``tag = True`` in .bumpversion.cfg had no effect


- **BREAKING CHANGE** The ``--bump`` argument was removed, this is now the first
positional argument.
If you used ``bumpversion --bump major`` before, you can use
``bumpversion major`` now.
If you used ``bumpversion`` without arguments before, you now
need to specify the part (previous default was ``patch``) as in
``bumpversion patch``).


- add --no-commit, --no-tag


- If available, use git to learn about current version


- Mercurial support


- Only create a tag when it's requested (thanks @gvangool)


- Initial public version

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

advbumpversion-1.2.0.tar.gz (43.6 kB view hashes)

Uploaded Source

Built Distribution

advbumpversion-1.2.0-py2.py3-none-any.whl (27.7 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page