diff --git a/.github/workflows/docker_transport_service.yml b/.github/workflows/docker_transport_service.yml index 62f38c46..f5ef128a 100644 --- a/.github/workflows/docker_transport_service.yml +++ b/.github/workflows/docker_transport_service.yml @@ -36,15 +36,23 @@ jobs: - name: Set tag for push if: github.event_name == 'push' - run: echo "TAG1=$IMAGE_NAME:edge" >> $GITHUB_ENV + run: | + echo "WM_TRANSPORT_VERSION=0.0.0.dev0.git+${{ github.sha }}" >> $GITHUB_ENV + echo "TAG1=$IMAGE_NAME:edge" >> $GITHUB_ENV - name: Set tag for manually triggered if: github.event_name == 'workflow_dispatch' - run: echo "TAG1=$IMAGE_NAME:${{ github.event.inputs.tag }}" >> $GITHUB_ENV + run: | + VERSION="${{ github.event.inputs.tag }}" + echo "WM_TRANSPORT_VERSION=${VERSION#v}" >> $GITHUB_ENV + echo "TAG1=$IMAGE_NAME:${VERSION}" >> $GITHUB_ENV - name: Set tag for release version if: github.event_name == 'release' - run: echo "TAG1=$IMAGE_NAME:${{ github.event.release.tag_name }}" >> $GITHUB_ENV + run: | + VERSION="${{ github.event.release.tag_name }}" + echo "WM_TRANSPORT_VERSION=${VERSION#v}" >> $GITHUB_ENV + echo "TAG1=$IMAGE_NAME:${VERSION}" >> $GITHUB_ENV - name: Set additionnal latest tag also for official release if: github.event_name == 'release' && !contains(github.event.release.tag_name, 'rc') @@ -63,7 +71,9 @@ jobs: file: docker/transport_service/Dockerfile platforms: linux/amd64, linux/arm64, linux/arm/v7, linux/arm/v6 push: true - build-args: GATEWAY_BUILD_SHA1= ${{ github.sha }} + build-args: | + GATEWAY_BUILD_SHA1=${{ github.sha }} + WM_TRANSPORT_VERSION=${{ env.WM_TRANSPORT_VERSION }} tags: | ${{ env.TAG1 }} ${{ env.TAG2 }} diff --git a/.github/workflows/release_artefacts.yml b/.github/workflows/release_artefacts.yml index 913c136d..26c432ce 100644 --- a/.github/workflows/release_artefacts.yml +++ b/.github/workflows/release_artefacts.yml @@ -4,6 +4,10 @@ on: release: types: [created] workflow_dispatch: + inputs: + version: + description: 'Version to use' + required: true jobs: build: @@ -17,6 +21,18 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Set version for manually triggered + if: github.event_name == 'workflow_dispatch' + run: | + VERSION="${{ github.event.inputs.version }}" + echo "WM_TRANSPORT_VERSION=${VERSION#v}" >> $GITHUB_ENV + + - name: Set version for release + if: github.event_name == 'release' + run: | + VERSION="${{ github.event.release.tag_name }}" + echo "WM_TRANSPORT_VERSION=${VERSION#v}" >> $GITHUB_ENV + - name: Build and extract transportService wheel uses: docker/build-push-action@v6 with: @@ -25,6 +41,7 @@ jobs: platforms: linux/amd64 push: false target: export + build-args: WM_TRANSPORT_VERSION=${{ env.WM_TRANSPORT_VERSION }} outputs: ./artifacts/transportService/ - name: Move transport service wheel diff --git a/docker/transport_service/Dockerfile b/docker/transport_service/Dockerfile index 7a8784c6..52a7e0ad 100644 --- a/docker/transport_service/Dockerfile +++ b/docker/transport_service/Dockerfile @@ -1,5 +1,9 @@ ARG BASE_IMAGE=python:3.13-alpine3.21 +ARG WM_TRANSPORT_VERSION=0.0.0.dev0 + FROM $BASE_IMAGE AS builder +ARG WM_TRANSPORT_VERSION +ENV WM_TRANSPORT_VERSION=$WM_TRANSPORT_VERSION RUN adduser --disabled-password wirepas diff --git a/python_transport/setup.py b/python_transport/setup.py index 6f69ea4b..b6bdf569 100644 --- a/python_transport/setup.py +++ b/python_transport/setup.py @@ -66,13 +66,17 @@ def get_systemd_lib(key): return None +def get_version(): + return os.environ.get("WM_TRANSPORT_VERSION", "0.0.0.dev0") + + about = {} with open(get_absolute_path("./wirepas_gateway/__about__.py")) as f: exec(f.read(), about) setup( name=about["__pkg_name__"], - version=about["__version__"], + version=get_version(), description=about["__description__"], long_description=long_description, long_description_content_type="text/markdown", @@ -84,7 +88,7 @@ def get_systemd_lib(key): keywords=about["__keywords__"], packages=find_packages(exclude=["contrib", "docs", "tests", "examples"]), install_requires=get_requirements("requirements.txt"), - python_requires=">=3.7", + python_requires=">=3.8", ext_modules=[ Extension( "dbusCExtension", diff --git a/python_transport/wirepas_gateway/__about__.py b/python_transport/wirepas_gateway/__about__.py index 0af240b2..a320ef58 100644 --- a/python_transport/wirepas_gateway/__about__.py +++ b/python_transport/wirepas_gateway/__about__.py @@ -19,5 +19,5 @@ __pkg_name__ = "wirepas_gateway" __title__ = "Wirepas Gateway Transport Service" __url__ = "https://github.com/wirepas/gateway" -__version__ = "1.6.0rc1" __keywords__ = "wirepas connectivity iot mesh" + diff --git a/python_transport/wirepas_gateway/__init__.py b/python_transport/wirepas_gateway/__init__.py index 6e204a1c..7335b790 100644 --- a/python_transport/wirepas_gateway/__init__.py +++ b/python_transport/wirepas_gateway/__init__.py @@ -14,6 +14,7 @@ from . import dbus from . import protocol from . import utils +import importlib.metadata from .__about__ import ( __author__, @@ -25,6 +26,8 @@ __pkg_name__, __title__, __url__, - __version__, __keywords__, ) + +__version__ = importlib.metadata.version(__pkg_name__) +