Bump2version
Version-bump your software with a single command
Install / Use
/learn @c4urself/Bump2versionREADME
bump2version
⚠️ Warning
bump2versionis no longer maintained.You should switch to
bump-my-version.
Overview
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
- supports Python 3 and PyPy3
If you want to use Python 2, use pip>=9 and you'll get the last supported version,
or pin bump2version<1.
Alternatives
If bump2version does not fully suit your needs, you could take a look at other tools doing similar or related tasks: ALTERNATIVES.md.
Installation
You can download and install the latest version of this software from the Python package index (PyPI) as follows:
pip install --upgrade bump2version
NOTE: pip install bumpversion now installs the latest bump2version!
Changelog
Please find the changelog here: CHANGELOG.md
Usage
NOTE: Throughout this document you can use bumpversion or bump2version interchangeably.
There are two modes of operation: On the command line for single-file operation
and using a configuration file (.bumpversion.cfg) for more complex multi-file operations.
bump2version [options] part [file]
part
required<br />
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:
bump2version --current-version 0.5.1 minor src/VERSION
file
[optional]<br /> default: none
The file that will be modified.
This file is added to the list of files specified in [bumpversion:file:…]
sections from the configuration file. If you want to rewrite only files
specified on the command line, use --no-configured-files.
Example bumping 1.1.9 to 2.0.0:
bump2version --current-version 1.1.9 major setup.py
Configuration file
All options can optionally be specified in a config file called
.bumpversion.cfg so that once you know how bump2version 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 defaults.
Example .bumpversion.cfg:
[bumpversion]
current_version = 0.2.9
commit = True
tag = True
[bumpversion:file:setup.py]
If no .bumpversion.cfg exists, bump2version will also look into
setup.cfg for configuration.
Configuration file -- Global configuration
General configuration is grouped in a [bumpversion] section.
current_version
required<br /> default: none
The current version of the software package before bumping.
Also available as --current-version (e.g. bump2version --current-version 0.5.1 patch setup.py)
new_version
[optional]<br /> default: none
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: bump2version --current-version 0.5.1 --new-version 0.6.1 patch setup.py).
tag = (True | False)
[optional]<br /> 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)
[optional]<br /> default: False (Don't sign tags)
Whether to sign tags.
Also available on the command line as (--sign-tags | --no-sign-tags).
tag_name =
[optional]<br />
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 current_[part] and new_[part] (e.g. 'current_major'
or 'new_patch').
In addition, all environment variables are exposed, 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 command-line flag tag-name. Example usage:
bump2version --tag-name 'release-{new_version}' patch
tag_message =
[optional]<br />
default: Bump version: {current_version} → {new_version}
The tag message to use when creating a tag. 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 current_[part] and new_[part] (e.g. 'current_major'
or 'new_patch').
In addition, all environment variables are exposed, 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 command-line flag --tag-message. Example usage:
bump2version --tag-message 'Release {new_version}' patch
bump2version creates an annotated tag in Git by default. To disable this and create a lightweight tag, you must explicitly set an empty tag_message:
- either in the configuration file:
tag_message = - or in the command-line:
bump2version --tag-message ''
You can read more about Git tagging here.
commit = (True | False)
[optional]<br /> default: False (Don't create a commit)
Whether to create a commit using git or Mercurial.
Also available as (--commit | --no-commit).
In many projects it is common to have a pre-commit hook that runs prior to a
commit and in case of failure aborts the commit. For some use cases it might
be desired that when bumping a version and having commit = True, the
pre-commit hook should perform slightly different actions than in regular
commits. For example run an extended set of checks only for actual releases of
the software. To allow the pre-commit hooks to distinguish a bumpversion
commit, the BUMPVERSION_CURRENT_VERSION and BUMPVERSION_NEW_VERSION
environment variables are set when executing the commit command.
message =
[optional]<br />
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 current_[part] and new_[part] (e.g. 'current_major'
or 'new_patch').
In addition, all environment variables are exposed, 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 command-line flag --message. Example usage:
bump2version --message '[{now:%Y-%m-%d}] Jenkins Build {$BUILD_NUMBER}: {new_version}' patch)
commit_args =
[optional]<br /> default: empty
Extra arguments to pass to commit command. Only valid when using --commit /
commit = True.
This is for example useful to add -s to generate Signed-off-by: line in
the commit message.
Multiple arguments can be specified on separate lines.
Also available as command-line flag --commit-args, in which case only one
argument can be specified.
Configuration file -- 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 are 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
