Skip to content

Commit 81b47b6

Browse files
committed
update
1 parent 95f9dc3 commit 81b47b6

1 file changed

Lines changed: 28 additions & 5 deletions

File tree

.github/workflows/publish.yml

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,40 @@
1-
name: Publish to PyPI
1+
name: Publish to PyPI on Tag
22

33
on:
4-
release:
5-
types: [published]
6-
workflow_dispatch:
4+
push:
5+
tags:
6+
- "v*.*.*"
77

88
jobs:
99
publish:
1010
runs-on: ubuntu-latest
1111
permissions:
12-
contents: read
12+
contents: write
1313
id-token: write
1414

1515
steps:
1616
- uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
1719

1820
- name: Set up Python
1921
uses: actions/setup-python@v5
2022
with:
2123
python-version: "3.12"
2224

25+
- name: Extract version from tag
26+
id: get_version
27+
run: |
28+
VERSION=${GITHUB_REF#refs/tags/v}
29+
echo "version=$VERSION" >> $GITHUB_OUTPUT
30+
echo "Extracted version: $VERSION"
31+
32+
- name: Update pyproject.toml version
33+
run: |
34+
VERSION=${{ steps.get_version.outputs.version }}
35+
sed -i "s/^version = .*/version = \"$VERSION\"/" pyproject.toml
36+
cat pyproject.toml | grep version
37+
2338
- name: Install build dependencies
2439
run: |
2540
python -m pip install --upgrade pip
@@ -31,3 +46,11 @@ jobs:
3146
3247
- name: Publish to PyPI
3348
uses: pypa/gh-action-pypi-publish@release/v1
49+
50+
- name: Commit version bump
51+
run: |
52+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
53+
git config --local user.name "github-actions[bot]"
54+
git add pyproject.toml
55+
git commit -m "chore: bump version to ${{ steps.get_version.outputs.version }}" || echo "No changes to commit"
56+
git push origin HEAD:main || echo "Nothing to push"

0 commit comments

Comments
 (0)