Skip to content

Commit b1b67d1

Browse files
committed
ci: dynamically update pyproject.toml version from Git tag in publish workflow.
1 parent 775f92d commit b1b67d1

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

.github/workflows/publish-pypi.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,26 @@ jobs:
1818
with:
1919
python-version: "3.11"
2020

21+
- name: Extract version from tag
22+
id: get_version
23+
run: |
24+
# Get tag from release event or use ref for workflow_dispatch
25+
if [ "${{ github.event_name }}" = "release" ]; then
26+
TAG="${{ github.event.release.tag_name }}"
27+
else
28+
TAG="${{ github.ref_name }}"
29+
fi
30+
# Remove 'v' prefix if present
31+
VERSION="${TAG#v}"
32+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
33+
echo "Extracted version: $VERSION"
34+
35+
- name: Update version in pyproject.toml
36+
run: |
37+
sed -i "s/^version = .*/version = \"${{ steps.get_version.outputs.VERSION }}\"/" pyproject.toml
38+
echo "Updated pyproject.toml:"
39+
grep "^version" pyproject.toml
40+
2141
- name: Install build tooling
2242
run: |
2343
python -m pip install --upgrade pip

0 commit comments

Comments
 (0)