semantic version helper tool
Project description
semver-tool
Print SemVer version for a git project. Git tags must match v?M.N.P
pattern.
Usage
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
Examples:
$ semver-tool
4.1.2-rc2+gb10c717
$ semver-tool --rc dev
4.1.2-dev2+gb10c717
$ semver-tool --short 2
4.1
Use Cases
Build docker images
I use this tool to build docker images using SemVer schema. The flow is this:
- build
image:latest
withCommit
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 setup.py
Edit setup.py
from setuptools import setup
from semver_tool import get_semver
setup(
version=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.
Source Distribution
semver-tool-0.1.3.tar.gz
(11.2 kB
view hashes)
Built Distribution
Close
Hashes for semver_tool-0.1.3-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9729ad2b11d620f5a384a6f6897ac8a065c59108f39f4e32811de3e148dca14 |
|
MD5 | f5aec2956c8b49a54a22d00441c90e70 |
|
BLAKE2b-256 | b3f7b14404cd61a27628682186aabe68b3f6c974e6a31d74e626d918dfa21bbb |