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
Python library to decorate and beautify strings

outputformat Python library to decorate and beautify your standard output 💖 Ins

Felipe Delestro Matos 259 Dec 13, 2022
Generates a random prnt.sc link and display image.

Generates a random prnt.sc link and display image.

Emirhan 3 Oct 08, 2021
More routines for operating on iterables, beyond itertools

More Itertools Python's itertools library is a gem - you can compose elegant solutions for a variety of problems with the functions it provides. In mo

2.9k Jan 06, 2023
Let's renew the puzzle collection. We'll produce a collection of new puzzles out of the lichess game database.

Let's renew the puzzle collection. We'll produce a collection of new puzzles out of the lichess game database.

Thibault Duplessis 96 Jan 03, 2023
Run async workflows using pytest-fixtures-style dependency injection

Run async workflows using pytest-fixtures-style dependency injection

Simon Willison 26 Jun 26, 2022
Extends the pyranges module with operations on joined genomic intervals

tiedpyranges Extends the pyranges module with operations on joined genomic intervals (e.g. exons of same transcript) Install with: pip install tiedpyr

Marco Mariotti 4 Aug 05, 2022
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 08, 2022
A small utility that sorts your files.

FileSorter A small utility that sorts your files. TODO: Scan directory to find files(thanks @corruptmemry for this!) Split extensions to determine fil

2 Jun 16, 2022
A fancy and practical functional tools

Funcy A collection of fancy functional tools focused on practicality. Inspired by clojure, underscore and my own abstractions. Keep reading to get an

Alexander Schepanovski 2.9k Jan 07, 2023
osqueryIR is an artifact collection tool for Linux systems.

osqueryIR osqueryIR is an artifact collection tool for Linux systems. It provides the following capabilities: Execute osquery SQL queries Collect file

AbdulRhman Alfaifi 7 Nov 02, 2022
A simple API that will return a key-value pair of randomly generated UUID

A simple API that will return a key-value pair of randomly generated UUID. Key will be a timestamp and value will be UUID. While the server is running, whenever the API is called, it should return al

Pius Lucky 2 Jan 18, 2022
Script to decrypt / import chromium (edge/chrome) cookies

Cloonie Script to decrypt / import chromium (edge/chrome) cookies. Requirements Install the python dependencies via pip: pip install -r requirements.t

Lorenzo Bernardi 5 Sep 13, 2022
Protect your eyes from eye strain using this simple and beautiful, yet extensible break reminder

Protect your eyes from eye strain using this simple and beautiful, yet extensible break reminder

Gobinath 1.2k Jan 01, 2023
MITRE ATT&CK Lookup Tool

MITRE ATT&CK Lookup Tool attack-lookup is a tool that lets you easily check what Tactic, Technique, or Sub-technique ID maps to what name, and vice ve

Curated Intel 33 Nov 22, 2022
Cardano Stakepools: Check for scheduled blocks in current epoch.

ReLeaderLogs For Cardano Stakepool Operators: Lightweight Scheduled Blocks Checker for Current Epoch. No cardano-node Required, data is taken from blo

SNAKE (Cardano Stakepool) 2 Oct 19, 2021
A sys-botbase client for remote control automation of Nintendo Switch consoles. Based on SysBot.NET, written in python.

SysBot.py A sys-botbase client for remote control automation of Nintendo Switch consoles. Based on SysBot.NET, written in python. Setup: Download the

7 Dec 16, 2022
A time table app to notify the user about their class timings

kivyTimeTable A time table app to notify the user about their class timings Features This project incorporates some features i wanted to see in a time

2 Dec 15, 2021
Format Norminette Output!

Format Norminette Output!

7 Apr 19, 2022
Etherium unit conversation and arithmetic library

etherunit Etherium unit conversation and arithmetic library Install pip install -u etherunit Usage from etherunit import Ether, Gwei, Wei, E Creat

Yasin Özel 1 Nov 10, 2021
A fixture that allows runtime xfail

pytest-runtime-xfail pytest plugin, providing a runtime_xfail fixture, which is callable as runtime_xfail(), to allow runtime decisions to mark a test

Brian Okken 4 Apr 06, 2022