A Python command-line tool for bumping semantic versions
Project description
py-semver-bumper
A Python command-line tool for bumping semantic versions with support for patch, minor, and major version increments.
Features
- Semantic Versioning Support: Handles standard semver format (
MAJOR.MINOR.PATCH[-PRERELEASE][+BUILD]) - Multiple Bump Types: Support for patch, minor and major bumps
- pyproject.toml Integration: Automatically reads and updates version from
pyproject.toml - Command Line Interface: Easy-to-use CLI with clear options
Installation
From PyPI (Recommended)
# Install using pip
pip install py-semver-bumper
# Or using uv
uv add py-semver-bumper
Usage
Command Line Interface
The tool can be used as a module or installed as a command-line tool.
Basic Usage
# Bump patch version (reads from pyproject.toml)
py-semver-bumper patch
# Bump minor version with specific version
py-semver-bumper minor -v 1.2.3
# Bump major version and update pyproject.toml
py-semver-bumper major --update
Options
-v, --version: Specify the version to bump (if not provided, reads from pyproject.toml)-u, --update: Update the pyproject.toml file with the new versionbump_type: The type of bump to perform (patch, minor, major, prerelease)
Examples
# Output new version without updating files
py-semver-bumper patch
# Output: 1.0.1
# Update pyproject.toml with new version
py-semver-bumper minor --update
# Output: 1.1.0
# Use specific version
py-semver-bumper major -v 2.1.0
# Output: 3.0.0
Programmatic Usage
from py_semver_bumper import SemverBumper
# Create bumper with version string
bumper = SemverBumper("1.2.3")
# Bump versions
new_patch = bumper.patch() # 1.2.4
new_minor = bumper.minor() # 1.3.0
new_major = bumper.major() # 2.0.0
# Convert to string
print(str(new_patch)) # "1.2.4"
Automating Releases with GitHub CLI
You can automate the release process using GitHub CLI. Here are some examples:
Simple Release Script
#!/bin/bash
BUMP_TYPE=${1:-patch} # Default to patch if no argument provided
# Bump version and update pyproject.toml
NEW_VERSION=$(py-semver-bumper $BUMP_TYPE --update)
# Commit the version bump
git add pyproject.toml
git commit -m "Bump version to $NEW_VERSION"
# Push to remote
git push origin main
# Create GitHub release
gh release create $NEW_VERSION --title "Release $NEW_VERSION" --generate-notes
One-liner for Quick Releases
# Bump patch version, commit, push, and create release
NEW_VERSION=$(py-semver-bumper patch --update) && \
git add pyproject.toml && \
git commit -m "Bump version to $NEW_VERSION" && \
git push origin main && \
gh release create $NEW_VERSION --title "Release $NEW_VERSION" --generate-notes
Just command
You can add this to your justfile to automate the release process.
release bump='patch':
#!/bin/sh
export NEW_VERSION=$(py-semver-bumper {{ bump }} --update)
git add pyproject.toml
git commit -m "Bump version to $NEW_VERSION"
git push origin main
gh release create $NEW_VERSION --title "Release $NEW_VERSION" --generate-notes
Development
This project uses Just for task management. Run just to see all available commands.
The project uses Ruff for linting and formatting and Ty for type checking:
- Lint:
just lint - Format:
just format - Type Check:
just typecheck
Tests are written using pytest:
- Run Unit Tests:
just pytest
Roadmap
- Implement prerelease version bumping
- Add support for build metadata
- Add validation for semver format
- Add support for other version file formats (setup.py, etc.)
- Add dry-run mode
- Add interactive mode for version selection
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file py_semver_bumper-0.1.1.tar.gz.
File metadata
- Download URL: py_semver_bumper-0.1.1.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12da2760df0342a5a5a432bfc0622ddb4b45b49f1ab88e021d73f943670ba551
|
|
| MD5 |
db0f1b1f1c65b635ca3d40038e16878a
|
|
| BLAKE2b-256 |
3149adfad76cfd5c054f41b81c6caae896ff0af9d11bb1260bdbf81f19fb0900
|
Provenance
The following attestation bundles were made for py_semver_bumper-0.1.1.tar.gz:
Publisher:
publish.yml on MatthewCane/py-semver-bumper
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_semver_bumper-0.1.1.tar.gz -
Subject digest:
12da2760df0342a5a5a432bfc0622ddb4b45b49f1ab88e021d73f943670ba551 - Sigstore transparency entry: 326552504
- Sigstore integration time:
-
Permalink:
MatthewCane/py-semver-bumper@dee8dc9bac3056875a6ba004a35fb9d095b2b070 -
Branch / Tag:
refs/tags/0.1.1 - Owner: https://github.com/MatthewCane
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@dee8dc9bac3056875a6ba004a35fb9d095b2b070 -
Trigger Event:
release
-
Statement type:
File details
Details for the file py_semver_bumper-0.1.1-py3-none-any.whl.
File metadata
- Download URL: py_semver_bumper-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
94e7774dde2497b57e1b80b25d018d4e0ee324cf28be71a18624c81be49939d3
|
|
| MD5 |
a31c6d6f7fd928c59de62423c299857f
|
|
| BLAKE2b-256 |
e4d235e6b362a04c82466116c9a839abc520b6834946202707c39596af050dae
|
Provenance
The following attestation bundles were made for py_semver_bumper-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on MatthewCane/py-semver-bumper
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_semver_bumper-0.1.1-py3-none-any.whl -
Subject digest:
94e7774dde2497b57e1b80b25d018d4e0ee324cf28be71a18624c81be49939d3 - Sigstore transparency entry: 326552516
- Sigstore integration time:
-
Permalink:
MatthewCane/py-semver-bumper@dee8dc9bac3056875a6ba004a35fb9d095b2b070 -
Branch / Tag:
refs/tags/0.1.1 - Owner: https://github.com/MatthewCane
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@dee8dc9bac3056875a6ba004a35fb9d095b2b070 -
Trigger Event:
release
-
Statement type: