Skip to main content

CLI tool for deciding the next semantic version of the project, using conventional commits.

Project description

Bump your Semantic Version using Conventional Commits

A Python CLI tool for calculating how to bump a Semantic Version based on a commit message.

Installation and Usage

$> pip install conventional_semver

Configuration

Create a .toml file and modify the settings you want to be different from the PCCC defaults. An example config.toml file is present in this repository.

Usage

The most basic usage of this tool is to create a config file as described above and pass a conventional commit message as input to the script.

$> conventional_semver "fix: ensure /api/list-all returns properly"
$> 0.0.1

It is also possible to provide a SemVer as an argument and have the script calculate the next version:

$> conventional_semver --semver 1.0.8 "feat: add new cool feature"
$> 1.1.0

The tool also supports the SemVer options for pre-releases and build metadata, using --pre-release and --build-meta, which will append the provided strings in a SemVer compatible manner.

$> conventional_semver --semver 1.0.8 --pre-release alpha.1 --build-meta $(date -u +"%Y-%m-%dT%H:%M:%SZ") "feat: add new cool feature"
$> 1.1.0-alpha.1+2024-01-11T07:21:57Z

Note that the lib used for SemVer parsing is a bit more relaxed than the official documentation, w.r.t. pre-release and build metadata. Make sure the strings provided follow the SemVer specification!

Pipeline example

This tool is particularly useful if you work trunk based, as you can use it in combination with the information already present in your git repository to automatically tag your new commit. I have created a sample project where I show how to use the tool in a GitHub Workflow, both for validating PRs and for tagging new commits on main.

Dependencies

The tool relies on The Python Conventional Commit Parser for the validation of the commit message and on Python SemanticVersion for managing the Semantic Version. The former of these use the Enchant C Library used by PyEnchant.

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

conventional_semver-0.2.6.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

conventional_semver-0.2.6-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file conventional_semver-0.2.6.tar.gz.

File metadata

  • Download URL: conventional_semver-0.2.6.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.0 CPython/3.12.1 Linux/6.2.0-1018-azure

File hashes

Hashes for conventional_semver-0.2.6.tar.gz
Algorithm Hash digest
SHA256 a25b7dcc90ac5922e1026c87a4cce7a3771fed626369c25042b06497a7e8aa98
MD5 9089b9d3318c65008562c259df21aa59
BLAKE2b-256 4455fecfe2346f5341f3c03e1ea3cd34e86771d0bb9e3bbe8bc35ad11a60230f

See more details on using hashes here.

File details

Details for the file conventional_semver-0.2.6-py3-none-any.whl.

File metadata

File hashes

Hashes for conventional_semver-0.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 15f7185dcbde8d531e83d3875f2d2fdaf62932b20adee92b90f3d3a316004023
MD5 047fd68cb332fa27759a2038253558fe
BLAKE2b-256 948cc351f40cbb3e3f4920b648af1a0cda391396e6e38adf302c390801386eae

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