-
Notifications
You must be signed in to change notification settings - Fork 6
262 lines (218 loc) · 8.29 KB
/
build_wheels.yml
File metadata and controls
262 lines (218 loc) · 8.29 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
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
name: Build and Publish Wheels
on: [workflow_dispatch]
env:
USING_PYTHON_VERSION: '3.13.9'
jobs:
prepare:
runs-on: tenki-standard-autoscale
outputs:
LATEST_TDLIB_VERSION: ${{ steps.vars.outputs.LATEST_TDLIB_VERSION }}
LATEST_TDLIB_COMMIT_HASH: ${{ steps.vars.outputs.LATEST_TDLIB_COMMIT_HASH }}
PYPI_RELEASE_VERSION: ${{ steps.vars.outputs.PYPI_RELEASE_VERSION }}
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.USING_PYTHON_VERSION }}
- name: Install dependencies
run: python -m pip install --upgrade packaging requests
- name: Fetch TDLib version and commit hash
id: vars
run: |
LATEST_TDLIB_COMMIT_HASH=$(git ls-remote https://github.com/tdlib/td.git refs/heads/master | cut -f1)
LATEST_TDLIB_VERSION=$(curl -s "https://raw.githubusercontent.com/tdlib/td/$LATEST_TDLIB_COMMIT_HASH/CMakeLists.txt" | grep -oP 'project\(TDLib VERSION \K[0-9\.]+')
PYPI_RELEASE_VERSION=$(python next_version.py $LATEST_TDLIB_VERSION)
echo "LATEST_TDLIB_COMMIT_HASH=$LATEST_TDLIB_COMMIT_HASH" >> $GITHUB_OUTPUT
echo "LATEST_TDLIB_VERSION=$LATEST_TDLIB_VERSION" >> $GITHUB_OUTPUT
echo "PYPI_RELEASE_VERSION=$PYPI_RELEASE_VERSION" >> $GITHUB_OUTPUT
- name: Apply version changes
run: |
LATEST_TDLIB_VERSION=${{ steps.vars.outputs.LATEST_TDLIB_VERSION }}
PYPI_RELEASE_VERSION=${{ steps.vars.outputs.PYPI_RELEASE_VERSION }}
sed -i -r "s/^__version__ = \".*\"/__version__ = \"$PYPI_RELEASE_VERSION\"/" tdjson/_version.py
sed -i -r "s|(https://img.shields.io/badge/TDLib-v)[0-9\.]+(-blue)|\\1$LATEST_TDLIB_VERSION\\2|" README.md
- name: Upload updated files
uses: actions/upload-artifact@v4
with:
name: updated-files
path: |
tdjson/_version.py
README.md
linux-build:
needs: prepare
strategy:
matrix:
runner: [tenki-standard-autoscale, ubuntu-24.04-arm]
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v4
- name: Download updated files
uses: actions/download-artifact@v4
with:
name: updated-files
path: .
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.USING_PYTHON_VERSION }}
- name: Install dependencies
run: python -m pip install --upgrade scikit-build-core nanobind build ninja cibuildwheel auditwheel
- name: Build wheels
run: |
mkdir -p ./wheelhouse
python -m cibuildwheel . --output-dir ./wheelhouse
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.runner }}
path: ./wheelhouse/*.whl
windows-build:
needs: prepare
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
- name: Download updated files
uses: actions/download-artifact@v4
with:
name: updated-files
path: .
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.USING_PYTHON_VERSION }}
- name: Install Python dependencies
shell: bash
run: python -m pip install --upgrade cibuildwheel
- name: Build TDLib
shell: bash
run: |
git clone --depth 1 https://github.com/tdlib/td.git
cd td
sed -i '
/^if[[:space:]]*(NOT CMAKE_CROSSCOMPILING)[[:space:]]*$/{
N
s/^if[[:space:]]*(NOT CMAKE_CROSSCOMPILING)[[:space:]]*\n[[:space:]]*add_executable(tg_cli /if (FALSE)\n add_executable(tg_cli /
}
' CMakeLists.txt
sed -i '
s/^[[:space:]]*add_subdirectory(benchmark)[[:space:]]*$/# add_subdirectory(benchmark)/;
s/^[[:space:]]*add_subdirectory(test)[[:space:]]*$/# add_subdirectory(test)/
' CMakeLists.txt
cat << EOF > vcpkg.json
{
"dependencies": [ "gperf", "openssl", "zlib" ],
"builtin-baseline": "afb2279ad78a7c29b5293d989b9a1a2ca00000cf",
"overrides": [
{ "name": "openssl", "version": "1.1.1m" }
]
}
EOF
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.bat
cd ..
rm -rf build
mkdir build
cd build
cmake -A x64 -DCMAKE_INSTALL_PREFIX:PATH=../tdlib -DCMAKE_TOOLCHAIN_FILE:FILEPATH=../vcpkg/scripts/buildsystems/vcpkg.cmake ..
cmake --build . --target install --config Release -j3
cd ../..
ls -l td/tdlib
echo "${{ github.workspace }}/td/tdlib/bin" >> $GITHUB_PATH
- name: Build wheels
shell: bash
env:
CMAKE_PREFIX_PATH: ${{ github.workspace }}/td/tdlib
run: |
mkdir -p ./wheelhouse
python -m cibuildwheel . --output-dir ./wheelhouse
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-windows
path: ./wheelhouse/*.whl
macos-build:
needs: prepare
runs-on: tenki-macos-latest-small
env:
MACOSX_DEPLOYMENT_TARGET: "11.0"
steps:
- uses: actions/checkout@v4
- name: Download updated files
uses: actions/download-artifact@v4
with:
name: updated-files
path: .
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.USING_PYTHON_VERSION }}
- name: Install Python dependencies
run: python -m pip install --upgrade cibuildwheel
- name: Build OpenSSL 1.1.1
run: |
sudo -E git clone --depth 1 --branch OpenSSL_1_1_1-stable https://github.com/openssl/openssl.git
cd openssl
sudo -E perl ./Configure darwin64-arm64-cc --prefix=/usr/local --openssldir=/usr/local/openssl
sudo -E make -j
sudo -E make install MANDIR=/usr/local/openssl/share/man MANSUFFIX=ssl
- name: Build TDLib
run: |
git clone https://github.com/tdlib/td.git
cd td
sed -i '' '
/^if[[:space:]]*(NOT CMAKE_CROSSCOMPILING)[[:space:]]*$/{
N
s/^if[[:space:]]*(NOT CMAKE_CROSSCOMPILING)[[:space:]]*\n[[:space:]]*add_executable(tg_cli /if (FALSE)\n add_executable(tg_cli /
}
' CMakeLists.txt
sed -i '' '
s/^[[:space:]]*add_subdirectory(benchmark)[[:space:]]*$/# add_subdirectory(benchmark)/;
s/^[[:space:]]*add_subdirectory(test)[[:space:]]*$/# add_subdirectory(test)/
' CMakeLists.txt
rm -rf build
mkdir build
cd build
sudo -E cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DOPENSSL_ROOT_DIR=/usr/local -DCMAKE_INSTALL_PREFIX:PATH=/usr/local -DTD_ENABLE_LTO=ON ..
sudo -E cmake --build . --target install
cd ..
cd ..
ls -l /usr/local
- name: Build wheels
run: |
mkdir -p ./wheelhouse
sudo -E python -m cibuildwheel . --output-dir ./wheelhouse
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-macos
path: ./wheelhouse/*.whl
publish:
needs: [prepare, linux-build, windows-build]
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
- name: Download all wheels
uses: actions/download-artifact@v4
with:
pattern: wheels-*
merge-multiple: true
path: ./dist
- name: Download updated files
uses: actions/download-artifact@v4
with:
name: updated-files
path: .
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
- name: Commit updated files
uses: EndBug/add-and-commit@v9
with:
message: "Update TDLib to ${{ needs.prepare.outputs.LATEST_TDLIB_VERSION }} (tdlib/td@${{ needs.prepare.outputs.LATEST_TDLIB_COMMIT_HASH }})"
add: '["README.md", "tdjson/_version.py"]'
committer_name: GitHub Actions
committer_email: 41898282+github-actions[bot]@users.noreply.github.com