setup_scmversion
Builds a semantic version number based on information available on your scm (tag, branch, and number of commits).
See LICENSE for important licensing information.
Instalation
pip install jfaleiro.setup-scmversion
Or as a dev dependency in poetry:
poetry add jfaleiro.setup-scmversion --dev
poetry update
Currently only git is supported.
Use
A semantic version number is created from standard data available in your scm, i.e. tag, branch name, and number of commits from a tag or master. It supports a simple workflow:
- Versions follow a simplified semantic versioning scheme.
- Non-production releases are produced from release branches named
release/<version>. - Non-production releases are produced from feature-releases named
feature/<version>. - Production releases and releases candidates are generated from a
taginmasterafter a release branch is merged to master. The version will match the tag.
Simplest Use
Should apply to most projects. Tag the current version before build or deploy using a command line:
$ scmversion version
0.1.1
V=`scmversion version`
echo
0.1.1
or the type of version:
$ scmversion version-type
RELEASE_BRANCH
The type of version can be one of RELEASE, RELEASE_BRANCH, FEATURE_BRANCH, or OTHER.
or even replacing version variables in files. Take for example a this file pyproject.template.toml:
...
[tool.poetry]
name = "jfaleiro.setup-scmversion"
version = "${POETRY_VERSION}"
description = 'Semantic version number based on scm tags and branches'
...
scmversion tag-file --version POETRY_VERSION --pre-commit pyproject.template.toml pyproject.toml
will have a resulting file:
...
[tool.poetry]
name = "jfaleiro.setup-scmversion"
version = "0.1.1"
description = 'Semantic version number based on scm tags and branches'
...
And many more. Refer to the command line help for details.
$ scmversion --help
usage: scmversion [-h] {version,version-type,parsers,tag-version,generate-setup,tag-file,show,check} ...
Version parser from scm
positional arguments:
{version,version-type,parsers,tag-version,generate-setup,tag-file,show,check}
version displays the version
version-type displays the version type (one of ['RELEASE', 'RELEASE_BRANCH', 'FEATURE_BRANCH', 'OTHER'])
parsers lists all parsers available
tag-version tags a python package with a version file
generate-setup generates a setuptools compatible setup.py file
tag-file tags a file with version and type
show show what is currently tagged
check asserts versions on version file and scm are the same
optional arguments:
Pre-commit
For use as a pre-commit hook add this to your .pre-commit-config.yaml for example:
- repo: https://gitlab.com/jfaleiro.open/setup_scmversion
rev: 0.1.1
hooks:
- id: tag-version
- id: tag-pyproject
- id: tag-readme
Versioning Schema
- Release branches
release/<version>withnnndifferences from master will produce aRELEASE_BRANCHwith a version<version>-dev<nnn> - Feature branches
feature/<version>withnnndifferences from master will produce aFEATURE_BRANCHwith a version<version>-feature<nnn> - A well-formed tagged version
<tag>on master will produce aRELEASEversion<tag>. - Everything else will produce
0.0.0+master...for master or0.0.0+other...for any other branch.
Metadata
Release files for jfaleiro.setup-scmversion 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| jfaleiro.setup_scmversion-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Release files / jfaleiro.setup_scmversion-0.1.1-py3-none-any.whl
| Download URL | jfaleiro.setup_scmversion-0.1.1-py3-none-any.whl |
|---|---|
| Size | 26.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5c1759edbbfe901d6bdf9c19e53e39795924a10f3ebbd1ba76ada1648a780d55
|
|
BLAKE2b-256 checksum How to use checksums |
39b5263090b4b137c105f6adf44b70e53fc0a30cb87769af1430a71bdb4611f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.8 CPython/3.8.11 Linux/5.10.47-linuxkit
|