2727 name : Test code
2828 runs-on : ${{ matrix.os }}
2929 needs : is-duplicate
30- if : ${{ needs.is-duplicate.outputs.should_skip != 'true' }}
30+ if : needs.is-duplicate.outputs.should_skip != 'true'
3131 strategy :
3232 matrix :
3333 os : [ubuntu-latest, macos-latest, windows-latest]
@@ -52,65 +52,80 @@ jobs:
5252 - name : Test with Tox
5353 run : tox
5454
55- test-dist :
56- name : Test distribution
57- runs-on : ubuntu-latest
55+ build-wheels :
56+ name : Build wheels
57+ runs-on : ${{ matrix.os }}
5858 needs : is-duplicate
59- if : ${{ needs.is-duplicate.outputs.should_skip != 'true' }}
59+ if : |
60+ needs.is-duplicate.outputs.should_skip != 'true' &&
61+ startsWith(github.ref, 'refs/heads/develop')
62+ strategy :
63+ matrix :
64+ os : [ubuntu-latest, macos-latest, windows-latest]
6065
6166 steps :
6267 - name : Check out code
6368 uses : actions/checkout@v3
6469 with :
6570 submodules : recursive
6671
67- - name : Set up Python
68- uses : actions/setup-python@v4.5.0
72+ - name : Build wheels
73+ uses : pypa/cibuildwheel@v2.12.3
74+
75+ - name : Upload artefacts to GitHub
76+ uses : actions/upload-artifact@v3
6977 with :
70- python-version : ' 3.x'
78+ name : dist-packages
79+ path : wheelhouse/*.whl
7180
72- - name : Install dependencies
73- run : |
74- python -m pip install --upgrade pip
75- pip install --upgrade build twine
81+ build-sdist :
82+ name : Build source distribution
83+ runs-on : ubuntu-latest
84+ needs : is-duplicate
85+ if : |
86+ needs.is-duplicate.outputs.should_skip != 'true' &&
87+ startsWith(github.ref, 'refs/heads/develop')
88+
89+ steps :
90+ - name : Check out code
91+ uses : actions/checkout@v3
92+ with :
93+ submodules : recursive
7694
77- - name : Build and test with Twine
95+ - name : Build sdist
7896 run : |
79- python -m build
80- twine check dist/*
97+ pipx run build --sdist
98+ pipx run twine check dist/*
99+
100+ - name : Upload artefacts to GitHub
101+ uses : actions/upload-artifact@v3
102+ with :
103+ name : dist-packages
104+ path : dist/*.tar.gz
81105
82106 publish-to-test-pypi :
83107 name : Publish to TestPyPI
84108 environment : staging
85109 runs-on : ubuntu-latest
86- needs : [test-code]
110+ needs : [test-code, build-sdist, build-wheels ]
87111 if : |
88112 !failure() &&
89- startsWith(github.ref, 'refs/tags/')
113+ github.event_name == 'push' &&
114+ startsWith(github.ref, 'refs/tags/v')
90115
91116 steps :
92- - name : Check out code
93- uses : actions/checkout @v3
117+ - name : Download artefacts
118+ uses : actions/download-artifact @v3
94119 with :
95- submodules : recursive
120+ name : dist-packages
121+ path : dist
96122
97- - name : Set up Python
98- uses : actions/setup-python@v4.5.0
123+ - name : Publish to TestPyPI
124+ uses : pypa/gh-action-pypi-publish@v1.8.5
99125 with :
100- python-version : ' 3.x'
101-
102- - name : Install dependencies
103- run : |
104- python -m pip install --upgrade pip
105- pip install --upgrade build twine
106-
107- - name : Build and publish
108- env :
109- TWINE_USERNAME : ' __token__'
110- TWINE_PASSWORD : ${{ secrets.PYPI_API_TOKEN }}
111- run : |
112- python -m build
113- twine upload --repository testpypi dist/*
126+ repository-url : https://test.pypi.org/legacy/
127+ password : ${{ secrets.PYPI_API_TOKEN }}
128+ print-hash : true
114129
115130 publish-to-pypi :
116131 name : Publish to PyPI
@@ -119,28 +134,18 @@ jobs:
119134 needs : [publish-to-test-pypi]
120135 if : |
121136 !failure() &&
122- startsWith(github.ref, 'refs/tags/')
137+ github.event_name == 'push' &&
138+ startsWith(github.ref, 'refs/tags/v')
123139
124140 steps :
125- - name : Check out code
126- uses : actions/checkout @v3
141+ - name : Download artefacts
142+ uses : actions/download-artifact @v3
127143 with :
128- submodules : recursive
144+ name : dist-packages
145+ path : dist
129146
130- - name : Set up Python
131- uses : actions/setup-python@v4.5.0
147+ - name : Publish to test PyPI
148+ uses : pypa/gh-action-pypi-publish@v1.8.5
132149 with :
133- python-version : ' 3.x'
134-
135- - name : Install dependencies
136- run : |
137- python -m pip install --upgrade pip
138- pip install --upgrade build twine
139-
140- - name : Build and publish
141- env :
142- TWINE_USERNAME : ' __token__'
143- TWINE_PASSWORD : ${{ secrets.PYPI_API_TOKEN }}
144- run : |
145- python -m build
146- twine upload dist/*
150+ password : ${{ secrets.PYPI_API_TOKEN }}
151+ print-hash : true
0 commit comments