Skip to main content

Bump software releases

Project description

https://img.shields.io/travis/TankerHQ/tbump.svg?branch=master https://img.shields.io/pypi/v/tbump.svg https://img.shields.io/github/license/TankerHQ/tbump.svg

Installation

  • Make sure you are using Python 3.4 or later

  • Intall tbump with pip as usual.

Screenshot

Here’s what a typical usage of tbump looks like:

https://raw.githubusercontent.com/TankerHQ/tbump/master/scrot.png

Usage

Frist, run tbump init. This will create a tbump.toml file looking like this:

[version]
current = "1.2.41"
regex = '''
  (?P<major>\d+)
  \.
  (?P<minor>\d+)
  \.
  (?P<patch>\d+)
'''

[git]
message_template = "Bump to {new_version}"
tag_template = "v{new_version}"

[[file]]
src = "setup.py"

Then run:

$ tbump 1.2.42

tbump will:

  • Replace the string 1.2.41 by 1.2.42 in every file listed in the configuration

  • Make a commit based on the message_template.

  • Make an annotated tag based on the tag_template

  • Push the current branch and the tag.

Note that by default, tbump will display all the changes and stop to ask if they are correct before performing any action, allowing you to abort and re-try the bump if something is not right.

You can use --non-interactive to disable this behavior.

Advanced configuration

Restricting the lines that are replaced

Sometimes you want to make sure only the line matching a given pattern is replaced. For instance, with the folliwing package.json:

/* in package.json */
{
   "name": "foo",
   "version": "0.42",
   "dependencies": {
     "some-dep": "0.42",
     "other-dep": "1.3",
   }
}

you’ll want to make sure that when you bump from 0.42 to 0.43 that the line containing some-dep does not change.

In this case, you can set a search option in the file section:

# In tbump.toml

[[file]]
src = "package.json"
search = '"version": "{current_version}"'

Using a custom version template

If you are using a version schema like 1.2.3-alpha-4, you may want to expose a variable that only contains the “public” part of the version string. (1.2.3 in this case).

To do so, add a version_template option in te file section. The names used in the format string should match the group names in the regular expression.

/* in version.js */

export FULL_VERSION = '1.2.3-alpha-4';
export PUBLIC_VERSION = '1.2.3';
[[file]]
src = "version.js"
version_template = "{major}.{minor}.{patch}"
search = "export PUBLIC_VERSION = '{current_version}'"

[[file]]
src = "version.js"
search = "export FULL_VERSION = '{current_version}'"

Running commands before commit

You can specify a list of hooks to be run after the file have changed, but before the commit is made and pushed.

This is useful if some of the files under version control are generated through an external program.

Here’s an example:

[[before_commit]]
name = "Check Changelog"
cmd = "grep -q {new_version} Changelog.rst"

The name is mandatory. The command will be executed via the shell, after the {new_version} placeholder is replaced with the new version.

Any hook that fails will interrupt the bump. You may want to run git reset --hard before trying again to undo the changes made in the files.

Running commands after push

You can specify a list of hooks to be run right after the tag has been pushed, using an [[after_push]] section.

This is useful if you need the command to run on a clean repository, without un-committed changes, for instance to publish rust packages:

[[after_push]]
name = "Publish to crates.io"
cmd = "cargo publish"

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

tbump-5.0.3.tar.gz (19.7 kB view details)

Uploaded Source

Built Distribution

tbump-5.0.3-py3-none-any.whl (22.6 kB view details)

Uploaded Python 3

File details

Details for the file tbump-5.0.3.tar.gz.

File metadata

  • Download URL: tbump-5.0.3.tar.gz
  • Upload date:
  • Size: 19.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.8rc1

File hashes

Hashes for tbump-5.0.3.tar.gz
Algorithm Hash digest
SHA256 15a2ceeafe376ec80a8ec6ef183c83057c29a64540953b197fc733b76ec13429
MD5 ac01e3db84272cb47d62c4d0c9645c14
BLAKE2b-256 1251b3c52f76da4d2ec502d9ef7bcf3f0598c34e9636712e0f89f58069189554

See more details on using hashes here.

File details

Details for the file tbump-5.0.3-py3-none-any.whl.

File metadata

  • Download URL: tbump-5.0.3-py3-none-any.whl
  • Upload date:
  • Size: 22.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.8rc1

File hashes

Hashes for tbump-5.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1d16e47835941f04bede756966587f7fff7a3cec05eb4f55a131a63dc50dd458
MD5 85a8f2c583226eb7c4f4d39854fcee4b
BLAKE2b-256 a25b3ee67cccd3242fdc7837572d9365a87c4333a6e5dc9abe821b5688355bcb

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