File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- name : Publish to PyPI
1+ name : Publish to PyPI on Tag
22
33on :
4- release :
5- types : [published]
6- workflow_dispatch :
4+ push :
5+ tags :
6+ - " v*.*.* "
77
88jobs :
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
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"
You can’t perform that action at this time.
0 commit comments