Skip to main content

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

# 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 version
  • bump_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

Metadata

Release files for py-semver-bumper 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-semver-bumper 0.1.1
File Size Uploaded
py_semver_bumper-0.1.1.tar.gz 6.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for py-semver-bumper 0.1.1
File Interpreter ABI Platform
py_semver_bumper-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 12.3 kB

Release files / py_semver_bumper-0.1.1.tar.gz

Download URL py_semver_bumper-0.1.1.tar.gz
Size 6.0 kB
Tags Source
SHA-256 checksum
How to use checksums
12da2760df0342a5a5a432bfc0622ddb4b45b49f1ab88e021d73f943670ba551
BLAKE2b-256 checksum
How to use checksums
3149adfad76cfd5c054f41b81c6caae896ff0af9d11bb1260bdbf81f19fb0900
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 29, 2025.

Transparency log

Release files / py_semver_bumper-0.1.1-py3-none-any.whl

Download URL py_semver_bumper-0.1.1-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
94e7774dde2497b57e1b80b25d018d4e0ee324cf28be71a18624c81be49939d3
BLAKE2b-256 checksum
How to use checksums
e4d235e6b362a04c82466116c9a839abc520b6834946202707c39596af050dae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 29, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page