diff --git a/.github/workflows/on_push_to_main.yaml b/.github/workflows/on_push_to_main.yaml index 46fe08b7..214fc40a 100644 --- a/.github/workflows/on_push_to_main.yaml +++ b/.github/workflows/on_push_to_main.yaml @@ -84,6 +84,7 @@ jobs: uses: docker/build-push-action@v4 with: push: true + build-args: PREZ_VERSION=${{ env.IMAGE_NAME }}:${{ steps.patch.outputs.patch }}-${{ steps.hash.outputs.value }} tags: | ${{ env.IMAGE_NAME }}:${{ steps.patch.outputs.patch }}-${{ steps.hash.outputs.value }} ${{ env.IMAGE_NAME }}:dev diff --git a/.github/workflows/on_release.yaml b/.github/workflows/on_release.yaml index 60f9ef36..18292472 100644 --- a/.github/workflows/on_release.yaml +++ b/.github/workflows/on_release.yaml @@ -43,6 +43,7 @@ jobs: uses: docker/build-push-action@v4 with: push: true + build-args: PREZ_VERSION=${{ steps.metadata.outputs.tags }} tags: ${{ steps.metadata.outputs.tags }} # Set provenance to false due to issue documented here: https://github.com/docker/build-push-action/issues/778 provenance: false diff --git a/Dockerfile b/Dockerfile index 39d2a3f5..8baf51d5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,5 @@ +ARG PREZ_VERSION + # Creating a python base with shared environment variables FROM python:3.11-slim-buster as builder-base ENV PYTHONUNBUFFERED=1 \ @@ -33,6 +35,10 @@ COPY poetry.lock pyproject.toml connegp-0.1.5-py3-none-any.whl ./ RUN poetry install --only main --no-root --no-ansi FROM python:3.11-slim-buster + +ARG PREZ_VERSION +ENV PREZ_VERSION=${PREZ_VERSION} + ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ PATH="/app/.venv/bin:$PATH" diff --git a/prez/config.py b/prez/config.py index 665663c0..619e0d1b 100644 --- a/prez/config.py +++ b/prez/config.py @@ -1,3 +1,4 @@ +from os import environ from pathlib import Path from typing import Optional @@ -84,9 +85,14 @@ def check_endpoint_enabled(cls, values): @root_validator() def get_version(cls, values): - values["prez_version"] = toml.load( - Path(Path(__file__).parent.parent) / "pyproject.toml" - )["tool"]["poetry"]["version"] + version = environ.get("PREZ_VERSION") + values["prez_version"] = version + + if version is None or version == "": + values["prez_version"] = toml.load( + Path(Path(__file__).parent.parent) / "pyproject.toml" + )["tool"]["poetry"]["version"] + return values @root_validator() diff --git a/pyproject.toml b/pyproject.toml index 19d255c5..3fad305d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "prez" -version = "3.0.8" +version = "0.1.0.dev0" description = "A python application for displaying linked data on the web" authors = ["Jamie Feiss ", "Nicholas Car ", "David Habgood "]