@@ -2,60 +2,52 @@ name: Publish new version on PyPi
22
33on :
44 workflow_dispatch :
5- inputs :
6- version :
7- type : string
8- description : Set new version!
9- required : true
5+ push :
6+ branches :
7+ - master
8+
9+ permissions :
10+ contents : write
11+ issues : write
12+ pull-requests : write
13+ repository-projects : read # this is required by release-please-action to set the auto-release tags
14+
15+ # Note for release-please-action:
16+ # The action will set the auto-release tags for the release PR. If these tags do not already exist, the action will fail to create them.
17+ # Therefore, make sure that the tags are created in the repository before running the release workflow: `autorelease: pending`, `autorelease: tagged`
1018
1119jobs :
1220 publish :
1321 runs-on : ubuntu-22.04
1422
1523 steps :
16- - name : Checkout
17- uses : actions/checkout@v3
24+ - uses : googleapis/release-please-action@v4
25+ id : release
1826 with :
19- token : ${{ secrets.PYPI_PUBLISH_PAT }}
20- fetch-depth : 0
21- ref : master
27+ token : ${{ secrets.GITHUB_TOKEN }}
28+ release-type : python
2229
23- - name : Git Config
24- run : |
25- git config --global user.email "github-actions[bot]@users.noreply.github.com"
26- git config --global user.name "github-actions[bot]"
27-
28- - name : Set package version in version.py
29- run : |
30- echo "__version__ = \"${{ inputs.version }}\"" > honeybadger/version.py
31- cat honeybadger/version.py
32-
33- - name : Update changelog
34- run : |
35- printf -v date '%(%Y-%m-%d)T\n' -1
36- sed -i "6 a ## [${{ inputs.version }}] - $date" CHANGELOG.md
37- sed -i '/## \[Unreleased\]/{G;}' CHANGELOG.md
38- cat CHANGELOG.md
30+ # The logic below handles Pypi publishing.
31+ - name : Checkout
32+ uses : actions/checkout@v5
33+ if : ${{ steps.release.outputs.release_created }}
3934
4035 - name : Setup python
36+ if : ${{ steps.release.outputs.release_created }}
4137 uses : actions/setup-python@v4
4238 with :
4339 python-version : ' 3.9'
4440
4541 - name : Build for python 3
42+ if : ${{ steps.release.outputs.release_created }}
4643 run : |
4744 pip install --upgrade twine wheel
4845 python setup.py bdist_wheel
4946 ls dist
5047
5148 - name : Upload
49+ if : ${{ steps.release.outputs.release_created }}
5250 env :
5351 TWINE_USERNAME : __token__
5452 TWINE_PASSWORD : ${{ secrets.PYPI_API_TOKEN }}
5553 run : twine upload dist/*
56-
57- - name : Push version on git
58- run : |
59- git commit -am "Release ${{ inputs.version }}"
60- git tag v${{ inputs.version }}
61- git push origin master --tags
0 commit comments