tbump: Bump Software Releases

6.11.0 · active · verified Thu Apr 16

tbump is a command-line tool designed to simplify the process of bumping software versions. It automates updating version strings in specified files, creating Git commits and tags, and pushing changes to a remote repository. The current version is 6.11.0, and it has an active development cycle with frequent updates and bug fixes.

Common errors

Warnings

Install

Quickstart

To use tbump, you typically create a `tbump.toml` configuration file in your project's root directory, or embed the configuration in `pyproject.toml` under the `[tool.tbump]` section. This configuration specifies the current version, a regex to match it, Git commit/tag templates, and the files where the version string should be updated. After configuration, run `tbump <new_version>` from your project's root.

import os

# Create a dummy project structure for demonstration
os.makedirs('my_project', exist_ok=True)
with open('my_project/pyproject.toml', 'w') as f:
    f.write('current = "1.2.3"\n')
    f.write('[tool.poetry]\n')
    f.write('name = "my_project"\n')
    f.write('version = "1.2.3"\n')

with open('my_project/src/__init__.py', 'w') as f:
    f.write('__version__ = "1.2.3"\n')

# --- tbump configuration (tbump.toml in the project root) ---
config_content = '''
[version]
current = "1.2.3"
regex = """(?P<major>\d+)\\.(?P<minor>\d+)\\.(?P<patch>\d+)"""

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

[[file]]
src = "pyproject.toml"
search = 'version = "{current_version}"'

[[file]]
src = "src/__init__.py"
search = '__version__ = "{current_version}"'
'''

with open('my_project/tbump.toml', 'w') as f:
    f.write(config_content)

print("Project setup in 'my_project/' with tbump.toml")
print("To bump the version, navigate to 'my_project/' and run:")
print("  git init")
print("  git add .")
print("  git commit -m \"Initial commit\"")
print("  tbump 1.2.4") # This will perform the bump and Git operations

view raw JSON →