Skip to content

Commit 2cbcfc7

Browse files
committed
ci: Update wheels-deploy.yml
1 parent 1ace024 commit 2cbcfc7

File tree

1 file changed

+187
-26
lines changed

1 file changed

+187
-26
lines changed

.github/workflows/wheels-deploy.yml

Lines changed: 187 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,60 +5,221 @@ on:
55
tags:
66
- v*
77

8+
workflow_dispatch:
9+
inputs:
10+
os_choice:
11+
description: 'Choose what to build'
12+
required: true
13+
default: 'all'
14+
type: choice
15+
options:
16+
- all
17+
- sdist-only
18+
- ubuntu-latest
19+
- windows-latest
20+
- macos-latest
21+
822
jobs:
9-
build_wheels:
10-
name: Build wheels on ${{ matrix.os }}
11-
runs-on: ${{ matrix.os }}
12-
strategy:
13-
fail-fast: false
14-
matrix:
15-
os: [macos-latest, windows-latest, ubuntu-latest]
23+
build_wheels_ubuntu:
24+
name: Build wheels on ubuntu-latest
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Check if build is needed
28+
id: check_build
29+
run: |
30+
if [ "${{ github.event_name }}" = "push" ]; then
31+
echo "build_needed=true" >> $GITHUB_OUTPUT
32+
elif [ "${{ github.event.inputs.os_choice }}" = "all" ] || [ "${{ github.event.inputs.os_choice }}" = "ubuntu-latest" ]; then
33+
echo "build_needed=true" >> $GITHUB_OUTPUT
34+
else
35+
echo "build_needed=false" >> $GITHUB_OUTPUT
36+
fi
37+
38+
- uses: actions/checkout@v4
39+
if: ${{ steps.check_build.outputs.build_needed == 'true' }}
40+
41+
- name: Set up Python 3.11
42+
if: ${{ steps.check_build.outputs.build_needed == 'true' }}
43+
uses: actions/setup-python@v5
44+
with:
45+
python-version: 3.11
46+
47+
- name: Build wheels
48+
if: ${{ steps.check_build.outputs.build_needed == 'true' }}
49+
uses: pypa/[email protected]
50+
with:
51+
output-dir: ./wheelhouse
52+
53+
- name: Upload wheels
54+
if: ${{ steps.check_build.outputs.build_needed == 'true' }}
55+
uses: actions/upload-artifact@v4
56+
with:
57+
name: wheels-ubuntu-latest
58+
path: ./wheelhouse/*.whl
59+
overwrite: true
60+
61+
build_wheels_windows:
62+
name: Build wheels on windows-latest
63+
runs-on: windows-latest
64+
steps:
65+
- name: Check if build is needed
66+
id: check_build
67+
run: |
68+
if [ "${{ github.event_name }}" = "push" ]; then
69+
echo "build_needed=true" >> $GITHUB_OUTPUT
70+
elif [ "${{ github.event.inputs.os_choice }}" = "all" ] || [ "${{ github.event.inputs.os_choice }}" = "windows-latest" ]; then
71+
echo "build_needed=true" >> $GITHUB_OUTPUT
72+
else
73+
echo "build_needed=false" >> $GITHUB_OUTPUT
74+
fi
75+
76+
- uses: actions/checkout@v4
77+
if: ${{ steps.check_build.outputs.build_needed == 'true' }}
78+
79+
- name: Set up Python 3.11
80+
if: ${{ steps.check_build.outputs.build_needed == 'true' }}
81+
uses: actions/setup-python@v5
82+
with:
83+
python-version: 3.11
1684

85+
- name: Build wheels
86+
if: ${{ steps.check_build.outputs.build_needed == 'true' }}
87+
uses: pypa/[email protected]
88+
with:
89+
output-dir: ./wheelhouse
90+
91+
- name: Upload wheels
92+
if: ${{ steps.check_build.outputs.build_needed == 'true' }}
93+
uses: actions/upload-artifact@v4
94+
with:
95+
name: wheels-windows-latest
96+
path: ./wheelhouse/*.whl
97+
overwrite: true
98+
99+
build_wheels_macos:
100+
name: Build wheels on macos-latest
101+
runs-on: macos-latest
17102
steps:
103+
- name: Check if build is needed
104+
id: check_build
105+
shell: bash
106+
run: |
107+
if [ "${{ github.event_name }}" = "push" ]; then
108+
echo "build_needed=true" >> $GITHUB_OUTPUT
109+
elif [ "${{ github.event.inputs.os_choice }}" = "all" ] || [ "${{ github.event.inputs.os_choice }}" = "macos-latest" ]; then
110+
echo "build_needed=true" >> $GITHUB_OUTPUT
111+
else
112+
echo "build_needed=false" >> $GITHUB_OUTPUT
113+
fi
114+
18115
- uses: actions/checkout@v4
116+
if: ${{ steps.check_build.outputs.build_needed == 'true' }}
117+
118+
- name: Set up Python 3.11
119+
if: ${{ steps.check_build.outputs.build_needed == 'true' }}
120+
uses: actions/setup-python@v5
121+
with:
122+
python-version: 3.11
19123

20124
- name: Build wheels
125+
if: ${{ steps.check_build.outputs.build_needed == 'true' }}
21126
uses: pypa/[email protected]
127+
with:
128+
output-dir: ./wheelhouse
22129

23-
- uses: actions/upload-artifact@v4
130+
- name: Upload wheels
131+
if: ${{ steps.check_build.outputs.build_needed == 'true' }}
132+
uses: actions/upload-artifact@v4
24133
with:
134+
name: wheels-macos-latest
25135
path: ./wheelhouse/*.whl
26136
overwrite: true
27137

28138
build_sdist:
29139
name: Build source distribution
30140
runs-on: ubuntu-latest
31141
steps:
142+
- name: Check if build is needed
143+
id: check_build
144+
run: |
145+
if [ "${{ github.event_name }}" = "push" ]; then
146+
echo "build_needed=true" >> $GITHUB_OUTPUT
147+
elif [ "${{ github.event.inputs.os_choice }}" = "all" ] || [ "${{ github.event.inputs.os_choice }}" = "sdist-only" ]; then
148+
echo "build_needed=true" >> $GITHUB_OUTPUT
149+
else
150+
echo "build_needed=false" >> $GITHUB_OUTPUT
151+
fi
152+
32153
- uses: actions/checkout@v4
154+
if: ${{ steps.check_build.outputs.build_needed == 'true' }}
155+
156+
- name: Set up Python 3.11
157+
if: ${{ steps.check_build.outputs.build_needed == 'true' }}
158+
uses: actions/setup-python@v5
159+
with:
160+
python-version: 3.11
161+
162+
- name: Install build dependencies
163+
if: ${{ steps.check_build.outputs.build_needed == 'true' }}
164+
run: python -m pip install --upgrade pip build
33165

34166
- name: Build sdist
35-
run: pipx run build --sdist
167+
if: ${{ steps.check_build.outputs.build_needed == 'true' }}
168+
run: python -m build --sdist
36169

37-
- uses: actions/upload-artifact@v4
170+
- name: Upload sdist
171+
if: ${{ steps.check_build.outputs.build_needed == 'true' }}
172+
uses: actions/upload-artifact@v4
38173
with:
174+
name: sdist
39175
path: dist/*.tar.gz
176+
overwrite: true
40177

41178
upload_pypi:
42-
needs: [build_wheels, build_sdist]
179+
name: Upload to PyPI
180+
needs:
181+
- build_wheels_ubuntu
182+
- build_wheels_windows
183+
- build_wheels_macos
184+
- build_sdist
43185
runs-on: ubuntu-latest
44-
# upload to PyPI on every tag starting with 'v'
45-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
46-
# alternatively, to publish when a GitHub Release is created, use the following rule:
47-
# if: github.event_name == 'release' && github.event.action == 'published'
186+
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
48187
steps:
49-
- uses: actions/download-artifact@v4
188+
- name: Download Ubuntu wheels
189+
uses: actions/download-artifact@v4
190+
with:
191+
name: wheels-ubuntu-latest
192+
path: dist/
193+
continue-on-error: true
194+
195+
- name: Download Windows wheels
196+
uses: actions/download-artifact@v4
50197
with:
51-
# unpacks default artifact into dist/
52-
# if `name: artifact` is omitted, the action will create extra parent dir
53-
name: artifact
54-
path: dist
198+
name: wheels-windows-latest
199+
path: dist/
200+
continue-on-error: true
55201

56-
- uses: ncipollo/release-action@v1
202+
- name: Download macOS wheels
203+
uses: actions/download-artifact@v4
57204
with:
58-
artifacts: "dist/*.whl,dist/*.tar.gz"
59-
token: ${{ secrets.GITHUB_TOKEN }}
205+
name: wheels-macos-latest
206+
path: dist/
207+
continue-on-error: true
60208

61-
- uses: pypa/[email protected]
209+
- name: Download sdist
210+
uses: actions/download-artifact@v4
62211
with:
63-
user: __token__
64-
password: ${{ secrets.PYPI_PASSWORD }}
212+
name: sdist
213+
path: dist/
214+
continue-on-error: true
215+
216+
- name: List artifacts (debug)
217+
run: ls dist || echo "No artifacts found."
218+
219+
- name: Upload to PyPI
220+
env:
221+
TWINE_USERNAME: __token__
222+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
223+
run: |
224+
pip install twine
225+
twine upload dist/*

0 commit comments

Comments
 (0)