Skip to content

Commit a5eb59b

Browse files
committed
update the published version based on version tag
1 parent 24549c8 commit a5eb59b

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

.github/workflows/workflow.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ jobs:
1111

1212
release-build:
1313
runs-on: ubuntu-latest
14+
if: startsWith(github.ref, 'refs/tags/')
1415

1516
steps:
1617
- uses: actions/checkout@v4
@@ -19,6 +20,23 @@ jobs:
1920
with:
2021
python-version: "3.x"
2122

23+
- name: Update package.json version
24+
run: |
25+
TAG_NAME=$(echo ${GITHUB_REF#refs/tags/})
26+
sed -i "s/version=.*,/version='$TAG_NAME',/" setup.py
27+
28+
- name: Commit and push changes
29+
run: |
30+
git config --global user.name 'github-actions[bot]'
31+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
32+
git add setup.py
33+
git commit -m "Update setup.py version to $TAG_NAME"
34+
git tag -f $TAG_NAME
35+
git push --force origin $TAG_NAME
36+
git push
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
2240
- name: build release distributions
2341
run: |
2442
pip install setuptools
@@ -32,7 +50,7 @@ jobs:
3250

3351
pypi-publish:
3452
runs-on: ubuntu-latest
35-
if: ${{ github.ref == 'refs/heads/main' }}
53+
if: startsWith(github.ref, 'refs/tags/')
3654
needs:
3755
- release-build
3856
permissions:

0 commit comments

Comments
 (0)