Skip to content

Commit

Permalink
chore: use project version for docker build, adapt version format
Browse files Browse the repository at this point in the history
  • Loading branch information
netomi committed Nov 5, 2024
1 parent 76a30ed commit 8ca8cd3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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 }}
Expand Down
8 changes: 7 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down

0 comments on commit 8ca8cd3

Please sign in to comment.