Skip to content

Commit

Permalink
Merge pull request #130 from RDFLib/edmond/ci-version
Browse files Browse the repository at this point in the history
Add versioning on push to main and release
  • Loading branch information
edmondchuc authored Jul 14, 2023
2 parents d40e299 + 71be81b commit a231ebf
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/on_push_to_main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/on_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down Expand Up @@ -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"
Expand Down
12 changes: 9 additions & 3 deletions prez/config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from os import environ
from pathlib import Path
from typing import Optional

Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>", "Nicholas Car <[email protected]>", "David Habgood <[email protected]>"]

Expand Down

0 comments on commit a231ebf

Please sign in to comment.