diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4a9fa74..e3fb4fe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,6 +58,10 @@ jobs: python -m pip install --upgrade pip pip install build + - name: Set package version (tags only) + if: startsWith(github.ref, 'refs/tags/v') + run: echo "SETUPTOOLS_SCM_PRETEND_VERSION_FOR_MESHCORE_PROXY=${GITHUB_REF_NAME#v}" >> "$GITHUB_ENV" + - name: Build packages run: python -m build @@ -131,6 +135,9 @@ jobs: type=ref,event=tag type=raw,value=latest + - name: Set image version + run: echo "MESHCORE_PROXY_VERSION=${GITHUB_REF_NAME#v}" >> "$GITHUB_ENV" + - name: Build and push image uses: docker/build-push-action@v5 with: @@ -139,3 +146,5 @@ jobs: platforms: linux/amd64,linux/arm64 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + build-args: | + MESHCORE_PROXY_VERSION=${{ env.MESHCORE_PROXY_VERSION }} diff --git a/Dockerfile b/Dockerfile index e936c4a..2474d3d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,8 @@ LABEL org.opencontainers.image.source="https://github.com/rgregg/meshcore-proxy" LABEL org.opencontainers.image.description="TCP proxy for MeshCore companion radios" LABEL org.opencontainers.image.licenses="MIT" +ARG MESHCORE_PROXY_VERSION + # Install system dependencies for BLE support RUN apt-get update && apt-get install -y --no-install-recommends \ bluez \ @@ -23,6 +25,7 @@ COPY pyproject.toml README.md ./ COPY src/ ./src/ # Install the package +ENV SETUPTOOLS_SCM_PRETEND_VERSION_FOR_MESHCORE_PROXY=${MESHCORE_PROXY_VERSION} RUN pip install --no-cache-dir . # Switch to non-root user diff --git a/pyproject.toml b/pyproject.toml index 9e02842..f9eeb7e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -61,3 +61,4 @@ testpaths = ["tests"] version_scheme = "guess-next-dev" local_scheme = "no-local-version" tag_regex = "^v(?P[0-9]+\\.[0-9]+\\.[0-9]+(-alpha|-beta|-rc[0-9]+)?)$" +fallback_version = "0.0.0.dev0" diff --git a/src/meshcore_proxy/__init__.py b/src/meshcore_proxy/__init__.py index 1e1a157..058da60 100644 --- a/src/meshcore_proxy/__init__.py +++ b/src/meshcore_proxy/__init__.py @@ -1,6 +1,6 @@ """MeshCore Proxy - TCP proxy for MeshCore companion radios.""" -from importlib.metadata import version, PackageNotFoundError +from importlib.metadata import PackageNotFoundError, version try: __version__ = version("meshcore-proxy")