-
Notifications
You must be signed in to change notification settings - Fork 10
364 lines (343 loc) · 15.6 KB
/
release-wheel.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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
name: Release Wheel
permissions:
contents: read
on:
workflow_dispatch:
inputs:
version:
description: The version to build
env:
PYPI_NAME: tongsuopy
TONGSUO_VERSION: 8.3.2
INNER_WORKSPACE: /workspace
INNER_BUILD_DIR: /build
jobs:
sdist:
runs-on: ubuntu-latest
name: sdists
steps:
- uses: actions/[email protected]
with:
# The tag to build or the tag received by the tag event
ref: ${{ github.event.inputs.version || github.ref }}
persist-credentials: false
- run: python -m venv .venv
- name: Install Python dependencies
run: .venv/bin/pip install -U pip cffi
- name: Make sdist
run: .venv/bin/python setup.py sdist
- uses: actions/[email protected]
with:
name: "tongsuopy-sdist"
path: dist/tongsuopy*
manylinux:
needs: [sdist]
runs-on: ubuntu-latest
container:
image: ghcr.io/tongsuo-project/${{ matrix.MANYLINUX.CONTAINER }}
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
strategy:
fail-fast: false
matrix:
PYTHON:
- { VERSION: "cp36-cp36m", ABI_VERSION: 'cp36' }
- { VERSION: "pp38-pypy38_pp73" }
- { VERSION: "pp39-pypy39_pp73" }
MANYLINUX:
- { NAME: "manylinux2014_x86_64", CONTAINER: "tongsuopy-manylinux2014:x86_64" }
- { NAME: "manylinux_2_24_x86_64", CONTAINER: "tongsuopy-manylinux_2_24:x86_64"}
- { NAME: "manylinux_2_28_x86_64", CONTAINER: "tongsuopy-manylinux_2_28:x86_64"}
- { NAME: "musllinux_1_1_x86_64", CONTAINER: "tongsuopy-musllinux_1_1:x86_64"}
exclude:
# There are no readily available PyPy distributions
- PYTHON: { VERSION: "pp38-pypy38_pp73" }
MANYLINUX: { NAME: "musllinux_1_1_x86_64", CONTAINER: "tongsuopy-musllinux_1_1:x86_64"}
- PYTHON: { VERSION: "pp39-pypy39_pp73" }
MANYLINUX: { NAME: "musllinux_1_1_x86_64", CONTAINER: "tongsuopy-musllinux_1_1:x86_64"}
name: "${{ matrix.PYTHON.VERSION }} for ${{ matrix.MANYLINUX.NAME }}"
steps:
- uses: actions/[email protected]
with:
name: tongsuopy-sdist
- run: /opt/python/${{ matrix.PYTHON.VERSION }}/bin/python -m venv .venv
- name: Install Python dependencies
run: .venv/bin/pip install -U pip wheel cffi
- run: tar zxvf tongsuopy*.tar.gz && rm tongsuopy*.tar.gz && mkdir tmpwheelhouse
- name: Build the wheel
run: |
if [ -n "${{ matrix.PYTHON.ABI_VERSION }}" ]; then
PY_LIMITED_API="--py-limited-api=${{ matrix.PYTHON.ABI_VERSION }}"
fi
cd tongsuopy*
../.venv/bin/python setup.py bdist_wheel $PY_LIMITED_API && mv dist/tongsuopy*.whl ../tmpwheelhouse
- run: auditwheel repair --plat ${{ matrix.MANYLINUX.NAME }} tmpwheelhouse/tongsuopy*.whl -w wheelhouse/
- run: unzip wheelhouse/*.whl -d execstack.check
- run: |
results=$(readelf -lW execstack.check/tongsuopy/backends/*.so)
count=$(echo "$results" | grep -c 'GNU_STACK.*[R ][W ]E' || true)
if [ "$count" -ne 0 ]; then
exit 1
else
exit 0
fi
- run: .venv/bin/pip install ${{ env.PYPI_NAME }} --no-index -f wheelhouse/
- run: |
.venv/bin/python -c "from tongsuopy.backends.tongsuo.backend import backend;print('Loaded: ' + backend.openssl_version_text());print('Linked Against: ' + backend._ffi.string(backend._lib.OPENSSL_VERSION_TEXT).decode('ascii'))"
- run: mkdir tongsuopy-wheelhouse
- run: mv wheelhouse/tongsuopy*.whl tongsuopy-wheelhouse/
- name: Publish tongsuopy to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
packages_dir: tongsuopy-wheelhouse/
print_hash: true
manylinux-aarch64:
needs: [ sdist ]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
PYTHON:
- { VERSION: "cp36-cp36m", ABI_VERSION: 'cp36' }
- { VERSION: "pp38-pypy38_pp73" }
- { VERSION: "pp39-pypy39_pp73" }
MANYLINUX:
- { NAME: "manylinux2014_aarch64", CONTAINER: "tongsuopy-manylinux2014:aarch64" }
- { NAME: "manylinux_2_24_aarch64", CONTAINER: "tongsuopy-manylinux_2_24:aarch64" }
- { NAME: "manylinux_2_28_aarch64", CONTAINER: "tongsuopy-manylinux_2_28:aarch64" }
- { NAME: "musllinux_1_1_aarch64", CONTAINER: "tongsuopy-musllinux_1_1:aarch64" }
exclude:
# There are no readily available PyPy distributions
- PYTHON: { VERSION: "pp38-pypy38_pp73" }
MANYLINUX: { NAME: "musllinux_1_1_aarch64", CONTAINER: "tongsuopy-musllinux_1_1:aarch64" }
- PYTHON: { VERSION: "pp39-pypy39_pp73" }
MANYLINUX: { NAME: "musllinux_1_1_aarch64", CONTAINER: "tongsuopy-musllinux_1_1:aarch64" }
name: "${{ matrix.PYTHON.VERSION }} for ${{ matrix.MANYLINUX.NAME }}"
steps:
- uses: actions/[email protected]
with:
name: tongsuopy-sdist
path: ${{ github.workspace }}
- uses: uraimo/run-on-arch-action@v2
name: Build artifact
with:
arch: none
distro: none
base_image: --platform=linux/arm64 ghcr.io/tongsuo-project/${{ matrix.MANYLINUX.CONTAINER }}
# Not required, but speeds up builds
githubToken: ${{ secrets.PAT }}
# Mount the artifacts directory as /artifacts in the container
dockerRunArgs: |
--volume "${{ github.workspace }}:${{ env.INNER_WORKSPACE }}"
--volume "${{ runner.temp }}:${{ env.INNER_BUILD_DIR }}"
# Pass some environment variables to the container
env: |
INNER_WORKSPACE: "${{ env.INNER_WORKSPACE }}"
INNER_BUILD_DIR: "${{ env.INNER_BUILD_DIR }}"
PYTHON_VERSION: "${{ matrix.PYTHON.VERSION }}"
PYTHON_ABI_VERSION: "${{ matrix.PYTHON.ABI_VERSION }}"
MANYLINUX_NAME: "${{ matrix.MANYLINUX.NAME }}"
# Produce a binary artifact and place it in the mounted volume
run: |
cd ${INNER_BUILD_DIR}
/opt/python/${PYTHON_VERSION}/bin/python -m venv .venv
.venv/bin/pip install -U pip wheel cffi
cd ${INNER_WORKSPACE}
tar zxvf tongsuopy*.tar.gz && rm tongsuopy*.tar.gz && mkdir tmpwheelhouse
PY_LIMITED_API=""
if [ -n "${PYTHON_ABI_VERSION}" ]; then
PY_LIMITED_API="--py-limited-api=${PYTHON_ABI_VERSION}"
fi
cd tongsuopy*
${INNER_BUILD_DIR}/.venv/bin/python setup.py bdist_wheel ${PY_LIMITED_API} && mv dist/tongsuopy*.whl ../tmpwheelhouse
cd ${INNER_WORKSPACE}
auditwheel repair --plat ${MANYLINUX_NAME} tmpwheelhouse/tongsuopy*.whl -w wheelhouse/
unzip wheelhouse/*.whl -d execstack.check
results=$(readelf -lW execstack.check/tongsuopy/backends/*.so)
count=$(echo "$results" | grep -c 'GNU_STACK.*[R ][W ]E' || true)
echo "count -> ${count}"
if [ "$count" -ne 0 ]; then
exit 1
fi
cd ${INNER_WORKSPACE}
${INNER_BUILD_DIR}/.venv/bin/pip install ${{ env.PYPI_NAME }} --no-index -f wheelhouse/
${INNER_BUILD_DIR}/.venv/bin/python -c "from tongsuopy.backends.tongsuo.backend import backend;print('Loaded: ' + backend.openssl_version_text());print('Linked Against: ' + backend._ffi.string(backend._lib.OPENSSL_VERSION_TEXT).decode('ascii'))"
mkdir tongsuopy-wheelhouse
mv wheelhouse/tongsuopy*.whl tongsuopy-wheelhouse/
- name: Publish tongsuopy to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
packages_dir: ${{ github.workspace }}/tongsuopy-wheelhouse/
print_hash: true
macos:
needs: [sdist]
runs-on: macos-12
strategy:
fail-fast: false
matrix:
PYTHON:
- VERSION: '3.10'
ABI_VERSION: 'cp36'
# Despite the name, this is built for the macOS 11 SDK on arm64 and 10.9+ on intel
DOWNLOAD_URL: 'https://www.python.org/ftp/python/3.10.0/python-3.10.0post2-macos11.pkg'
BIN_PATH: '/Library/Frameworks/Python.framework/Versions/3.10/bin/python3'
DEPLOYMENT_TARGET: '10.12'
# This archflags is default, but let's be explicit
ARCHFLAGS: '-arch x86_64 -arch arm64'
# See https://github.com/pypa/cibuildwheel/blob/c8876b5c54a6c6b08de5d4b1586906b56203bd9e/cibuildwheel/macos.py#L257-L269
# This will change in the future as we change the base Python we
# build against
_PYTHON_HOST_PLATFORM: 'macosx-10.9-universal2'
- VERSION: '3.10'
ABI_VERSION: 'cp36'
DOWNLOAD_URL: 'https://www.python.org/ftp/python/3.10.0/python-3.10.0post2-macos11.pkg'
BIN_PATH: '/Library/Frameworks/Python.framework/Versions/3.10/bin/python3'
DEPLOYMENT_TARGET: '10.12'
# We continue to build a non-universal2 for a bit to see metrics on
# download counts (this is a proxy for pip version since universal2
# requires a 21.x pip)
ARCHFLAGS: '-arch x86_64'
_PYTHON_HOST_PLATFORM: 'macosx-10.9-x86_64'
- VERSION: 'pypy-3.8'
BIN_PATH: 'pypy3'
DEPLOYMENT_TARGET: '10.12'
_PYTHON_HOST_PLATFORM: 'macosx-10.9-x86_64'
ARCHFLAGS: '-arch x86_64'
- VERSION: 'pypy-3.9'
BIN_PATH: 'pypy3'
DEPLOYMENT_TARGET: '10.12'
_PYTHON_HOST_PLATFORM: 'macosx-10.9-x86_64'
ARCHFLAGS: '-arch x86_64'
name: "${{ matrix.PYTHON.VERSION }} ABI ${{ matrix.PYTHON.ABI_VERSION }} macOS ${{ matrix.PYTHON.ARCHFLAGS }}"
steps:
- uses: actions/[email protected]
with:
name: tongsuopy-sdist
- name: Setup python
run: |
curl "$PYTHON_DOWNLOAD_URL" -o python.pkg
sudo installer -pkg python.pkg -target /
env:
PYTHON_DOWNLOAD_URL: ${{ matrix.PYTHON.DOWNLOAD_URL }}
if: contains(matrix.PYTHON.VERSION, 'pypy') == false
- name: Setup pypy
uses: actions/[email protected]
with:
python-version: ${{ matrix.PYTHON.VERSION }}
if: contains(matrix.PYTHON.VERSION, 'pypy')
- name: Set TONGSUO_HOME
shell: bash
run: echo "TONGSUO_HOME=${GITHUB_WORKSPACE}/tongsuo${TONGSUO_VERSION}" >> $GITHUB_ENV
- name: Build Tongsuo
working-directory: ${{ runner.temp }}
run: |
wget "https://github.com/Tongsuo-Project/Tongsuo/archive/refs/tags/${TONGSUO_VERSION}.tar.gz"
tar zxf "${TONGSUO_VERSION}.tar.gz"
cd "Tongsuo-${TONGSUO_VERSION}"
./config no-shared enable-ntls --release --prefix=${TONGSUO_HOME}
make -s -j4
make install_sw
cd -
- run: ${{ matrix.PYTHON.BIN_PATH }} -m venv venv
- run: venv/bin/pip install -U pip wheel cffi twine
- run: tar zxvf tongsuopy*.tar.gz && mkdir wheelhouse
- name: Build the wheel
run: |
cd tongsuopy*
../venv/bin/python setup.py bdist_wheel --py-limited-api=${{ matrix.PYTHON.ABI_VERSION }} && mv dist/tongsuopy*.whl ../wheelhouse
env:
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.PYTHON.DEPLOYMENT_TARGET }}
ARCHFLAGS: ${{ matrix.PYTHON.ARCHFLAGS }}
_PYTHON_HOST_PLATFORM: ${{ matrix.PYTHON._PYTHON_HOST_PLATFORM }}
- run: venv/bin/pip install -f wheelhouse --no-index ${{ env.PYPI_NAME }}
- name: Show the wheel's minimum macOS SDK and architectures
run: |
find venv/lib/*/site-packages/tongsuopy/backends -name '*.so' -exec vtool -show {} \;
- run: |
venv/bin/python -c "from tongsuopy.backends.tongsuo.backend import backend;print('Loaded: ' + backend.openssl_version_text());print('Linked Against: ' + backend._ffi.string(backend._lib.OPENSSL_VERSION_TEXT).decode('ascii'))"
- run: mkdir tongsuopy-wheelhouse
- run: mv wheelhouse/tongsuopy*.whl tongsuopy-wheelhouse/
- name: Publish tongsuopy to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
venv/bin/twine upload --repository pypi tongsuopy-wheelhouse/*
windows:
needs: [sdist]
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
WINDOWS:
- {ARCH: 'x86', WINDOWS: 'win32', CONFIG: 'VC-WIN32'}
- {ARCH: 'x64', WINDOWS: 'win64', CONFIG: 'VC-WIN64A'}
PYTHON:
- {VERSION: "3.8", "ABI_VERSION": "cp36"}
- {VERSION: "pypy-3.8"}
- {VERSION: "pypy-3.9"}
exclude:
# We need to exclude the below configuration because there is no 32-bit pypy3
- WINDOWS: {ARCH: 'x86', WINDOWS: 'win32', CONFIG: 'VC-WIN32'}
PYTHON: {VERSION: "pypy-3.8"}
- WINDOWS: {ARCH: 'x86', WINDOWS: 'win32', CONFIG: 'VC-WIN32'}
PYTHON: {VERSION: "pypy-3.9"}
name: "${{ matrix.PYTHON.VERSION }} ${{ matrix.WINDOWS.WINDOWS }} ${{ matrix.PYTHON.ABI_VERSION }}"
steps:
- uses: actions/[email protected]
with:
name: tongsuopy-sdist
- name: Setup python
uses: actions/[email protected]
with:
python-version: ${{ matrix.PYTHON.VERSION }}
architecture: ${{ matrix.WINDOWS.ARCH }}
- run: choco install -y winrar
- uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.WINDOWS.WINDOWS }}
- uses: ilammy/setup-nasm@v1
with:
platform: ${{ matrix.WINDOWS.WINDOWS }}
- uses: shogo82148/actions-setup-perl@v1
- name: Set Env
shell: bash
run: |
echo "TONGSUO_HOME=${GITHUB_WORKSPACE}\tongsuo${{ env.TONGSUO_VERSION }}" >> $GITHUB_ENV
- name: Download Tongsuo source
run: |
wget "https://github.com/Tongsuo-Project/Tongsuo/archive/refs/tags/${{ env.TONGSUO_VERSION }}.tar.gz" -OutFile "${{ env.TONGSUO_VERSION }}.tar.gz"
shell: powershell
- run: '"C:\Program Files\WinRAR\WinRAR.exe" -INUL x ${{ env.TONGSUO_VERSION }}.tar.gz'
shell: cmd
- name: Build Tongsuo
shell: cmd
run: |
pushd "Tongsuo-${{ env.TONGSUO_VERSION }}"
mkdir _build
pushd _build
perl ..\Configure no-makedepend no-shared enable-ntls ${{ matrix.WINDOWS.CONFIG }} --prefix=%TONGSUO_HOME%
nmake /S
nmake install_sw
popd
popd
- run: python -m pip install -U pip wheel twine
- run: python -m pip install cffi
- run: tar zxvf tongsuopy*.tar.gz && mkdir wheelhouse
shell: bash
- run: cd tongsuopy* && python setup.py bdist_wheel --py-limited-api=${{ matrix.PYTHON.ABI_VERSION }} && mv dist/tongsuopy*.whl ../wheelhouse
- run: pip install -f wheelhouse --no-index ${{ env.PYPI_NAME }}
- name: Print the OpenSSL we built and linked against
run: |
python -c "from tongsuopy.backends.tongsuo.backend import backend;print('Loaded: ' + backend.openssl_version_text());print('Linked Against: ' + backend._ffi.string(backend._lib.OPENSSL_VERSION_TEXT).decode('ascii'))"
- run: mkdir tongsuopy-wheelhouse
- run: move wheelhouse\tongsuopy*.whl tongsuopy-wheelhouse\
- name: Publish tongsuopy to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
twine upload --repository pypi tongsuopy-wheelhouse\*