11name : Continuous Delivery of Python package
22
3+ run-name : ${{ inputs.production_release && 'Production Release' || 'Beta Release' }}
4+
35on :
46 push :
57 branches :
68 - main
7- - release/*
9+ paths-ignore :
10+ - " docs/**"
11+ workflow_dispatch :
12+ inputs :
13+ production_release :
14+ description : " Production release?"
15+ type : boolean
16+ required : true
17+ default : true
818
919concurrency : release
1020
1727 name : Semantic Release
1828 runs-on : ubuntu-latest
1929 permissions :
20- # IMPORTANT: this permission is mandatory for trusted publishing
30+ # IMPORTANT: mandatory for trusted publishing and GitHub releases
2131 id-token : write
2232 contents : write
2333 packages : read
@@ -37,58 +47,45 @@ jobs:
3747 - name : Setup Python and algokit
3848 uses : ./.github/actions/setup-algokit-python
3949
40- - name : Check if version is already released
41- id : check_version
42- run : |
43- rc=0
44- poetry run semantic-release --strict --noop version || rc=$?
45- echo "return_code=$rc" >> $GITHUB_OUTPUT
46- if [ $rc -ne 2 ]; then
47- exit $rc
48- fi
49-
50- - name : pre-commit and pytest
51- if : steps.check_version.outputs.return_code == '0'
50+ - name : Run tests and quality checks (dummy for testing)
5251 run : |
5352 set -o pipefail
5453 poetry run pre-commit run --all-files && git diff --exit-code
5554 poetry run pytest
5655
57- - name : Set Git user as GitHub actions
58- if : steps.check_version.outputs.return_code == '0'
59- run : git config --global user.email "actions@github.com" && git config --global user.name "github-actions"
60-
61- - name : Update release
62- if : steps.check_version.outputs.return_code == '0'
63- run : poetry run semantic-release --strict version
64- env :
65- GITHUB_TOKEN : ${{ steps.app-token.outputs.token }}
66-
67- - name : Create Wheel
68- if : steps.check_version.outputs.return_code == '0'
69- run : poetry build --format wheel
56+ - name : Get branch name
57+ shell : bash
58+ run : echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
59+ id : get_branch
7060
71- - uses : actions/upload-artifact@v4 # upload artifacts so they are retained on the job
72- if : steps.check_version.outputs.return_code == '0'
61+ - name : Python Semantic Release - Beta (non-prod)
62+ id : release-beta
63+ if : steps.get_branch.outputs.branch == 'main' && !inputs.production_release
64+ uses : python-semantic-release/python-semantic-release@v10.3.1
7365 with :
74- path : dist
66+ github_token : ${{ steps.app-token.outputs.token }}
67+ prerelease : true
7568
76- - name : Publish to GitHub
77- if : steps.check_version.outputs.return_code == '0'
78- run : poetry run semantic-release publish
79- env :
80- GITHUB_TOKEN : ${{ steps.app-token.outputs.token }}
69+ - name : Python Semantic Release - Production
70+ id : release-prod
71+ if : steps.get_branch.outputs.branch == 'main' && inputs.production_release
72+ uses : python-semantic-release/python-semantic-release@v10.3.1
73+ with :
74+ github_token : ${{ steps.app-token.outputs.token }}
8175
8276 - name : Publish to PyPI
83- if : steps.check_version.outputs.return_code == '0'
8477 uses : pypa/gh-action-pypi-publish@release/v1
78+ with :
79+ verbose : true
80+
8581
8682 publish-docs :
8783 name : Publish Docs
88- # Don't publish canary docs
89- if : github.ref != 'refs/heads/main'
84+ needs : release
85+ # Don't publish docs for beta releases from main
86+ if : inputs.production_release
9087 uses : ./.github/workflows/gh-pages.yaml
9188 permissions :
9289 contents : read
9390 pages : write
94- id-token : write
91+ id-token : write
0 commit comments