Fixed version display

This commit is contained in:
Louis King
2025-12-07 21:55:10 +00:00
parent f0cee14bd8
commit 278d102064
5 changed files with 15 additions and 18 deletions

View File

@@ -59,13 +59,13 @@ jobs:
tags: ${{ steps.meta.outputs.tags }} tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
build-args: | build-args: |
SETUPTOOLS_SCM_PRETEND_VERSION=${{ startsWith(github.ref, 'refs/tags/v') && github.ref_name || format('0.0.0.dev0+g{0}', github.sha) }} BUILD_VERSION=${{ github.ref_name }}
cache-from: type=gha cache-from: type=gha
cache-to: type=gha,mode=max cache-to: type=gha,mode=max
- name: Test Docker image - name: Test Docker image
if: github.event_name == 'pull_request' if: github.event_name == 'pull_request'
run: | run: |
docker build -t meshcore-hub-test --build-arg SETUPTOOLS_SCM_PRETEND_VERSION=0.0.0.dev0+g${{ github.sha }} -f Dockerfile . docker build -t meshcore-hub-test --build-arg BUILD_VERSION=${{ github.ref_name }} -f Dockerfile .
docker run --rm meshcore-hub-test --version docker run --rm meshcore-hub-test --version
docker run --rm meshcore-hub-test --help docker run --rm meshcore-hub-test --help

View File

@@ -21,9 +21,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
RUN python -m venv /opt/venv RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH" ENV PATH="/opt/venv/bin:$PATH"
# Build argument for version (set via CI or manually)
ARG SETUPTOOLS_SCM_PRETEND_VERSION=0.0.0+docker
# Copy project files # Copy project files
WORKDIR /app WORKDIR /app
COPY pyproject.toml README.md ./ COPY pyproject.toml README.md ./
@@ -31,9 +28,13 @@ COPY src/ ./src/
COPY alembic/ ./alembic/ COPY alembic/ ./alembic/
COPY alembic.ini ./ COPY alembic.ini ./
# Install the package with version from build arg # Build argument for version (set via CI or manually)
RUN pip install --upgrade pip && \ ARG BUILD_VERSION=dev
SETUPTOOLS_SCM_PRETEND_VERSION=${SETUPTOOLS_SCM_PRETEND_VERSION} pip install .
# Set version in _version.py and install the package
RUN sed -i "s/__version__ = \"dev\"/__version__ = \"${BUILD_VERSION}\"/" src/meshcore_hub/_version.py && \
pip install --upgrade pip && \
pip install .
# ============================================================================= # =============================================================================
# Stage 2: Runtime - Final production image # Stage 2: Runtime - Final production image

View File

@@ -1,10 +1,10 @@
[build-system] [build-system]
requires = ["setuptools>=68.0", "wheel", "setuptools-scm>=8.0"] requires = ["setuptools>=68.0", "wheel"]
build-backend = "setuptools.build_meta" build-backend = "setuptools.build_meta"
[project] [project]
name = "meshcore-hub" name = "meshcore-hub"
dynamic = ["version"] version = "0.0.0"
description = "Python monorepo for managing and orchestrating MeshCore mesh networks" description = "Python monorepo for managing and orchestrating MeshCore mesh networks"
readme = "README.md" readme = "README.md"
license = {text = "GPL-3.0-or-later"} license = {text = "GPL-3.0-or-later"}
@@ -68,10 +68,6 @@ Documentation = "https://github.com/ipnet-mesh/meshcore-hub#readme"
Repository = "https://github.com/ipnet-mesh/meshcore-hub" Repository = "https://github.com/ipnet-mesh/meshcore-hub"
Issues = "https://github.com/ipnet-mesh/meshcore-hub/issues" Issues = "https://github.com/ipnet-mesh/meshcore-hub/issues"
[tool.setuptools_scm]
version_file = "src/meshcore_hub/_version.py"
fallback_version = "0.0.0+unknown"
[tool.setuptools.packages.find] [tool.setuptools.packages.find]
where = ["src"] where = ["src"]

View File

@@ -1,5 +1,5 @@
"""MeshCore Hub - Python monorepo for managing MeshCore mesh networks.""" """MeshCore Hub - Python monorepo for managing MeshCore mesh networks."""
from meshcore_hub._version import __version__, __version_tuple__ from meshcore_hub._version import __version__
__all__ = ["__version__", "__version_tuple__"] __all__ = ["__version__"]

View File

@@ -83,7 +83,7 @@
</ul> </ul>
</div> </div>
<div class="navbar-end"> <div class="navbar-end">
<div class="badge badge-outline badge-sm">v{{ version }}</div> <div class="badge badge-outline badge-sm">{{ version }}</div>
</div> </div>
</div> </div>
@@ -114,7 +114,7 @@
<a href="{{ network_contact_github }}" target="_blank" rel="noopener noreferrer" class="link link-hover">GitHub</a> <a href="{{ network_contact_github }}" target="_blank" rel="noopener noreferrer" class="link link-hover">GitHub</a>
{% endif %} {% endif %}
</p> </p>
<p class="text-xs opacity-50 mt-2">Powered by <a href="https://github.com/ipnet-mesh/meshcore-hub" target="_blank" rel="noopener noreferrer" class="link link-hover">MeshCore Hub</a> v{{ version }}</p> <p class="text-xs opacity-50 mt-2">Powered by <a href="https://github.com/ipnet-mesh/meshcore-hub" target="_blank" rel="noopener noreferrer" class="link link-hover">MeshCore Hub</a> {{ version }}</p>
</aside> </aside>
</footer> </footer>