File tree Expand file tree Collapse file tree 1 file changed +20
-25
lines changed
Expand file tree Collapse file tree 1 file changed +20
-25
lines changed Original file line number Diff line number Diff line change @@ -2,44 +2,24 @@ name: Publish to PyPI
22
33on :
44 push :
5- branches : [main]
5+ tags :
6+ - ' v*'
67
78jobs :
89 publish :
910 runs-on : ubuntu-latest
11+ permissions :
12+ contents : write
13+ id-token : write
1014
1115 steps :
1216 - uses : actions/checkout@v4
13- with :
14- fetch-depth : 0
1517
1618 - name : Set up Python
1719 uses : actions/setup-python@v5
1820 with :
1921 python-version : ' 3.11'
2022
21- - name : Get version from pyproject.toml
22- id : get_version
23- run : |
24- VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
25- echo "version=v$VERSION" >> $GITHUB_OUTPUT
26-
27- - name : Create Release
28- id : create_release
29- uses : actions/create-release@v1
30- env :
31- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
32- with :
33- tag_name : ${{ steps.get_version.outputs.version }}
34- release_name : Release ${{ steps.get_version.outputs.version }}
35- body : |
36- ## What's Changed
37- ${{ github.event.head_commit.message }}
38-
39- **Full Changelog**: https://github.com/${{ github.repository }}/commits/${{ steps.get_version.outputs.version }}
40- draft : false
41- prerelease : false
42-
4323 - name : Install build dependencies
4424 run : |
4525 python -m pip install --upgrade pip
4828 - name : Build package
4929 run : python -m build
5030
31+ - name : Extract changelog
32+ id : changelog
33+ run : |
34+ VERSION=${GITHUB_REF#refs/tags/v}
35+ CHANGELOG=$(awk '/## \['$VERSION'\]/,/## \[/' CHANGELOG.md | sed '$d' | tail -n +2)
36+ echo "content<<EOF" >> $GITHUB_OUTPUT
37+ echo "$CHANGELOG" >> $GITHUB_OUTPUT
38+ echo "EOF" >> $GITHUB_OUTPUT
39+
40+ - name : Create Release
41+ uses : softprops/action-gh-release@v1
42+ with :
43+ body : ${{ steps.changelog.outputs.content }}
44+ generate_release_notes : false
45+
5146 - name : Publish to PyPI
5247 env :
5348 TWINE_USERNAME : __token__
You can’t perform that action at this time.
0 commit comments