Skip to content

Commit b078b7d

Browse files
Upload dev wheels to Anaconda.org + revamp wheels publishing workflow (#714)
* Revamp wheels publishing + add Anaconda deployment * Refine workflow run contexts and conditions * Ensure unique artifact names, via identifiers
1 parent 310fab5 commit b078b7d

File tree

1 file changed

+98
-63
lines changed

1 file changed

+98
-63
lines changed

.github/workflows/wheel_tests_and_release.yml

Lines changed: 98 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,22 @@ on:
44
tags:
55
- "v*"
66
- "buildwheels*"
7+
branches:
8+
# Runs on every merge to master to upload .dev0 wheels to anaconda.org
9+
- master
10+
- v1.**
11+
# Make it possible to upload wheels manually if needed
12+
workflow_dispatch:
13+
inputs:
14+
push_wheels:
15+
description: >
16+
'Push wheels to Anaconda if "true". Default is "false". Warning: this will overwrite existing wheels.'
17+
required: false
18+
default: "false"
19+
# Upload wheels to anaconda.org on a schedule
20+
schedule:
21+
# Run at 0300 hours on days 3 and 17 of the month
22+
- cron: "0 3 3,17 * *"
723
env:
824
CIBW_BUILD_VERBOSITY: 2
925
# CIBW_BEFORE_BUILD: pip install cython
@@ -19,33 +35,32 @@ jobs:
1935
fail-fast: false
2036
matrix:
2137
os: [ubuntu-latest]
22-
cibw_python: ["cp39-*", "cp310-*", "cp311-*", "cp312-*"]
38+
cibw_python: ["cp39", "cp310", "cp311", "cp312"]
2339
cibw_manylinux: [manylinux2014]
2440
cibw_arch: ["x86_64"]
2541
steps:
26-
- uses: actions/checkout@v4
42+
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
2743
with:
2844
fetch-depth: 0
2945
- uses: actions/setup-python@v5
3046
name: Install Python
3147
with:
3248
python-version: "3.9"
33-
- name: Install cibuildwheel
34-
run: |
35-
python -m pip install cibuildwheel
3649
- name: Build the wheel
37-
run: |
38-
python -m cibuildwheel --output-dir dist
50+
uses: pypa/cibuildwheel@8d945475ac4b1aac4ae08b2fd27db9917158b6ce # 2.17.0
51+
with:
52+
output-dir: dist
3953
env:
40-
CIBW_BUILD: ${{ matrix.cibw_python }}
54+
CIBW_BUILD: ${{ matrix.cibw_python }}-*
4155
CIBW_ARCHS_LINUX: ${{ matrix.cibw_arch }}
4256
CIBW_SKIP: "*-musllinux_*"
4357
CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.cibw_manylinux }}
4458
CIBW_MANYLINUX_I686_IMAGE: "manylinux2010"
45-
- uses: actions/upload-artifact@v4
59+
- uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
4660
with:
47-
name: wheels
61+
name: wheels_linux_${{ matrix.cibw_arch }}_${{ matrix.cibw_python }}_manylinux2014
4862
path: ./dist/*.whl
63+
if-no-files-found: error
4964

5065
build_linux_aarch64_wheels:
5166
name: Build python ${{ matrix.cibw_python }} aarch64 wheels on ${{ matrix.os }}
@@ -54,10 +69,11 @@ jobs:
5469
fail-fast: false
5570
matrix:
5671
os: [ubuntu-latest]
57-
cibw_python: ["cp39-*", "cp310-*", "cp311-*", "cp312-*"]
72+
cibw_python: ["cp39", "cp310", "cp311", "cp312"]
5873
cibw_manylinux: [manylinux2014]
74+
cibw_arch: ["aarch64"]
5975
steps:
60-
- uses: actions/checkout@v4
76+
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
6177
with:
6278
fetch-depth: 0
6379
- uses: actions/setup-python@v5
@@ -68,20 +84,18 @@ jobs:
6884
uses: docker/setup-qemu-action@v3
6985
with:
7086
platforms: arm64
71-
- name: Install cibuildwheel
72-
run: |
73-
python -m pip install cibuildwheel
7487
- name: Build the wheel
75-
run: |
76-
python -m cibuildwheel --output-dir dist
88+
uses: pypa/cibuildwheel@8d945475ac4b1aac4ae08b2fd27db9917158b6ce # 2.17.0
89+
with:
90+
output-dir: dist
7791
env:
78-
CIBW_BUILD: ${{ matrix.cibw_python }}
79-
CIBW_ARCHS_LINUX: aarch64
92+
CIBW_BUILD: ${{ matrix.cibw_python }}-*
93+
CIBW_ARCHS_LINUX: ${{ matrix.cibw_arch }}
8094
CIBW_SKIP: "*-musllinux_*"
8195
CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.cibw_manylinux }}
82-
- uses: actions/upload-artifact@v4
96+
- uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
8397
with:
84-
name: wheels
98+
name: wheels_linux_${{ matrix.cibw_arch }}_${{ matrix.cibw_python }}_manylinux2014
8599
path: ./dist/*.whl
86100

87101
build_macos_wheels:
@@ -91,10 +105,10 @@ jobs:
91105
fail-fast: false
92106
matrix:
93107
os: [macos-latest]
94-
cibw_python: ["cp39-*", "cp310-*", "cp311-*", "cp312-*"]
108+
cibw_python: ["cp39", "cp310", "cp311", "cp312"]
95109
cibw_arch: ["x86_64", "arm64"]
96110
steps:
97-
- uses: actions/checkout@v4
111+
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
98112
with:
99113
fetch-depth: 0
100114

@@ -103,33 +117,19 @@ jobs:
103117
with:
104118
python-version: "3.9"
105119

106-
- name: Install cibuildwheel
107-
run: |
108-
python -m pip install cibuildwheel
109-
110-
- name: Build wheels for CPython (MacOS)
111-
run: |
112-
# We need to set both MACOS_DEPLOYMENT_TARGET and MACOSX_DEPLOYMENT_TARGET
113-
# until there is a new release with this commit:
114-
# https://github.com/mesonbuild/meson-python/pull/309 (should be in 0.13.0)
115-
if [[ "$CIBW_ARCHS_MACOS" == arm64 ]]; then
116-
export MACOSX_DEPLOYMENT_TARGET=11.0
117-
export MACOS_DEPLOYMENT_TARGET=11.0
118-
else
119-
export MACOSX_DEPLOYMENT_TARGET=10.13
120-
export MACOS_DEPLOYMENT_TARGET=10.13
121-
fi
122-
echo MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET}
123-
124-
python -m cibuildwheel --output-dir dist
120+
- name: Build wheels for CPython (macOS)
121+
uses: pypa/cibuildwheel@8d945475ac4b1aac4ae08b2fd27db9917158b6ce # 2.17.0
122+
with:
123+
output-dir: dist
125124
env:
126-
CIBW_BUILD: ${{ matrix.cibw_python }}
125+
CIBW_BUILD: ${{ matrix.cibw_python }}-*
127126
CIBW_ARCHS_MACOS: ${{ matrix.cibw_arch }}
128127

129-
- uses: actions/upload-artifact@v4
128+
- uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
130129
with:
131-
name: wheels
130+
name: wheels_macos_${{ matrix.cibw_arch }}_${{ matrix.cibw_python }}
132131
path: ./dist/*.whl
132+
if-no-files-found: error
133133

134134
build_windows_wheels:
135135
name: Build ${{ matrix.cibw_python }} ${{ matrix.cibw_arch }} wheels on ${{ matrix.os }}
@@ -139,9 +139,9 @@ jobs:
139139
matrix:
140140
os: [windows-latest]
141141
cibw_arch: ["AMD64", "x86"]
142-
cibw_python: ["cp39-*", "cp310-*", "cp311-*", "cp312-*"]
142+
cibw_python: ["cp39", "cp310", "cp311", "cp312"]
143143
steps:
144-
- uses: actions/checkout@v4
144+
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
145145
with:
146146
fetch-depth: 0
147147

@@ -150,10 +150,6 @@ jobs:
150150
with:
151151
python-version: "3.9"
152152

153-
- name: Install cibuildwheel
154-
run: |
155-
python -m pip install cibuildwheel
156-
157153
- name: Setup MSVC (32-bit)
158154
if: matrix.cibw_arch == 'x86'
159155
uses: bus1/cabuild/action/msdevshell@e22aba57d6e74891d059d66501b6b5aed8123c4d # v1
@@ -167,30 +163,33 @@ jobs:
167163
architecture: x64
168164

169165
- name: Build Windows wheels for CPython
170-
run: |
171-
python -m cibuildwheel --output-dir dist
166+
uses: pypa/cibuildwheel@8d945475ac4b1aac4ae08b2fd27db9917158b6ce # 2.17.0
167+
with:
168+
output-dir: dist
172169
env:
173-
CIBW_BUILD: ${{ matrix.cibw_python }}
170+
CIBW_BUILD: ${{ matrix.cibw_python }}-*
174171
CIBW_ARCHS_WINDOWS: ${{ matrix.cibw_arch }}
175172

176-
- uses: actions/upload-artifact@v4
173+
- uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
177174
with:
178-
name: wheels
175+
name: wheels_windows_${{ matrix.cibw_arch }}_${{ matrix.cibw_python }}
179176
path: ./dist/*.whl
177+
if-no-files-found: error
180178

181-
deploy:
182-
name: Release
179+
deploy_pypi:
180+
name: Release (PyPI)
183181
needs:
184182
[
185183
build_linux_x86_64_wheels,
186184
build_linux_aarch64_wheels,
187185
build_macos_wheels,
188186
build_windows_wheels,
189187
]
190-
if: github.repository_owner == 'PyWavelets' && startsWith(github.ref, 'refs/tags/v') && always()
188+
# Run only on tags pushed to the repository
189+
if: github.repository == 'PyWavelets/pywt' && startsWith(github.ref, 'refs/tags/v')
191190
runs-on: ubuntu-latest
192191
steps:
193-
- uses: actions/checkout@v4
192+
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
194193
with:
195194
fetch-depth: 0
196195

@@ -204,11 +203,13 @@ jobs:
204203
python -m pip install --upgrade pip
205204
pip install twine
206205
pip install cython numpy build
207-
- uses: actions/download-artifact@v4
206+
207+
- uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4
208208
id: download
209209
with:
210-
name: wheels
210+
pattern: "wheels_*"
211211
path: ./dist
212+
merge-multiple: true
212213

213214
- name: Publish the source distribution on PyPI
214215
run: |
@@ -224,7 +225,41 @@ jobs:
224225
TWINE_PASSWORD: ${{ secrets.TWINE_TOKEN }}
225226

226227
- name: Github release
227-
uses: softprops/action-gh-release@v2
228+
uses: softprops/action-gh-release@d99959edae48b5ffffd7b00da66dcdb0a33a52ee # v2.0.2
228229
env:
229230
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
230231
GITHUB_REPOSITORY: ${{ github.repository }}
232+
233+
deploy_anaconda:
234+
name: Release (Anaconda)
235+
needs:
236+
[
237+
build_linux_x86_64_wheels,
238+
build_linux_aarch64_wheels,
239+
build_macos_wheels,
240+
build_windows_wheels,
241+
]
242+
# Run only on pushes to the master branch, on schedule, or when triggered manually
243+
if: >-
244+
github.repository == 'PyWavelets/pywt' &&
245+
(github.event_name == 'push' && github.ref == 'refs/heads/master') ||
246+
(github.event_name == 'workflow_dispatch' && github.event.inputs.push_wheels == 'true') ||
247+
(github.event_name == 'schedule')
248+
runs-on: ubuntu-latest
249+
steps:
250+
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
251+
with:
252+
fetch-depth: 0
253+
254+
- uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4
255+
id: download
256+
with:
257+
pattern: "*_wheels"
258+
path: dist/
259+
merge-multiple: true
260+
261+
- name: Push to Anaconda PyPI index
262+
uses: scientific-python/upload-nightly-action@b67d7fcc0396e1128a474d1ab2b48aa94680f9fc # v0.5.0
263+
with:
264+
artifacts_path: dist/
265+
anaconda_nightly_upload_token: ${{ secrets.ANACONDA_ORG_UPLOAD_TOKEN }}

0 commit comments

Comments
 (0)