11name : Release
22
3- on : create
3+ on :
4+ release :
5+ types : [published]
46
57jobs :
6- release :
7- if : ${{ startsWith(github.ref, 'refs/heads/release/v') }}
8+ package_and_release :
89 runs-on : ubuntu-latest
10+ if : startsWith(github.ref, 'refs/tags/v')
911 steps :
1012 - uses : actions/checkout@v3
11- with :
12- token : ${{ secrets.TOWNCRIER_TOKEN }}
13- fetch-depth : 0
14- submodules : true
15-
16- - name : Set up Python 3.10
13+ - name : Set up Python 3.12
1714 uses : actions/setup-python@v4
1815 with :
19- python-version : " 3.10"
20-
21- - name : Extract the tag
22- id : vars
23- run : |
24- echo "::set-output name=tag::${GITHUB_REF##*/}"
25-
26- - name : Check tag validity
27- env :
28- VERSION : ${{ steps.vars.outputs.tag }}
29- run : |
30- grep "^v[[:digit:]]\.[[:digit:]]\.[[:digit:]]$" <<< "$VERSION" || (echo "Invalid version: '$VERSION'" && exit 42)
31-
32- - name : Install dependencies
33- run : |
34- sudo apt install pandoc
35- python -m pip install --upgrade pip
36- pip install tox bump2version
37- pip install -e '.'
38-
39- - name : Check generated docs
40- run : |
41- tox -e check-docs
42-
43- - name : Bump the version
44- # the part (patch) doesn't matter when supplying --new-version
45- env :
46- VERSION : ${{ steps.vars.outputs.tag }}
47- run : |
48- bump2version patch --no-commit --no-tag --verbose --new-version "${VERSION/v/}"
49-
50- - name : Commit version bump
51- uses : stefanzweifel/git-auto-commit-action@v4
52- with :
53- file_pattern : .bumpversion.cfg
54- commit_user_name : CI
55- commit_message : ${{ format('[auto][ci skip] Release {0}', steps.vars.outputs.tag) }}
56- tagging_message : ${{ steps.vars.outputs.tag }}
57- skip_dirty_check : false
58-
59- # `Test` triggers `Deployment`
60- # TODO(michalk8): can't find WD for `Test`
61- - name : Invoke deployment workflow
62- uses : benc-uk/workflow-dispatch@v1
16+ python-version : " 3.12"
17+ cache : pip
18+ - name : Install build dependencies
19+ run : python -m pip install --upgrade pip wheel twine build
20+ - name : Build package
21+ run : python -m build
22+ - name : Check package
23+ run : twine check --strict dist/*.whl
24+ - name : Install hatch
25+ run : pip install hatch
26+ - name : Build project for distribution
27+ run : hatch build
28+ - name : Publish a Python distribution to PyPI
29+ uses : pypa/gh-action-pypi-publish@release/v1
6330 with :
64- workflow : Deployment
65- token : ${{ secrets.RELEASE_DISPATCH_TOKEN }}
66- inputs : ' { "reason": "release" }'
31+ password : ${{ secrets.PYPI_API_TOKEN }}
0 commit comments