From f25fa7334fadd5c01f6243affeecb0a76db07a94 Mon Sep 17 00:00:00 2001 From: Christian Dalager Date: Wed, 9 Oct 2024 09:01:21 +0200 Subject: [PATCH] Update version from git tag --- .github/workflows/pypi-publish.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/.github/workflows/pypi-publish.yml b/.github/workflows/pypi-publish.yml index 4d2e7c0..7a0cc7d 100644 --- a/.github/workflows/pypi-publish.yml +++ b/.github/workflows/pypi-publish.yml @@ -18,6 +18,26 @@ jobs: with: python-version: "3.x" + - name: Ensure tag is v-prefixed + id: check_tag + run: | + if [[ "${{ github.ref }}" != refs/tags/v* ]]; then + echo "Error: Release tag must be v-prefixed (e.g., v1.0.0)." + exit 1 + fi + + - name: Extract version from release tag + id: get_version + run: | + echo "Release tag: ${{ github.ref }}" + VERSION="${{ github.ref#refs/tags/v }}" + echo "Version: $VERSION" + echo "release_version=$VERSION" >> $GITHUB_ENV + + - name: Update version in pyproject.toml + run: | + sed -i "s/^version = .*/version = \"${{ env.release_version }}\"/" pyproject.toml + - name: Build release distributions run: | python -m pip install build