Skip to main content

Automatic semantic versioning for python projects

Project description

Automatic semantic versioning for python projects. This is a python implementation of the semantic-release for js by Stephan Bönnemann. If you find this topic interesting you should check out his talk from JSConf Budapest.

Build status PyPI version

The general idea is to be able to detect what the next version of the project should be based on the commits. This tool will use that to automate the whole release, upload to PyPI and upload changelogs to Github. You can run the tool with a CI service or just run it locally.

Setup in your project

Install it

pip install python-semantic-release

Configure it

There are a three different ways to configure semantic-release.

  • [semantic_release] section in setup.cfg

  • [tool.semantic_release] section in pyproject.toml

  • Passing -D to the command like semantic-release <command> -D <option_name>=<option_value>

The important thing to configure for all projects is where the version variable is stored. This is used to get the current version and updating it. The config variable for that is version_variable. If your project main package is super_package and the version with name __version__ variable is in __init__.py then you can set it too version_variable = super_package/__init__.py:__version__.

For the basic setup this should be all you need to, for further reading on supported config variables check the Configuration page in the documentation

Run it

There is three different things you can do with this tool. Run the commands below with semantic-release <command>.

  • 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.

  • changelog - Generates the changelog for the next release.

Running commands from setup.py

Add the following to your setup.py and you will be able to run python setup.py <command> as you would semantic-release <command>.

try:
    from semantic_release import setup_hook
    setup_hook(sys.argv)
except ImportError:
    pass

Configuration

Configuration belongs in semantic_release section of the setup.cfg file in your project. Details about configuration options can be found in the configuration documentation.

Running it on CI

Getting a fully automated setup with automatic releases from CI can be helpful for some projects. It was the main motivation to create this tool. There is a dedicated documentation page for setting up with different CI tools: Automatic release with CI documentation

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python-semantic-release-4.11.0.tar.gz (20.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_semantic_release-4.11.0-py3-none-any.whl (30.0 kB view details)

Uploaded Python 3

File details

Details for the file python-semantic-release-4.11.0.tar.gz.

File metadata

  • Download URL: python-semantic-release-4.11.0.tar.gz
  • Upload date:
  • Size: 20.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.7

File hashes

Hashes for python-semantic-release-4.11.0.tar.gz
Algorithm Hash digest
SHA256 f40fa29c38cdf880161d541675686784c3fb8ce8a94ec8ad90fbdc3934f1c1fd
MD5 c608776d9b2c358afbeea8ed616e71b2
BLAKE2b-256 58b456f2e011ed81ac9837b99e906a45b0d31f4dfa8f14331b9c7f754b70de1c

See more details on using hashes here.

File details

Details for the file python_semantic_release-4.11.0-py3-none-any.whl.

File metadata

  • Download URL: python_semantic_release-4.11.0-py3-none-any.whl
  • Upload date:
  • Size: 30.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.7

File hashes

Hashes for python_semantic_release-4.11.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c97fe70b114f53433df9647b2be5ccbf7856631e0f51ecd0765a71ef382de248
MD5 fe53911d7f0dd6ad6c113eb21f7d06e5
BLAKE2b-256 62fd386bf129baf963bd796b77efe826b15a55ca03135b89b61bce3f7be20c47

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page