From 8ca8cd32c7bc8cda1eed6ae36bc68b38618df8d1 Mon Sep 17 00:00:00 2001 From: Thomas Neidhart Date: Wed, 6 Nov 2024 00:00:34 +0100 Subject: [PATCH] chore: use project version for docker build, adapt version format --- .github/workflows/publish.yml | 6 +++++- pyproject.toml | 8 +++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index fb41885..429bcf3 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -28,6 +28,7 @@ jobs: outputs: release-tag: ${{ steps.context.outputs.RELEASE_TAG }} release-version: ${{ steps.context.outputs.RELEASE_VERSION }} + project-version: ${{ steps.context.outputs.PROJECT_VERSION }} steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: @@ -49,10 +50,13 @@ jobs: # extract the current version from the pyproject.toml and replace .devN with -SNAPSHOT VERSION=$(poetry version -s | sed 's/.dev[0-9]*/-SNAPSHOT/') echo "RELEASE_VERSION=$VERSION" >> $GITHUB_OUTPUT + PROJECT_VERSION=$(poetry version -s) + echo "PROJECT_VERSION=$PROJECT_VERSION" >> $GITHUB_OUTPUT else echo "RELEASE_TAG=${{ github.ref_name }}" >> $GITHUB_OUTPUT VERSION=$(echo ${{ github.ref_name }} | sed 's/v//') echo "RELEASE_VERSION=$VERSION" >> $GITHUB_OUTPUT + echo "PROJECT_VERSION=$VERSION" >> $GITHUB_OUTPUT fi build-and-push-image: @@ -88,7 +92,7 @@ jobs: context: . file: docker/Dockerfile build-args: | - version=${{ needs.prepare.outputs.release-version }} + version=${{ needs.prepare.outputs.project-version }} push: true tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.prepare.outputs.release-version }} labels: ${{ steps.meta.outputs.labels }} diff --git a/pyproject.toml b/pyproject.toml index d4621bb..cc578d7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -116,7 +116,13 @@ otterdog = "otterdog.cli:cli" enable = true vcs = "git" latest-tag = true -format-jinja = "{% if distance == 0 %}{{ base }}{% else %}{{ base }}.dev{{ distance }}{% endif %}" +format-jinja = """ + {%- if distance == 0 -%} + {{ serialize_pep440(base, stage, revision) }} + {%- else -%} + {{ serialize_pep440(bump_version(base, 1), stage, revision, dev=distance) }} + {%- endif -%} +""" [build-system] requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning>=1.0.0,<2.0.0"]