forked from scylladb/python-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
197 lines (170 loc) · 6.28 KB
/
lib-build-and-push.yml
File metadata and controls
197 lines (170 loc) · 6.28 KB
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
name: Build and upload to PyPi
on:
workflow_call:
inputs:
upload:
description: 'Upload to PyPI'
type: boolean
required: false
default: false
python-version:
description: 'Python version to run on'
type: string
required: false
default: "3.13"
target:
description: "Target os to build for: linux,macos,windows"
type: string
required: false
default: "linux,macos-x86,macos-arm,windows,linux-aarch64"
target_tag:
description: "Publish particular tag"
type: string
required: false
default: ""
ignore_tests:
description: "Don't run tests"
type: boolean
required: false
default: false
jobs:
prepare-matrix:
name: "Prepare matrix to run for ${{ inputs.python-version }} on `${{ inputs.target }}`"
runs-on: ubuntu-24.04
outputs:
matrix: ${{ steps.prepare.outputs.matrix }}
steps:
- name: Prepare matrix json from input matrix list
id: prepare
run: |
echo -n "[" > /tmp/matrix.json
was_added=""
for target in $(echo "${{ inputs.target }}" | tr -d " " | tr "," "\n")
do
if [[ "${target}" == "linux" ]]; then
[ -n "$was_added" ] && echo -n "," >> /tmp/matrix.json
echo -n '{"os":"ubuntu-24.04", "target": "linux"}' >> /tmp/matrix.json
was_added=1
elif [[ "${target}" == "linux-aarch64" ]]; then
[ -n "$was_added" ] && echo -n "," >> /tmp/matrix.json
echo -n '{"os":"ubuntu-24.04-arm", "target": "linux-aarch64"}' >> /tmp/matrix.json
was_added=1
elif [[ "${target}" == "windows" ]]; then
[ -n "$was_added" ] && echo -n "," >> /tmp/matrix.json
echo -n '{"os":"windows-2022", "target": "windows"}' >> /tmp/matrix.json
was_added=1
elif [[ "${target}" == "macos-x86" ]]; then
[ -n "$was_added" ] && echo -n "," >> /tmp/matrix.json
echo -n '{"os":"macos-13", "target": "macos-x86"}' >> /tmp/matrix.json
was_added=1
elif [[ "${target}" == "macos-arm" ]]; then
[ -n "$was_added" ] && echo -n "," >> /tmp/matrix.json
echo -n '{"os":"macos-14", "target": "macos-arm"}' >> /tmp/matrix.json
was_added=1
fi
done
echo -n "]" >> /tmp/matrix.json
echo -e "Resulted matrix json:\n$(cat /tmp/matrix.json)"
echo "matrix=$(cat /tmp/matrix.json)" >> $GITHUB_OUTPUT
build-wheels:
name: Build wheels for ${{ matrix.target }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs: prepare-matrix
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.prepare-matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- name: Checkout tag ${{ inputs.target_tag }}
if: inputs.target_tag != ''
uses: actions/checkout@v4
with:
ref: ${{ inputs.target_tag }}
- name: Disable tests
if: inputs.ignore_tests
shell: bash
run: |
echo "CIBW_TEST_COMMAND=true" >> $GITHUB_ENV;
echo "CIBW_TEST_COMMAND_WINDOWS=(exit 0)" >> $GITHUB_ENV;
echo "CIBW_TEST_SKIP=*" >> $GITHUB_ENV;
echo "CIBW_SKIP=cp2* cp36* pp36* cp37* pp37* cp38* pp38* *i686 *musllinux*" >> $GITHUB_ENV;
echo "CIBW_BUILD=cp3* pp3*" >> $GITHUB_ENV;
echo "CIBW_BEFORE_TEST=true" >> $GITHUB_ENV;
echo "CIBW_BEFORE_TEST_WINDOWS=(exit 0)" >> $GITHUB_ENV;
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
python-version: ${{ inputs.python-version }}
- name: Install cibuildwheel
run: |
uv tool install 'cibuildwheel==2.22.0'
- name: Install OpenSSL for Windows
if: runner.os == 'Windows'
run: |
choco install openssl --version=3.5.1 -f -y --no-progress
- name: Install Conan
if: runner.os == 'Windows'
uses: turtlebrowser/get-conan@main
- name: Configure libev for Windows
if: runner.os == 'Windows'
run: |
conan profile detect
conan install conanfile.py
- name: Install OpenSSL for MacOS
if: runner.os == 'MacOs'
run: |
brew install libev
- name: Overwrite for MacOS
if: runner.os == 'MacOS'
run: |
##### Set MACOSX_DEPLOYMENT_TARGET
if [ "${{ matrix.os }}" == "macos-13" ]; then
echo "MACOSX_DEPLOYMENT_TARGET=13.0" >> $GITHUB_ENV;
echo "Enforcing target deployment for 13.0"
elif [ "${{ matrix.os }}" == "macos-14" ]; then
echo "MACOSX_DEPLOYMENT_TARGET=14.0" >> $GITHUB_ENV;
echo "Enforcing target deployment for 14.0"
fi
- name: Build wheels
if: matrix.target != 'linux-aarch64'
shell: bash
run: |
GITHUB_WORKFLOW_REF="scylladb/python-driver/.github/workflows/lib-build-and-push.yml@refs/heads/master" cibuildwheel --output-dir wheelhouse
- name: Build wheels for linux aarch64
if: matrix.target == 'linux-aarch64'
run: |
GITHUB_WORKFLOW_REF="scylladb/python-driver/.github/workflows/lib-build-and-push.yml@refs/heads/master" CIBW_BUILD="cp3*" cibuildwheel --archs aarch64 --output-dir wheelhouse
- uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.target }}-${{ matrix.os }}
path: ./wheelhouse/*.whl
build-sdist:
name: Build source distribution
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
python-version: ${{ inputs.python-version }}
- name: Build sdist
run: uv build --sdist
- uses: actions/upload-artifact@v4
with:
name: source-dist
path: dist/*.tar.gz
upload_pypi:
if: inputs.upload
needs: [build-wheels, build-sdist]
runs-on: ubuntu-24.04
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true