Skip to main content

semantic version helper tool

Project description


Print SemVer version for a git project. Git tags must match v?M.N.P pattern.


usage: semver_tool [-h] [--debug] [--version] [--rc str] [--short N] [--full]
                   [-n] [dir]

positional arguments:
  dir             git repo dir; default "."

optional arguments:
  -h, --help      show this help message and exit
  --debug         debug mode
  --version       show program's version number and exit
  --rc str        release candidate prefix; default "rc"
  --short N       print first N components of M.N.P version
  --full          full version with hash
  -n, --next-tag  print next tag


$ semver-tool
$ semver-tool --rc dev
$ semver-tool --short 2

Use Cases

Build docker images

I use this tool to build docker images using SemVer schema. The flow is this:

  • build image:latest with Commit label
  • push it as image:M.N.P
  • push it as image:M.N
  • push it as image:M

My build script has this code

docker build --label Commit=$(semver_tool --full) -t image:latest .
docker tag image:latest image $(semver_tool --short 3)
docker tag image:latest image $(semver_tool --short 2)
docker tag image:latest image $(semver_tool --short 1)

which results in these images

image   latest
image   1.2.3
image   1.2
image   1

Each image has Commit label with semver description, eg, 1.2'3-rc4+g22eeff

Automatically set version in


from setuptools import setup
from semver_tool import get_semver


Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for semver-tool, version 0.1.4
Filename, size File type Python version Upload date Hashes
Filename, size semver_tool-0.1.4-py2-none-any.whl (11.5 kB) File type Wheel Python version py2 Upload date Hashes View
Filename, size semver-tool-0.1.4.tar.gz (11.2 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page