semantic version helper tool
pip install semver-tool==3.0.4
Print SemVer version for a git project. Git tags must match v?M.N.P
pattern.
You can print specific version components using fotmat string.
Full format string is MNPRBD, where:
Examples:
$ semver-tool
4.1.2-rc.2+git.b10c717
$ semver-tool -f MNPR
4.1.2-rc.2
I use this tool to build docker images using SemVer schema. The flow is this:
image:latest
with Commit
labelimage:M.N.P-R
image:M.N.P
image:M.N
My build script has this code
current=$(semver_tool -f MNPR)
docker build --label Commit=$(semver_tool) -t image:$current
docker tag image:$current image $(semver_tool -f MNP)
docker tag image:$current image $(semver_tool -f MN)
which results in these images
image 1.2.3-rc.2
image 1.2.3
image 1.2
Each image has Commit
label with semver description, eg, 1.2.3-rc.2+git.22eeff