Find version automatically based on git tags and commit messages.

Overview

GIT-CONVENTIONAL-VERSION

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.

  • 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.

Notices

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

You might also like...
Python code to generate and store certificates automatically , using names from a csv file

WOC-certificate-generator Python code to generate and store certificates automatically , using names from a csv file IMPORTANT In order to make the co

Python script to launch burp scans automatically

SimpleAutoBurp Python script that takes a config.json file as config and uses Burp Suite Pro to scan a list of websites.

Automatically Generate Rulesets for IIS for Intelligent HTTP/S C2 Redirection

Automatically Generate Rulesets for IIS for Intelligent HTTP/S C2 Redirection This project converts a Cobalt Strike profile to a functional web.config

Python utilities for writing cross-version compatible libraries

Python utilities for writing cross-version compatible libraries

Create C bindings for python automatically with the help of libclang

Python C Import Dynamic library + header + ctypes = Module like object! Create C bindings for python automatically with the help of libclang. Examples

An awesome tool to save articles from RSS feed to Pocket automatically.
An awesome tool to save articles from RSS feed to Pocket automatically.

RSS2Pocket An awesome tool to save articles from RSS feed to Pocket automatically. About the Project I used to use IFTTT to save articles from RSS fee

Nmap script to guess* a GitLab version.

gitlab-version-nse Nmap script to guess* a GitLab version. Usage https://github.com/righel/gitlab-version-nse cd gitlab-version-nse nmap target --s

Early version for manipulate Geo localization data trough API REST.

Backend para obtener los datos (beta) Descripción El servidor está diseñado para recibir y almacenar datos enviados en forma de JSON por una aplicació

This program organizes automatically files in folders named as file's extension

Auto Sorting System by Sergiy Grimoldi - V.0.0.2 This program organizes automatically files in folders named as file's extension How to use the code T

Comments
  • Fix tag comparison (numerical order)

    Fix tag comparison (numerical order)

    Tag comparison was done using alphabetical ordering instead of numerical ordering. This won't work for releases that uses numbers over 9. Casting each version component to an int will force numerical ordering.

    The bug can easily be reproduced by creating a dummy repository and adding tags "0.9.0" and "0.10.0". "0.9.0"will be seen as the latest by error.

    opened by sgrimard 0
Owner
DevOps Enthusiast
null
Spacegit is a .git exposed finder

Spacegit Spacegit is a basic .git exposed finder Usage: You need python3 installed to run spacegit use: python3 spacegit.py (url) Disclaimer: **This i

null 2 Nov 30, 2021
The git for the Python Story Utility Package library.

SUP The git for the Python Story Utility Package library. Installation: Install SUP by simply running pip install psup in your terminal. Check out our

Enoki 6 Nov 27, 2022
A python package for your Kali Linux distro that find the fastest mirror and configure your apt to use that mirror

Kali Mirror Finder Using Single Python File A python package for your Kali Linux distro that find the fastest mirror and configure your apt to use tha

MrSingh 6 Dec 12, 2022
Find unused resource keys in properties files in a Salesforce Commerce Cloud project and get rid of them.

Find Unused Resource Keys Find unused resource keys in properties files in a Salesforce Commerce Cloud project and get rid of them. It looks through a

Noël 5 Jan 8, 2022
A python program to find binary, octal and hexadecimal of a decimal.

decimal-converter This little python program can convert a decimal in to, Binary Octal Hexadecimal Needed Python 3 or later or a online python compile

Chandula Janith 0 Nov 27, 2021
Here, I find the Fibonacci Series using python

Fibonacci-Series-using-python Here, I find the Fibonacci Series using python Requirements No Special Requirements Contribution I have strong belief on

Sachin Vinayak Dabhade 4 Sep 24, 2021
This tool analyzes the json files generated by stream-lnd-htlcs to find hidden channel demand.

analyze_lnd_htlc Introduction Rebalancing channels is an important part of running a Lightning Network node. While it would be great if all channels c

Marimox 4 Dec 8, 2022
Rabbito is a mini tool to find serialized objects in input values

Rabbito-ObjectFinder Rabbito is a mini tool to find serialized objects in input values What does Rabbito do Rabbito has the main object finding Serial

null 7 Dec 13, 2021
Find dependent python scripts of a python script in a project directory.

Find dependent python scripts of a python script in a project directory.

null 2 Dec 5, 2021
isort is a Python utility / library to sort imports alphabetically, and automatically separated into sections and by type.

isort is a Python utility / library to sort imports alphabetically, and automatically separated into sections and by type. It provides a command line utility, Python library and plugins for various editors to quickly sort all your imports.

Python Code Quality Authority 5.5k Jan 8, 2023