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.4.tar.gz
(11.2 kB
view hashes)
Built Distribution
Close
Hashes for semver_tool-0.1.4-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 006c3cec9fbb637046a73a70b8c0839ac95f97461146a9d0b0f09f466cbc36ef |
|
MD5 | 2fe0d4ee67d0246c5dc3069b9ff022da |
|
BLAKE2b-256 | 66273328fb34788f4dae056ba981f149bf6cdb2fede13b7b005240cc0d8816a2 |