Skip to main content

GIT-CONVENTIONAL-VERSION

ci-badge

Find version automatically based on git tags and commit messages.

The tool is very specific in its function, so it is very flexible.

You can use it as a part of many different integrations and it will not break your process.

Install

python3 -m pip install git-conventional-version

Usage

Get new bumped final version:

gcv

Get new bumped release candidate version:

gcv --type=rc

Get current (old) version, 0.0.0 if none exists:

gcv --old

Example of CI automation script:

old=$(gcv --old)
new=$(gcv)
# check if version bump would happen
if [ ! $new == $old ]; then
    # if yes, update setup.cfg
    sed -i "s/^version.*/version = $new/g" setup.cfg
    # and commit release
    git add setup.cfg
    git commit -m "$new"
    git tag "$new"
    git push --tags
    git push
fi

Version formats

Tags are equivalent to versions, no suffix or prefix is added or interpreted. Formats follow https://www.python.org/dev/peps/pep-0440/.

  • Final version

Standard tag is in the format \d+\.\d+\.d+ ie. 1.0.0. It can be divided into major . minor . patch versions.

It is automatically bumped based on commits messages and old version of the same type (look at Git commit message convention below).

  • Pre-release versions

Pre-release versions bumps are calculated based on last final version, its expected bump and old version of the same pre-release type.

    • Release candidate version

Format \d+\.\d+\.d+rc\d+ ie. 1.0.0rc1.

    • Developmental version

Format \d+\.\d+\.d+dev\d+ ie. 1.0.0dev1.

    • Alpha version

Format \d+\.\d+\.d+a\d+ ie. 1.0.0a1.

    • Beta version

Format \d+\.\d+\.d+b\d+ ie. 1.0.0b1.

  • Local version

Also, local version can be created from commit sha and old version: \d+\.\d+\.d\+.+ ie. 0.0.0+79ad.

Git commit message convention

Convention is based on https://www.conventionalcommits.org/en/v1.0.0/ (it's good!). At the moment, only the following rules apply (I usually use only these but more can be added easily):

  • Start commit with 'fix:' or 'fix(.*):' to bump patch version.
  • Start commit with 'feat:' or 'feat(.*):' to bump minor version.
  • Include in the commit line with 'breaking change:' to bump major version.

Automatic changelog

On branch where your version tags are present, you can generate changelog:

gcv-log

Full changelog is generated and printed to stdout. You can redirect it to a file. Assumes that you are about to release next version if not on commit with final version.

Notices

Automatically handling many types of version tags in git is more complicated than it initially seems like.

Metadata

Release files for git-conventional-version 1.0.2

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

Source distribution (sdist)

Source distribution for git-conventional-version 1.0.2
File Size Uploaded Provenance Actions
git-conventional-version-1.0.2.tar.gz 6.6 kB Without provenance Details for git-conventional-version-1.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for git-conventional-version 1.0.2
File Interpreter ABI Platform Actions
git_conventional_version-1.0.2-py3-none-any.whl Python 3 none any Details for git_conventional_version-1.0.2-py3-none-any.whl

Total release size: 16.1 kB

Release files / git-conventional-version-1.0.2.tar.gz

Download URL git-conventional-version-1.0.2.tar.gz
Size 6.6 kB
Tags Source
SHA-256 checksum
How to use checksums
05e61e32ddb867f9b751e6e6fed2b3038c87b0c9313adb7a6d7bc7288754a416
BLAKE2b-256 checksum
How to use checksums
e93ae8386256d529b4c5c64d6533b4460c8739b8a1d9945a628d80deeb11bc04
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.13

Release files / git_conventional_version-1.0.2-py3-none-any.whl

Download URL git_conventional_version-1.0.2-py3-none-any.whl
Size 9.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7d268c4fe475ae1cf538756967cfa6490465b5aac685b79c22366bdf7dd5f6b7
BLAKE2b-256 checksum
How to use checksums
e1b103b730a05729392e8ad8a1c50f1606ae9c942cdc91cc3f8a90ffae168cf0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.13

Security for git-conventional-version 1.0.2

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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