Skip to content

Rework versioning based on Git tags, and modernize Docker configuration #620

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions .bumpversion.cfg

This file was deleted.

2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
*
!.git
!etc
!mqttwarn
!tests
!pyproject.toml
!setup.py
!MANIFEST.in
!*.ini
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/release-docker-full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ jobs:
-
name: Acquire sources
uses: actions/checkout@v3
with:
fetch-depth: 0
-
name: Docker meta
id: meta
Expand All @@ -44,7 +46,9 @@ jobs:
# Generate Docker tags based on the following events/attributes
tags: |
type=schedule,pattern=nightly
type=ref,event=tag
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
-
name: Inspect meta
run: |
Expand Down Expand Up @@ -75,7 +79,6 @@ jobs:
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
-
name: Login to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ghcr.io
Expand All @@ -90,7 +93,7 @@ jobs:
platforms: linux/amd64,linux/arm64,linux/arm/v7
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: ${{ github.event_name != 'pull_request' }}
push: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new

Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/release-docker-standard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ jobs:
-
name: Acquire sources
uses: actions/checkout@v3
with:
fetch-depth: 0
-
name: Docker meta
id: meta
Expand All @@ -44,7 +46,9 @@ jobs:
# Generate Docker tags based on the following events/attributes
tags: |
type=schedule,pattern=nightly
type=ref,event=tag
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
-
name: Inspect meta
run: |
Expand Down Expand Up @@ -75,7 +79,6 @@ jobs:
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
-
name: Login to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ghcr.io
Expand All @@ -90,7 +93,7 @@ jobs:
platforms: linux/amd64,linux/arm64,linux/arm/v7
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: ${{ github.event_name != 'pull_request' }}
push: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12-dev"]
os: [ubuntu-20.04, macos-latest, windows-latest]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11"] # "3.12-dev"
exclude:

# Breaks on building `winsdk`
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ mqttwarn changelog
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
=================
Expand Down
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
#
# docker build --tag=mqttwarn-local .
#
FROM python:3.9-slim-buster
FROM python:3.11-slim-bullseye

# Install additional requirements
RUN apt-get update && apt-get install --yes git

# Create /etc/mqttwarn
RUN mkdir -p /etc/mqttwarn
Expand All @@ -17,7 +20,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
Expand Down
6 changes: 4 additions & 2 deletions Dockerfile.full
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
#
# docker build --tag=mqttwarn-local-full --file=Dockerfile.full .
#
FROM python:3.9-slim-buster
FROM python:3.11-slim-bullseye

# Install additional requirements
RUN apt-get update && apt-get install --yes git

# FIXME: Skip all packages needing compilation
#RUN apt-get update && apt-get install --yes librrd-dev

Expand All @@ -21,7 +23,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
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -21,6 +21,7 @@ $(eval poe := $(venvpath)/bin/poe)
# Setup Python virtualenv
setup-virtualenv:
@test -e $(python) || python3 -m venv $(venvpath)
$(pip) install versioningit


# -------
Expand Down Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 deletions mqttwarn/__init__.py
Original file line number Diff line number Diff line change
@@ -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 <jpmens()gmail.com>, Ben Jones <ben.jones12()gmail.com>"
__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 # type: ignore[no-redef]

__version__ = version("mqttwarn")
19 changes: 19 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
# ==================
# Build system setup
# ==================

[build-system]
requires = [
"setuptools>=42", # At least v42 of setuptools required!
"versioningit",
]
build-backend = "setuptools.build_meta"


[tool.versioningit]

[tool.versioningit.vcs]
method = "git"
default-tag = "0.0.0"


# =========================
# Linter and code formatter
# =========================
Expand Down
2 changes: 1 addition & 1 deletion requirements-release.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
bump2version
minibump<1; python_version>='3.10'
twine
keyring
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -16,6 +17,7 @@
"docopt<1",
"requests<3",
"future>=0.18.0,<1",
"importlib-metadata; python_version<'3.8'",
]

extras = {
Expand Down Expand Up @@ -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",
Expand All @@ -197,7 +199,6 @@
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Communications",
"Topic :: Education",
"Topic :: Internet",
Expand Down