Skip to content

Commit c7ee8d6

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

1 file changed

Lines changed: 189 additions & 26 deletions

File tree

.github/workflows/wheels-deploy.yml

Lines changed: 189 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,60 +5,223 @@ 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/cibuildwheel@v2.21.1
50+
with:
51+
output-dir: ./wheelhouse
1652

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
1764
steps:
65+
- name: Check if build is needed
66+
id: check_build
67+
shell: bash
68+
run: |
69+
if [ "${{ github.event_name }}" = "push" ]; then
70+
echo "build_needed=true" >> $GITHUB_OUTPUT
71+
elif [ "${{ github.event_name }}" = "workflow_dispatch" ] && { [ "${{ github.event.inputs.os_choice }}" = "all" ] || [ "${{ github.event.inputs.os_choice }}" = "windows-latest" ]; }; then
72+
echo "build_needed=true" >> $GITHUB_OUTPUT
73+
else
74+
echo "build_needed=false" >> $GITHUB_OUTPUT
75+
fi
76+
77+
1878
- uses: actions/checkout@v4
79+
if: ${{ steps.check_build.outputs.build_needed == 'true' }}
80+
81+
- name: Set up Python 3.11
82+
if: ${{ steps.check_build.outputs.build_needed == 'true' }}
83+
uses: actions/setup-python@v5
84+
with:
85+
python-version: 3.11
1986

2087
- name: Build wheels
88+
if: ${{ steps.check_build.outputs.build_needed == 'true' }}
2189
uses: pypa/cibuildwheel@v2.21.1
90+
with:
91+
output-dir: ./wheelhouse
2292

23-
- uses: actions/upload-artifact@v4
93+
- name: Upload wheels
94+
if: ${{ steps.check_build.outputs.build_needed == 'true' }}
95+
uses: actions/upload-artifact@v4
2496
with:
97+
name: wheels-windows-latest
98+
path: ./wheelhouse/*.whl
99+
overwrite: true
100+
101+
build_wheels_macos:
102+
name: Build wheels on macos-latest
103+
runs-on: macos-latest
104+
steps:
105+
- name: Check if build is needed
106+
id: check_build
107+
shell: bash
108+
run: |
109+
if [ "${{ github.event_name }}" = "push" ]; then
110+
echo "build_needed=true" >> $GITHUB_OUTPUT
111+
elif [ "${{ github.event.inputs.os_choice }}" = "all" ] || [ "${{ github.event.inputs.os_choice }}" = "macos-latest" ]; then
112+
echo "build_needed=true" >> $GITHUB_OUTPUT
113+
else
114+
echo "build_needed=false" >> $GITHUB_OUTPUT
115+
fi
116+
117+
- uses: actions/checkout@v4
118+
if: ${{ steps.check_build.outputs.build_needed == 'true' }}
119+
120+
- name: Set up Python 3.11
121+
if: ${{ steps.check_build.outputs.build_needed == 'true' }}
122+
uses: actions/setup-python@v5
123+
with:
124+
python-version: 3.11
125+
126+
- name: Build wheels
127+
if: ${{ steps.check_build.outputs.build_needed == 'true' }}
128+
uses: pypa/cibuildwheel@v2.21.1
129+
with:
130+
output-dir: ./wheelhouse
131+
132+
- name: Upload wheels
133+
if: ${{ steps.check_build.outputs.build_needed == 'true' }}
134+
uses: actions/upload-artifact@v4
135+
with:
136+
name: wheels-macos-latest
25137
path: ./wheelhouse/*.whl
26138
overwrite: true
27139

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

34168
- name: Build sdist
35-
run: pipx run build --sdist
169+
if: ${{ steps.check_build.outputs.build_needed == 'true' }}
170+
run: python -m build --sdist
36171

37-
- uses: actions/upload-artifact@v4
172+
- name: Upload sdist
173+
if: ${{ steps.check_build.outputs.build_needed == 'true' }}
174+
uses: actions/upload-artifact@v4
38175
with:
176+
name: sdist
39177
path: dist/*.tar.gz
178+
overwrite: true
40179

41180
upload_pypi:
42-
needs: [build_wheels, build_sdist]
181+
name: Upload to PyPI
182+
needs:
183+
- build_wheels_ubuntu
184+
- build_wheels_windows
185+
- build_wheels_macos
186+
- build_sdist
43187
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'
188+
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
48189
steps:
49-
- uses: actions/download-artifact@v4
190+
- name: Download Ubuntu wheels
191+
uses: actions/download-artifact@v4
192+
with:
193+
name: wheels-ubuntu-latest
194+
path: dist/
195+
continue-on-error: true
196+
197+
- name: Download Windows wheels
198+
uses: actions/download-artifact@v4
50199
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
200+
name: wheels-windows-latest
201+
path: dist/
202+
continue-on-error: true
55203

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

61-
- uses: pypa/gh-action-pypi-publish@v1.10.2
211+
- name: Download sdist
212+
uses: actions/download-artifact@v4
62213
with:
63-
user: __token__
64-
password: ${{ secrets.PYPI_PASSWORD }}
214+
name: sdist
215+
path: dist/
216+
continue-on-error: true
217+
218+
- name: List artifacts (debug)
219+
run: ls dist || echo "No artifacts found."
220+
221+
- name: Upload to PyPI
222+
env:
223+
TWINE_USERNAME: __token__
224+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
225+
run: |
226+
pip install twine
227+
twine upload dist/*

0 commit comments

Comments
 (0)