Package: bumpversion
⚠️ Current status of this project🎬If you want to startusing bumpversion, you’re best advised toinstall one of the maintained forks, e.g. ➡@c4urself’s bump2version.🔨If you want tohelp maintainbumpversion, there’s anongoing discussion about merging the fork back to the original project as well as forming a group of maintainersto ensure a long-term future for this project. Please contribute.bumpversionA 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 configurableworks without any VCS, but happily reads tag information from and writes
commits and tags to Git and Mercurial if availablejust handles text files, so it’s not specific to any programming languageScreencastInstallationYou can download and install the latest version of this software from the Python package index (PyPI) as follows:pip install --upgrade bumpversionUsageThere are two modes of operation: On the command line for single-file operation
and using a configuration file  for more complex multi-file
operations.bumpversion [options] part [file]part(required)The part of the version to increase, e.g.minor.Valid values include those given in the--serialize/--parseoption.Examplebumping 0.5.1 to 0.6.0:bumpversion --current-version 0.5.1 minor src/VERSION[file]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.Examplebumping 1.1.9 to 2.0.0:bumpversion --current-version 1.1.9 major setup.pyConfigurationAll options can optionally be specified in a config file called.bumpversion.cfgso that once you know howbumpversionneeds 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.cfgexists,bumpversionwill also look intosetup.cfgfor configuration.Global configurationGeneral 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-version0.5.1 patch setup.py)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-version0.5.1--new-version0.6.1 patch setup.py).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 togit-pushwith the--tagsflag.Also available on the command line as(--tag|--no-tag).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 thePython Format String Syntax.
Available in the template context arecurrent_versionandnew_versionas well as all environment variables (prefixed with$). You can also use
the variablesnoworutcnowto 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).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 thePython Format String Syntax.
Available in the template context arecurrent_versionandnew_versionas well as all environment variables (prefixed with$). You can also use
the variablesnoworutcnowto 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 configurationA version string consists of one or more parts, e.g. the version1.0.2has three parts, separated by a dot (.) character. In the default
configuration these parts are namedmajor,minor,patch, however you can
customize that using theparse/serializeoption.By default all parts considered numeric, that is their initial value is0and they are increased as integers. Also, the value0is considered to be
optional if it’s not needed for serialization, i.e. the version1.4.0is
equal to1.4if{major}.{minor}is given as aserializevalue.For advanced versioning schemes, non-numeric parts may be desirable (e.g. to
identifyalpha 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 namedrelease_nameis 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
part.Example:[bumpversion:part:release_name]
values =
  witty-warthog
  ridiculous-rat
  marvelous-mantisoptional_value =default: The first entry invalues =.If the value of the part matches this value it is considered optional, i.e.
it’s representation in a--serializepossibility is not required.Example:[bumpversion]
current_version = 1.alpha
parse = (?P<num>\d+)\.(?P<release>.*)
serialize =
  {num}.{release}
  {num}

[bumpversion:part:release]
optional_value = gamma
values =
  alpha
  beta
  gammaHere,bumpversion releasewould bump1.alphato1.beta. Executingbumpversion releaseagain would bump1.betato1, becausereleasebeinggammais configured optional.first_value =default: The first entry invalues =.When the part is reset, the value will be set to the value specified here.File specific configuration[bumpversion:file:…]parse =default:(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)Regular expression (usingPython regular expression syntax) on
how to find and parse the version string.Is required to parse all strings produced byserialize =. Named matching
groups (”(?P<name>...)”) provide values to as thepartargument.Also available as--parseserialize =default:{major}.{minor}.{patch}Template specifying how to serialize the version parts back to a version
string.This is templated using thePython Format String Syntax.
Available in the template context are parsed values of the named groups
specified inparse =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 =
  {major}.{minor}
  {major}Given the example above, the new version1.9it will be serialized as1.9, but the version2.0will be serialized as2.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
occurences. Can be multiple lines, templated usingPython Format String Syntax.replace =default:{new_version}Template to create the string that will replace the current version number in
the file.Given thisrequirements.txt:Django>=1.5.6,<1.6
MyProject==1.5.6using this.bumpversion.cfgwill ensure only the line containingMyProjectwill be changed:[bumpversion]
current_version = 1.5.6

[bumpversion:file:requirements.txt]
search = MyProject=={current_version}
replace = MyProject=={new_version}Can be multiple lines, templated usingPython Format String Syntax.OptionsMost of the configuration values above can also be given as an option.
Additionally, the following options are available:--dry-run,-nDon’t touch any files, just pretend. Best used with--verbose.--allow-dirtyNormally, 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.--verbosePrint useful information to stderr--listList machine readable information to stdout for consumption by other
programs.Example output:current_version=0.0.18
new_version=0.0.19-h,--helpPrint help and exitUsing bumpversion in a scriptIf you need to use the version generated by bumpversion in a script you can make use of
the–listoption, combined withgrepandsed.Say for example that you are using git-flow to manage your project and want to automatically
create a release. When you issuegit flow release startyou already need to know the
new version, before applying the change.The standard way to get it in a bash script isbumpversion –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-runto avoid bumpversion actually bumping the version number.For example, if you are updating the minor number and looking for the new version number this becomesbumpversion –dry-run –list minor | grep new_version | sed -r s,”^.*=”,,DevelopmentDevelopment 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 itselfExecute the following commands:git checkout master
git pull
tox
bumpversion release
python setup.py sdist bdist_wheel upload
bumpversion --no-tag patch
git push origin master --tagsLicensebumpversion is licensed under the MIT License - see the LICENSE.rst file for detailsChanges0.6.0Deprecation: publish package that links to the newer bump2version for seamless
upgrades (see:https://www.python.org/dev/peps/pep-0423/#id106)v0.5.3Fix bug where--new-versionvalue 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)v0.5.1Document file specific optionssearch =andreplace =(introduced in 0.5.0)Fix parsing individual labels fromserialize =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 insearch =also load configuration fromsetup.cfg(thanks @t-8ch#57).v0.5.0This is a major one, containing two larger features, that require some changes
in the configuration format. This release is fully backwards compatible tov0.4.1, however deprecates two uses that will be removed in a future version.New feature: Part specific configurationNew feature: File specific configurationNew feature: parse option can now span multiple line (allows to comment complex
regular expressions. Seere.VERBOSE in the Python documentationfor details,this
testcaseas 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  instead, or invokebumpversionmultiple times)Deprecate ‘files =’ configuration (use file specific configuration  instead)v0.4.1Add –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 wrongv0.4.0Add –verbose option (#21#30)Allow option –serialize multiple timesv0.3.8Fix: –parse/–serialize didn’t work from cfg (#34)v0.3.7Don’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)v0.3.6Fix –tag default (thanks @keimlink)v0.3.5add {now} and {utcnow} to contextuse 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
confusing)print own version number in usageallow bumping parts that contain non-numericsvarious fixes regarding file encodingv0.3.4bugfix: tag_name and message in .bumpversion.cfg didn’t have an effect (#9)v0.3.3add –tag-name optionnow works on Python 3.2, 3.3 and PyPyv0.3.2bugfix: Read only tags fromgit describethat look like versionsv0.3.1bugfix:--helpin git workdir raising AssertionErrorbugfix: fail earlier if one of files does not existbugfix:commit = True/tag = Truein .bumpversion.cfg had no effectv0.3.0BREAKING CHANGEThe--bumpargument was removed, this is now the first
positional argument.
If you usedbumpversion--bumpmajorbefore, you can usebumpversion majornow.
If you usedbumpversionwithout arguments before, you now
need to specify the part (previous default waspatch) as inbumpversion patch).v0.2.2add –no-commit, –no-tagv0.2.1If available, use git to learn about current versionv0.2.0Mercurial supportv0.1.1Only create a tag when it’s requested (thanks @gvangool)v0.1.0Initial public version