Automatic semantic versioning for python projects
pip install python-semantic-release
The general idea is to have some sort of tag in commit messages that indicates certain types of changes. If a commit message lack a tag it is ignored. Running release can be run locally or from a CI service.
Usage: semantic-release [OPTIONS] COMMAND
Options:
--major Force major version.
--minor Force minor version.
--patch Force patch version.
--noop No-operations mode, finds the new version number without changing it.
--help Show this message and exit.
version
- Create a new release. Will change the version, commit it and tag it.publish
- Runs version before pushing to git and uploading to pypi.
Add the following to your setup.py and you will be able to run python setup.py <command>
as you woul semantic-release <command>
.
try:
from semantic_release import setup_hook
setup_hook(sys.argv)
except ImportError:
pass
All configuration described here belongs in setup.cfg
in a section: semantic-release
.
version_variable
- The filename and variable name of where the version number is stored, e.g.
semantic_release/__init__.py:__version__
.
There are a set of tags used to evaluate the changes from commit messages. They can be configured to meet what you want them to be. The different tags are listed below with their defaults.
- Major change:
major_tag = :boom:
💥 - Minor change:
minor_tag = :sparkles:
✨ - Patch change:
patch_tag = :bug:
🐛