1- name : Release
1+ name : Publish Python Package
22
33on :
4- push :
5- tags :
6- - ' v*'
4+ release :
5+ types : [created]
76
87jobs :
9- test :
8+ deploy :
109 runs-on : ubuntu-latest
11- strategy :
12- matrix :
13- python-version : ["3.8", "3.9", "3.10", "3.11", "3.12"]
14-
1510 steps :
16- - uses : actions/checkout@v4
11+ - uses : actions/checkout@v3
1712
18- - name : Set up Python ${{ matrix.python-version }}
13+ - name : Set up Python
1914 uses : actions/setup-python@v4
2015 with :
21- python-version : ${{ matrix.python-version }}
16+ python-version : ' 3.12 '
2217
2318 - name : Install dependencies
2419 run : |
2520 python -m pip install --upgrade pip
21+ pip install build twine wheel
22+ pip install -r requirements/dev.txt
2623 pip install -e .
27- pip install -r requirements/test.txt
2824
2925 - name : Run tests
3026 run : |
31- pytest tests/
32-
33- build :
34- needs : test
35- runs-on : ubuntu-latest
36-
37- steps :
38- - uses : actions/checkout@v4
39-
40- - name : Set up Python
41- uses : actions/setup-python@v4
42- with :
43- python-version : " 3.11"
44-
45- - name : Install build dependencies
46- run : |
47- python -m pip install --upgrade pip
48- pip install build twine
27+ PYTHONPATH=$PYTHONPATH:$(pwd) pytest
4928
5029 - name : Build package
5130 run : |
5231 python -m build
5332
54- - name : Check package
55- run : |
56- twine check dist/*
57-
58- - name : Upload build artifacts
59- uses : actions/upload-artifact@v3
60- with :
61- name : dist
62- path : dist/
63-
64- publish :
65- needs : build
66- runs-on : ubuntu-latest
67- environment : release
68-
69- steps :
70- - uses : actions/checkout@v4
71-
72- - name : Download build artifacts
73- uses : actions/download-artifact@v3
74- with :
75- name : dist
76- path : dist/
77-
78- - name : Set up Python
79- uses : actions/setup-python@v4
80- with :
81- python-version : " 3.11"
82-
83- - name : Install twine
84- run : |
85- python -m pip install --upgrade pip
86- pip install twine
87-
8833 - name : Publish to PyPI
89- env :
90- TWINE_USERNAME : __token__
91- TWINE_PASSWORD : ${{ secrets.PYPI_API_TOKEN }}
92- run : |
93- twine upload dist/*
94-
95- github-release :
96- needs : publish
97- runs-on : ubuntu-latest
98-
99- steps :
100- - uses : actions/checkout@v4
101-
102- - name : Download build artifacts
103- uses : actions/download-artifact@v3
104- with :
105- name : dist
106- path : dist/
107-
108- - name : Create GitHub Release
109- uses : softprops/action-gh-release@v1
34+ if : startsWith(github.ref, 'refs/tags')
35+ uses : pypa/gh-action-pypi-publish@release/v1
11036 with :
111- files : dist/*
112- generate_release_notes : true
113- draft : false
114- prerelease : false
115- env :
116- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
37+ password : ${{ secrets.PYPI_API_TOKEN }}
38+ verify_metadata : true
0 commit comments