Skip to main content

Manage properly semver in your repository

Project description

Semversioner

The easiest way to manage semantic versioning in your project and generate CHANGELOG.md files automatically.

Semversioner provides the tooling to automate the semver release process for libraries, docker images, microservices, and more.

This project was inspired by the way AWS manages their versioning for AWS-cli.

PyPI Version

Semantic Versioning

The semantic versioning spec involves several possible variations, but to simplify, in Semversioner we are using the three-part version number:

<major>.<minor>.<patch>

Constructed with the following guidelines:

  • Breaking backward compatibility or major features bumps the major (and resets the minor and patch).
  • New additions without breaking backward compatibility bumps the minor (and resets the patch).
  • Bug fixes and misc changes bumps the patch.

An example would be 1.0.0.

How it works

At any given time, the .semversioner/ directory looks like:

.semversioner
├── next-release
│   ├── minor-20181227010225.json
│   └── major-20181228010225.json
├── 1.1.0.json
├── 1.1.1.json
└── 1.1.2.json

The release process takes everything in the next-release directory and aggregates them all together in a single JSON file for that release (e.g., 1.12.0.json). This JSON file is a list of all the individual JSON files from next-release.

Install

pip install semversioner

Usage

You can use the --help option on any command to see the available options:

semversioner --help

Adding changesets

In your local environment, you can use the CLI to create the different changeset files that will be committed with your code. This ensures that every pull request or commit contains its own self-contained change description and version bump intention.

semversioner add-change --type patch --description "Fix security vulnerability with authentication."

Allowed --type values are: major, minor, patch.

You can also add custom attributes to the changeset file that will be available later in your release template. Use the --attributes flag in key=value format (you can pass it multiple times):

semversioner add-change --type patch \
    --description "My custom changelog message with attributes." \
    --attributes pr_id=322 \
    --attributes issue_id=123

Checking working directory status

You can check the status of your working directory to see the current version, the computed next version, and any unreleased changes:

semversioner status

Example output:

Version: 1.0.0
Next version: 1.1.0
Unreleased changes:
	minor:	Added new authentication feature
(use "semversioner release" to release the next version)

Enforcing changesets in CI/CD (Check)

In your CI/CD pipeline, it's often useful to enforce that a PR includes a changeset before merging. You can use the check command to verify that there are unreleased changes in the .semversioner/next-release/ directory.

semversioner check

If no changes are found, the command exits with a non-zero status code (-1) and prints an error message.

Releasing a new version

When you are ready to create a release (usually in your CI/CD tool on the main branch), you run the release command. This automatically computes the new version number based on the unreleased changes, generates a new version JSON file, and clears the next-release directory.

semversioner release

Generating the Changelog

As part of your release workflow, you can generate the changelog file with all aggregated changes.

semversioner changelog > CHANGELOG.md

Customizing the changelog template

You can customize the changelog by creating a template and passing it as a parameter to the command. For example:

semversioner changelog --template .semversioner/config/template.j2

The template uses Jinja2, a templating language for Python. A basic example:

# Changelog
{% for release in releases %}

## {{ release.version }}

{% for change in release.changes %}
- {{ change.type }}: {{ change.description }}
{% endfor %}
{% endfor %}

If you included custom attributes (e.g., pr_id, issue_id) using the add-change command, you can reference them in your template. You also have access to current_version:

# Changelog
Note: version releases in the 0.x.y range may introduce breaking changes.

# Current version: {{ current_version }}

{% for release in releases %}

## {{ release.version }}{{ ' (' + release.created_at.strftime('%Y-%m-%d') + ')' if release.created_at }}

{% for change in release.changes %}
- {{ change.type }}: {{ change.description }}{{ ' (#' + change.attributes.pr_id + ')' if change.attributes }}{{ ' (J' + change.attributes.issue_id + ')' if change.attributes }}
{% endfor %}
{% endfor %}

Filtering the changelog

You can filter the changelog by only showing changes for a specific version:

semversioner changelog --version "1.0.0"

Alternatively, you can filter changes for the last released version:

semversioner changelog --version $(semversioner current-version)

Getting the current version

You can retrieve the currently released version of your project:

semversioner current-version

Getting the next version

As part of the CI/CD workflow, sometimes you want to release dev, rc, or other pre-release packages. For this purpose, the next-version command can be issued to compute the upcoming version based on the current changeset. This will not modify any files on disk.

semversioner next-version

Global Options

  • --path: Specify a custom base path for your project. Defaults to the current directory. Example: semversioner --path /path/to/project release

License

Copyright (c) 2026 Raul Gomis. MIT licensed, see LICENSE file.


Made with ♥ by Raul Gomis.

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

semversioner-3.0.0.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

semversioner-3.0.0-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

Details for the file semversioner-3.0.0.tar.gz.

File metadata

  • Download URL: semversioner-3.0.0.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for semversioner-3.0.0.tar.gz
Algorithm Hash digest
SHA256 6e27a13c100de899977b6289a8d1cdd0c961a406690057599aea43b4ecd79097
MD5 24f476499143351743fd37f3ed523715
BLAKE2b-256 76ea6b0d7e5ae1006b787e78ff800c1cca4a672b80568776163651e56a572cbf

See more details on using hashes here.

Provenance

The following attestation bundles were made for semversioner-3.0.0.tar.gz:

Publisher: release.yml on raulgomis/semversioner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file semversioner-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: semversioner-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 13.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for semversioner-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1d98112b6b08f1818b6137c7068885f0269b06bed4705fc35f50a07c0ba1031a
MD5 348f36f3b3df6b8510ad81da0cab61cb
BLAKE2b-256 bdb355777e4e8e562c9c023be6d9700b93c860e9d52cc9da82f739b7f53af317

See more details on using hashes here.

Provenance

The following attestation bundles were made for semversioner-3.0.0-py3-none-any.whl:

Publisher: release.yml on raulgomis/semversioner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page