-
Notifications
You must be signed in to change notification settings - Fork 2
216 lines (189 loc) · 6.69 KB
/
release.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
name: Build + Release Wheels
on:
workflow_dispatch:
inputs:
use_qemu:
description: "Use qemu for builds with targets requiring emulation"
required: true
default: true
llvm_version:
description: "LLVM version to build"
required: false
default: ""
wheel_version:
description: "Version of the wheel packaging (appended to LLVM version)"
required: false
default: "0"
deploy_to_testpypi:
description: "Whether the build should be deployed to test.pypi.org instead regular PyPI"
required: true
default: false
env:
USE_QEMU: ${{ github.event.inputs.use_qemu == 'true' }}
jobs:
build-wheels:
name: Build wheels on ${{ matrix.os }} (arch=${{ matrix.arch }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-22.04
arch: "x86_64"
use_qemu: false
skip: "*manylinux*"
- os: ubuntu-22.04
arch: "x86_64"
use_qemu: false
skip: "*musllinux*"
- os: ubuntu-22.04
arch: "i686"
use_qemu: false
skip: "*manylinux*"
- os: ubuntu-22.04
arch: "i686"
use_qemu: false
skip: "*musllinux*"
# These take too long to build on Github
#- os: ubuntu-20.04
#arch: "aarch64"
#use_qemu: true
#- os: ubuntu-20.04
#arch: "ppc64le"
#use_qemu: true
#- os: ubuntu-20.04
#arch: "s390x"
#use_qemu: true
- os: windows-2022
arch: "AMD64"
use_qemu: false
skip:
- os: windows-2022
arch: "x86"
use_qemu: false
skip:
- os: macos-11
arch: "x86_64"
use_qemu: false
skip:
- os: macos-14
arch: "arm64"
use_qemu: false
skip:
steps:
- uses: actions/checkout@v4
if: (!matrix.use_qemu) || fromJSON(env.USE_QEMU)
- name: Support long paths
if: runner.os == 'Windows' && ((!matrix.use_qemu) || fromJSON(env.USE_QEMU))
run: git config --system core.longpaths true
- name: Export macOS SDKROOT
if: runner.os == 'macOS'
run: echo SDKROOT=$(xcrun --sdk macosx --show-sdk-path) >> $GITHUB_ENV
- name: Override LLVM version (${{ github.event.inputs.llvm_version }})
if: github.event.inputs.llvm_version
run: |
echo "set(CLANG_TIDY_VERSION ${{ github.event.inputs.llvm_version }})" > clang-tidy_version.cmake
echo "set(CLANG_TIDY_WHEEL_VERSION ${{ github.event.inputs.wheel_version }})" >> clang-tidy_version.cmake
- name: Set up QEMU
uses: docker/[email protected]
if: runner.os == 'Linux' && ((matrix.use_qemu) && fromJSON(env.USE_QEMU))
- uses: actions/setup-python@v5
with:
python-version: 3.8
# the pre-installed python 3.8 isn't native and cannot produce ARM64 wheels
# see also https://github.com/pypa/cibuildwheel/pull/1871
if: runner.os == 'macOS' && runner.arch == 'arm64'
- name: Build wheels
uses: pypa/[email protected]
if: (!matrix.use_qemu) || fromJSON(env.USE_QEMU)
env:
CIBW_ARCHS: "${{ matrix.arch }}"
CIBW_BEFORE_TEST: rm -rf {package}/clang_tidy
CIBW_TEST_SKIP: "*linux*"
# always skip PyPY builds + what's defined in the matrix
CIBW_SKIP: "pp* ${{matrix.skip}}"
# clang-tidy simply does not want to cooperate with the github linux image
- name: Test Linux Wheel
if: runner.os == 'Linux' && !(matrix.use_qemu) && matrix.arch == 'x86_64'
run: |
if [[ "${{matrix.skip}}" == "*manylinux*" ]] ; then
docker build --build-arg BASEOS=alpine3.16 --build-arg PLATFORM=musllinux -f .github/workflows/Dockerfile .
else
docker build --build-arg BASEOS=slim-bullseye --build-arg PLATFORM=manylinux -f .github/workflows/Dockerfile .
fi
- name: Set artifact name
id: set_artifact_name
shell: bash -l {0}
run: |
VALUE="archive_wheels_${{ matrix.os }}_${{ matrix.arch }}_${{ matrix.skip }}"
VALUE="${VALUE//\*/}"
echo "value=${VALUE}" >> ${GITHUB_OUTPUT}
- uses: actions/upload-artifact@v4
if: (!matrix.use_qemu) || fromJSON(env.USE_QEMU)
with:
path: ./wheelhouse/*.whl
name: ${{ steps.set_artifact_name.outputs.value }}
build-sdist:
name: Build source distribution
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Override LLVM version (${{ github.event.inputs.llvm_version }})
if: github.event.inputs.llvm_version
run: |
echo "set(CLANG_TIDY_VERSION ${{ github.event.inputs.llvm_version }})" > clang-tidy_version.cmake
echo "set(CLANG_TIDY_WHEEL_VERSION ${{ github.event.inputs.wheel_version }})" >> clang-tidy_version.cmake
- name: Build SDist
run: pipx run build --sdist
- uses: actions/upload-artifact@v4
with:
path: dist/*.tar.gz
name: archive_sdist
test-sdist:
name: Test build from source distribution
needs: [build-sdist]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.9'
- uses: actions/download-artifact@v4
with:
name: archive_sdist
path: sdist
- name: Install from SDist
run: |
# make sure the test will not pick this up
rm -r clang_tidy
pip install sdist/*.tar.gz
- name: Install test requirements
run:
python -m pip install -r requirements-dev.txt
- name: Run test suite
run:
python -m pytest
upload_pypi:
name: Upload to PyPI
needs: [build-wheels, build-sdist, test-sdist]
runs-on: ubuntu-22.04
if: github.repository_owner == 'ssciwr'
steps:
- uses: actions/download-artifact@v4
with:
pattern: archive*
path: dist
merge-multiple: true
- name: Upload to PyPI
uses: pypa/[email protected]
if: github.event.inputs.deploy_to_testpypi == 'false'
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Upload to TestPyPI
uses: pypa/[email protected]
if: github.event.inputs.deploy_to_testpypi == 'true'
with:
user: __token__
password: ${{ secrets.TESTPYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/