-
Notifications
You must be signed in to change notification settings - Fork 28
298 lines (262 loc) · 9.17 KB
/
python-publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
name: Build binary wheels and upload to PyPI
on:
release:
types: [created]
schedule:
# Build nightly at 05:43 UTC
- cron: '43 5 * * *'
workflow_dispatch: # allow running manually from 'Actions' tab
jobs:
build-source-distribution:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
- name: Build
run: python setup.py sdist
- uses: actions/upload-artifact@v2
with:
name: python-package-distributions
path: dist/
build-wheels-manylinux1:
# Note: the 'manylinux1' image will no longer be supported by PyPA
# after 2022-01-01.
# See: https://github.com/pypa/manylinux/issues/994
name: Build wheels on ubuntu-20.04 - x86_64 - manylinux1
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Build Wheels
uses: pypa/[email protected]
env:
CIBW_ARCHS_LINUX: x86_64
CIBW_MANYLINUX_X86_64_IMAGE: manylinux1
CIBW_SKIP: "cp310-*" # manylinux1 has no support for 3.10.x Python
CIBW_ENVIRONMENT: >
CRC32C_PURE_PYTHON="0"
CRC32C_INSTALL_PREFIX="$(pwd)/usr"
CIBW_BUILD_VERBOSITY: 1
# Build the C library inside CIBW so that the manylinux image is
# used to link the share library; otherwise, our extension wouldn't
# be able to link with it.
CIBW_BEFORE_BUILD: >
python -m pip install --upgrade setuptools pip wheel &&
python -m pip install cmake &&
cmake -S google_crc32c -B build \
-DCMAKE_BUILD_TYPE=Release \
-DCRC32C_BUILD_TESTS=no \
-DCRC32C_BUILD_BENCHMARKS=no \
-DBUILD_SHARED_LIBS=yes \
-DCMAKE_INSTALL_PREFIX:PATH=$(pwd)/usr &&
make -C build all install
CIBW_TEST_REQUIRES: pytest
CIBW_TEST_COMMAND: py.test -v {project}/tests/
- uses: actions/upload-artifact@v2
with:
name: python-package-distributions
path: wheelhouse/
build-wheels-linux:
name: Build wheels on ${{ matrix.os }} - ${{ matrix.arch }}
strategy:
matrix:
os:
- ubuntu-20.04
arch:
- x86_64
- i686
- aarch64
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Set up QEMU for ARM64 cross compile
if: ${{ matrix.arch }} == 'aarch64'
id: qemu
uses: docker/setup-qemu-action@v1
- name: Build Wheels
uses: pypa/[email protected]
env:
CIBW_ARCHS_LINUX: ${{ matrix.arch }}
CIBW_ENVIRONMENT: >
CRC32C_PURE_PYTHON="0"
CRC32C_INSTALL_PREFIX="$(pwd)/usr"
CIBW_BUILD_VERBOSITY: 1
# Build the C library inside CIBW so that the manylinux image is
# used to link the share library; otherwise, our extension wouldn't
# be able to link with it.
CIBW_BEFORE_BUILD: >
python -m pip install --upgrade setuptools pip wheel &&
python -m pip install cmake &&
cmake -S google_crc32c -B build \
-DCMAKE_BUILD_TYPE=Release \
-DCRC32C_BUILD_TESTS=no \
-DCRC32C_BUILD_BENCHMARKS=no \
-DBUILD_SHARED_LIBS=yes \
-DCMAKE_INSTALL_PREFIX:PATH=$(pwd)/usr &&
make -C build all install
CIBW_TEST_REQUIRES: pytest
CIBW_TEST_COMMAND: py.test -v {project}/tests/
- uses: actions/upload-artifact@v2
with:
name: python-package-distributions
path: wheelhouse/
build-wheels-macos:
name: Build wheels on ${{ matrix.os }} - ${{ matrix.arch }}
strategy:
matrix:
os:
- macos-10.15
#- macos-11
arch:
- x86_64
- universal2
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Get C library hash
id: get-c-lib-hash
run:
echo "::set-output name=hash::$(git -C google_crc32c log -n 1 --pretty=%H)"
- id: load-cache
name: Load cached C library
uses: actions/cache@v2
with:
path: ${{ github.workspace }}/usr
key:
libcrc32c-${{ matrix.os }}-${{ steps.get-c-lib-hash.outputs.hash }}
- name: Build C Library
if: steps.load-cache.outputs.cache-hit != 'true'
run: >
python -m pip install --upgrade setuptools pip wheel &&
python -m pip install cmake &&
cmake -S google_crc32c -B build \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.9 \
-DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" \
-DCRC32C_BUILD_TESTS=no \
-DCRC32C_BUILD_BENCHMARKS=no \
-DBUILD_SHARED_LIBS=yes \
-DCMAKE_INSTALL_PREFIX:PATH=${{ github.workspace }}/usr \
-DCMAKE_INSTALL_NAME_DIR:PATH=${{ github.workspace }}/usr/lib &&
make -C build all install
- name: Build Wheels
uses: pypa/[email protected]
env:
CIBW_ARCHS_MACOS: ${{ matrix.arch }}
CIBW_ENVIRONMENT: >
CRC32C_PURE_PYTHON="0"
CRC32C_INSTALL_PREFIX="$(pwd)/usr"
CIBW_BUILD_VERBOSITY: 1
CIBW_TEST_REQUIRES: pytest
CIBW_TEST_COMMAND: py.test -v {project}/tests/
- uses: actions/upload-artifact@v2
with:
name: python-package-distributions
path: wheelhouse/
build-wheels-windows:
name: Build wheels on ${{ matrix.os }} ( ${{ matrix.platform }} )
strategy:
matrix:
os:
- windows-2019
platform:
- x64
- Win32
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Get C library hash
id: get-c-lib-hash
run:
echo "::set-output name=hash::$(git -C google_crc32c log -n 1 --pretty=%H)"
- id: load-cache
name: Load cached C library
uses: actions/cache@v2
with:
path: ${{ github.workspace }}\usr
key:
libcrc32c-${{ matrix.os }}-${{ matrix.platform }}-${{ steps.get-c-lib-hash.outputs.hash }}
- name: Build C Library
if: steps.load-cache.outputs.cache-hit != 'true'
run: |
python -m pip install --upgrade setuptools pip wheel
python -m pip install cmake
cmake -S google_crc32c -B build -G "Visual Studio 16 2019" -A ${{ matrix.platform }} -DCRC32C_BUILD_BENCHMARKS=no -DCRC32C_BUILD_TESTS=no -DBUILD_SHARED_LIBS=no -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=yes -DCRC32C_USE_GLOG=0
cmake --build build --verbose --config Release
cmake --install build --verbose --config Release --prefix=${{ github.workspace }}\usr\
# Passing through ${{ github.workspace }} to CIBW_ENVIRONMENT mangles
# backslashes: compute a variant which uses only forward-slashses.
- id: crc32c-install-prefix
name: Dead-reckon a CIBW-compatible install prefix
shell: bash
run: |
python -c "import os; workspace = '/'.join(os.getenv('GITHUB_WORKSPACE').split(os.sep)); pfx = f'{workspace}/usr'; print(f'::set-output name=prefix::{pfx}')"
- id: platform-arch
name: Map platform -> wheel arch
shell: bash
run: |
if [[ "${{ matrix.platform }}" == "Win32" ]]; then
echo "::set-output name=arch::x86"
else
echo "::set-output name=arch::AMD64"
fi
- name: Build Wheels
uses: pypa/[email protected]
env:
CIBW_ARCHS_WINDOWS: ${{ steps.platform-arch.outputs.arch }}
CIBW_ENVIRONMENT: >
CRC32C_INSTALL_PREFIX="${{ steps.crc32c-install-prefix.outputs.prefix }}"
CRC32C_PURE_PYTHON="0"
CIBW_BUILD_VERBOSITY: 1
CIBW_TEST_REQUIRES: pytest
CIBW_TEST_COMMAND: py.test -v {project}/tests
- uses: actions/upload-artifact@v2
with:
name: python-package-distributions
path: wheelhouse/
publish:
if: github.event_name == 'release'
needs:
- build-source-distribution
- build-wheels-manylinux1
- build-wheels-linux
- build-wheels-macos
- build-wheels-windows
runs-on: ubuntu-latest
steps:
- name: Download all the dists
uses: actions/download-artifact@v2
with:
name: python-package-distributions
path: dist/
- name: Download all the wheels
uses: actions/download-artifact@v2
with:
name: python-package-distributions
path: wheelhouse/
- name: What will we publish?
run: ls wheelhouse/
- name: Publish Source Distribution
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
packages_dir: dist/
skip_existing: true
# repository_url: https://test.pypi.org/legacy/
- name: Publish Wheels
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
packages_dir: wheelhouse/
skip_existing: true
# repository_url: https://test.pypi.org/legacy/