diff --git a/.bumpversion.cfg b/.bumpversion.cfg deleted file mode 100644 index e2f7a208..00000000 --- a/.bumpversion.cfg +++ /dev/null @@ -1,15 +0,0 @@ -[bumpversion] -current_version = 0.31.0 -files = setup.py mqttwarn/__init__.py -commit = True -tag = True -tag_name = {new_version} -allow_dirty = False - -[bumpversion:file:setup.py] -search = version="{current_version}" -replace = version="{new_version}" - -[bumpversion:file:mqttwarn/__init__.py] -search = __version__ = "{current_version}" -replace = __version__ = "{new_version}" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 78f7353c..a8b7320c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -61,7 +61,7 @@ jobs: - name: Setup project run: | # Install package in editable mode. - pip install wheel + pip install versioningit wheel pip install --editable=.[test,develop] - name: Check code style diff --git a/CHANGES.rst b/CHANGES.rst index d1569838..085ff7d2 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -7,6 +7,10 @@ in progress =========== - Modernize Docker configuration, now using Debian bullseye and Python 3.11. +- Improve nightly and on-PR Docker builds. +- Add versioning based on Git tags, using ``versioningit``. This will aid in + telling PR- and nightly releases apart from GA releases when running + ``mqttwarn --version``. 2022-11-21 0.31.0 diff --git a/Dockerfile b/Dockerfile index 46e81571..9fead571 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,7 +17,7 @@ RUN chown -R mqttwarn:mqttwarn /etc/mqttwarn # Install mqttwarn COPY . /src -RUN pip install wheel +RUN pip install versioningit wheel RUN pip install /src # Make process run as "mqttwarn" user diff --git a/Dockerfile.full b/Dockerfile.full index b9fd9f79..e22abc25 100644 --- a/Dockerfile.full +++ b/Dockerfile.full @@ -21,7 +21,7 @@ RUN chown -R mqttwarn:mqttwarn /etc/mqttwarn # Install mqttwarn COPY . /src -RUN pip install wheel +RUN pip install versioningit wheel RUN pip install /src[all] # Make process run as "mqttwarn" user diff --git a/Makefile b/Makefile index 313fa453..66b619d9 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ $(eval venvpath := .venv) $(eval pip := $(venvpath)/bin/pip) $(eval python := $(venvpath)/bin/python) $(eval pytest := $(venvpath)/bin/pytest) -$(eval bumpversion := $(venvpath)/bin/bumpversion) +$(eval minibump := $(venvpath)/bin/minibump) $(eval twine := $(venvpath)/bin/twine) $(eval sphinx := $(venvpath)/bin/sphinx-build) $(eval isort := $(venvpath)/bin/isort) @@ -21,6 +21,7 @@ $(eval poe := $(venvpath)/bin/poe) # Setup Python virtualenv setup-virtualenv: @test -e $(python) || python3 -m venv $(venvpath) + $(pip) install versioningit # ------- @@ -71,7 +72,7 @@ docs-html: install-doctools # Utility targets # =============== bumpversion: install-releasetools - @$(bumpversion) $(bump) + @$(minibump) bump --relax $(bump) push: git push && git push --tags diff --git a/mqttwarn/__init__.py b/mqttwarn/__init__.py index 433ee844..939857e1 100644 --- a/mqttwarn/__init__.py +++ b/mqttwarn/__init__.py @@ -1,8 +1,13 @@ # -*- coding: utf-8 -*- -# (c) 2014-2018 The mqttwarn developers - -__version__ = "0.31.0" +# (c) 2014-2023 The mqttwarn developers __author__ = "Jan-Piet Mens , Ben Jones " __copyright__ = "Copyright 2014-2022 Jan-Piet Mens" __license__ = "Eclipse Public License - v 2.0 (http://www.eclipse.org/legal/epl-2.0/)" + +try: + from importlib.metadata import version +except ImportError: + from importlib_metadata import version + +__version__ = version("mqttwarn") diff --git a/pyproject.toml b/pyproject.toml index d89f17f8..5b6b2e40 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,18 @@ +# ================== +# Build system setup +# ================== + +[build-system] +requires = [ + "setuptools>=42", # At least v42 of setuptools required! + "versioningit", +] +build-backend = "setuptools.build_meta" + + +[tool.versioningit] + + # ========================= # Linter and code formatter # ========================= diff --git a/requirements-release.txt b/requirements-release.txt index 7c066778..348c0d4a 100644 --- a/requirements-release.txt +++ b/requirements-release.txt @@ -1,3 +1,3 @@ -bump2version +minibump<1; python_version>='3.10' twine keyring diff --git a/setup.py b/setup.py index 01a3944a..501a5210 100644 --- a/setup.py +++ b/setup.py @@ -1,9 +1,10 @@ # -*- coding: utf-8 -*- -# (c) 2014-2022 The mqttwarn developers +# (c) 2014-2023 The mqttwarn developers import os import platform from setuptools import find_packages, setup +from versioningit import get_cmdclasses here = os.path.abspath(os.path.dirname(__file__)) README = open(os.path.join(here, "README.rst")).read() @@ -16,6 +17,7 @@ "docopt<1", "requests<3", "future>=0.18.0,<1", + "importlib-metadata; python_version<'3.8'", ] extras = { @@ -170,8 +172,8 @@ setup( + cmdclass=get_cmdclasses(), name="mqttwarn", - version="0.31.0", description="mqttwarn - subscribe to MQTT topics and notify pluggable services", long_description=README, license="EPL 2.0",