Skip to main content

Version bump your Python project

Project description

Bump My Version

image image image GitHub Actions

NOTE

This is a maintained refactor of the bump2version fork of the excellent bumpversion project. The main goals of this refactor were:

  • Add support for pyproject.toml configuration files.
  • Convert to click for and rich for the CLI interface
  • Add better configuration validation using Pydantic
  • Make the code and tests easier to read and maintain

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 source code manager, 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.8+ and PyPy3. Python 3.7 should work but isn't actively tested.

Future Direction

  • Make it easier to get the current version
  • Switch having both the version part and files to change as arguments on the command line.
  • Make the version part argument truly optional when --new-version is specified
  • Allow for multiple tags, including one that moves for having a v2 that always points to the latest version of version 2.
  • https://github.com/c4urself/bump2version/issues/253 Have an always increment configuration
  • Better UI with Rich

Potential bugs to verify

Documentation opportunities

Installation

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

pip install --upgrade bump-my-version

Changelog

Please find the changelog here: CHANGELOG.md

Usage

NOTE:

Throughout this document, you can use bumpversion or bump-my-version interchangeably.

There are two modes of operation: On the command line for single-file operation and using a configuration file for more complex multi-file operations.

bump-my-version [options] part [file]

part

required

The part of the version to increase, e.g. minor.

Valid values include the named groups defined in the parse configuration.

Example bumping 0.5.1 to 0.6.0:

bump-my-version --current-version 0.5.1 minor

file

[optional]
default: none

Additional files to modify.

These files are added to the list of files specified in your configuration file. If you want to rewrite only files specified on the command line, also use --no-configured-files.

Example bumping 1.1.9 to 2.0.0:

bump-my-version --current-version 1.1.9 major setup.py

Configuration file

bump-my-version looks in four places for the configuration file to parse (in order of precedence):

  1. --config-file <FILE> (command line argument)
  2. BUMPVERSION_CONFIG_FILE=file (environment variable)
  3. .bumpversion.cfg (legacy)
  4. .bumpversion.toml
  5. setup.cfg (legacy)
  6. pyproject.toml

.toml files are recommended due to their type handling. We will likely drop support for ini-style formats in the future due to issues with formatting and parsing. You should add your configuration file to your source code management system.

By using a configuration file, you no longer need to specify those options on the command line. The configuration file also allows greater flexibility in specifying how files are modified.

Command-line Options

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

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

--no-configured-files Will not update/check files specified in the configuration file.

Similar to dry-run, but will also avoid checking the files. Also useful when you want to update just one file with e.g., bump-my-version --no-configured-files major my-file.txt

--verbose, -v Print useful information to stderr. If specified more than once, it will output more information.

--list List machine-readable information to stdout for consumption by other programs.

Example output:

current_version=0.0.18
new_version=0.0.19

-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 need to know the new version before applying the change.

The standard way to get it in a bash script is

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

where part is the part of the version number you are updating. You need to specify --dry-run to avoid bumpversion acting.

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

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

Development & Contributing

Thank you, contributors! You can find a full list here: https://github.com/callowayproject/bump-my-version/graphs/contributors

See also our CONTRIBUTING.md

Development of this happens on GitHub, patches including tests, and 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.

License

bump-my-version is licensed under the MIT License - see the LICENSE file for details

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

bump-my-version-0.2.0.tar.gz (60.7 kB view details)

Uploaded Source

Built Distribution

bump_my_version-0.2.0-py3-none-any.whl (27.1 kB view details)

Uploaded Python 3

File details

Details for the file bump-my-version-0.2.0.tar.gz.

File metadata

  • Download URL: bump-my-version-0.2.0.tar.gz
  • Upload date:
  • Size: 60.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.5

File hashes

Hashes for bump-my-version-0.2.0.tar.gz
Algorithm Hash digest
SHA256 0bc8b5d00412c63942d003c8b0d2dd46fa9787e9b4bf214fe0e987857ad9bead
MD5 84d7ecdfae34197fa5821b0ab6dc5036
BLAKE2b-256 b3ca1e0a366a26c6f38b024eeccfa4005e0e9068c43b26f5c48ec916771d9430

See more details on using hashes here.

File details

Details for the file bump_my_version-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for bump_my_version-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ea8684c28a60481aa905e5dec0fa800b5f13a8e088aad84ea00d42ca87a45405
MD5 3ec0aa6f83d44396c2b1c02f0ce66c6c
BLAKE2b-256 a2556bf33d0b92b1e931d2bf2c5bd32ee06bfdee4bf88d7985d86b30e9a7dbaa

See more details on using hashes here.

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