-
Notifications
You must be signed in to change notification settings - Fork 52
272 lines (270 loc) · 9.8 KB
/
prebuilt-tdlib.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
name: Prebuild TDLib
# This workflow can be executed using a command like this:
# gh workflow run prebuilt-tdlib.yml --ref develop -f tdlib=v1.8.0 \
# -f npm-version=0.1008000.0 -f npm-tag=latest
on:
workflow_dispatch:
inputs:
tdlib:
description: 'TDLib git ref (e.g. v1.8.0 or a commit hash)'
type: string
required: true
npm-version:
description: 'prebuilt-tdlib version to publish on npm (required to publish)'
type: string
required: false
npm-tag:
description: 'npm tag (e.g. latest, beta)'
type: string
required: false
# NOTE: The ZLIB_USE_STATIC_LIBS option requires CMake >= 3.24
jobs:
build-linux-x64:
name: Build TDLib (GNU/Linux x86_64)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
repository: 'tdlib/td'
ref: ${{ inputs.tdlib }}
- name: Create a build script
run: |
cat > prebuilt-tdlib-docker.sh <<EOF
set -e
source /hbb_shlib/activate
set -x
yum install -y gperf
cd /td
mkdir -p build && cd build
cmake --version
# Currently, cmake in this image should be 3.22.2
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DOPENSSL_USE_STATIC_LIBS=TRUE \
-DZLIB_LIBRARY=/hbb_shlib/lib/libz.a \
-DZLIB_INCLUDE_DIR=/hbb_shlib/include \
..
cmake --build . --target tdjson -- -j 2
strip libtdjson.so
cd ..
cp -L build/libtdjson.so to-upload/libtdjson.so
cd to-upload
ldd libtdjson.so
touch info.txt
gcc --version | grep -i gcc >> info.txt
ldd --version | grep ldd >> info.txt
openssl version >> info.txt
sed -n 's/#define ZLIB_VERSION "\([^"]*\)"/zlib version: \1/p' /hbb_shlib/include/zlib.h >> info.txt
EOF
- name: Build in docker
run: |
mkdir to-upload
docker run -v $(pwd):/td ghcr.io/phusion/holy-build-box/hbb-64 \
bash /td/prebuilt-tdlib-docker.sh
- name: Info
working-directory: to-upload
run: |
cat info.txt
echo "-----"
du -hs libtdjson.so
ldd libtdjson.so
- uses: actions/upload-artifact@v3
with:
name: tdlib-linux-x64
path: to-upload
build-macos:
name: Build TDLib (macOS universal)
runs-on: macos-12
env:
openssl_dir: /usr/local/opt/custom_openssl
openssl_tag: '1.1.2100' # OpenSSL 1.1.1u
zlib_ver: '1.2.13'
zlib_dir: /usr/local/opt/custom_zlib
steps:
- uses: actions/checkout@v4
with:
repository: 'tdlib/td'
ref: ${{ inputs.tdlib }}
- name: Install gperf via homebrew
run: HOMEBREW_NO_INSTALL_CLEANUP=1 brew install gperf
- name: CMake version
run: cmake --version
# https://github.com/up9cloud/ios-libtdjson/blob/d4426dca16933b6178acb030955de92f040b7574/build.sh
- name: Download pre-built OpenSSL
run: |
# around 80 mb
curl -SL https://github.com/krzyzanowskim/OpenSSL/archive/refs/tags/${openssl_tag}.tar.gz -o OpenSSL.tar.gz
tar xzf OpenSSL.tar.gz
# As for now, MACOSX_DEPLOYMENT_TARGET in these pre-built openssl binaries should be 10.13
mv OpenSSL-${openssl_tag}/macosx ${openssl_dir}
- name: Download and build zlib
run: |
set -x
curl -SL https://github.com/madler/zlib/releases/download/v${zlib_ver}/zlib-${zlib_ver}.tar.gz -o zlib.tar.gz
tar xzf zlib.tar.gz
cd zlib-${zlib_ver}
MACOSX_DEPLOYMENT_TARGET=10.14 CFLAGS="-O2 -mmacosx-version-min=10.14 -arch x86_64" \
./configure --static --prefix=${zlib_dir}
MACOSX_DEPLOYMENT_TARGET=10.14 make
make install && rm ${zlib_dir}/lib/libz.a
cp libz.a libz-x86_64.a
make clean
MACOSX_DEPLOYMENT_TARGET=11.0 CFLAGS="-O2 -mmacosx-version-min=11.0 -arch arm64" \
./configure --static
MACOSX_DEPLOYMENT_TARGET=11.0 make
mv libz.a libz-arm64.a
lipo -create libz-x86_64.a libz-arm64.a -output libz.a
cp libz.a ${zlib_dir}/lib/libz.a
- name: Build TDLib
run: |
mkdir to-upload
mkdir -p build && cd build
MACOSX_DEPLOYMENT_TARGET=10.14 cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_OSX_ARCHITECTURES='x86_64;arm64' \
-DOPENSSL_USE_STATIC_LIBS=TRUE -DZLIB_USE_STATIC_LIBS=TRUE \
-DOPENSSL_FOUND=1 \
-DOPENSSL_CRYPTO_LIBRARY=${openssl_dir}/lib/libcrypto.a \
-DOPENSSL_SSL_LIBRARY=${openssl_dir}/lib/libssl.a \
-DOPENSSL_LIBRARIES="${openssl_dir}/lib/libcrypto.a;${openssl_dir}/lib/libssl.a" \
-DOPENSSL_INCLUDE_DIR=${openssl_dir}/include \
-DZLIB_INCLUDE_DIR=${zlib_dir}/include \
-DZLIB_LIBRARY=${zlib_dir}/lib/libz.a \
..
cmake --build . --target tdjson -- -j 3
cd ..
cp -L build/libtdjson.dylib to-upload/libtdjson.dylib
install_name_tool -id @rpath/libtdjson.dylib to-upload/libtdjson.dylib
- name: Info
working-directory: to-upload
run: |
touch info.txt
grep OPENSSL_VERSION_TEXT ${openssl_dir}/include/openssl/opensslv.h | sed 's/.*"\([^"]*\)"/\1/' >> info.txt
echo "zlib version: ${zlib_ver}" >> info.txt
otool -L libtdjson.dylib >> info.txt
cat info.txt
echo "-----"
uname -a
file libtdjson.dylib
du -hs libtdjson.dylib
otool -arch x86_64 -l libtdjson.dylib
echo "---"
otool -arch arm64 -l libtdjson.dylib
- uses: actions/upload-artifact@v3
with:
name: tdlib-macos
path: to-upload
build-windows-x64:
name: Build TDLib (Windows x86_64)
runs-on: windows-2019
steps:
- uses: actions/checkout@v4
with:
repository: 'tdlib/td'
ref: ${{ inputs.tdlib }}
- name: vcpkg cache
uses: actions/cache@v4
with:
path: '~\AppData\Local\vcpkg\archives'
key: windows-vcpkg-${{ github.run_id }}
restore-keys: |
windows-vcpkg-
- name: Install dependencies using vcpkg
run: vcpkg install gperf:x64-windows-static openssl:x64-windows-static zlib:x64-windows-static
- name: CMake version
run: cmake --version
- name: Build TDLib
run: |
mkdir to-upload
mkdir build
cd build
cmake -A x64 `
-DCMAKE_TOOLCHAIN_FILE=C:\vcpkg\scripts\buildsystems\vcpkg.cmake `
-DVCPKG_TARGET_TRIPLET=x64-windows-static `
-DOPENSSL_USE_STATIC_LIBS=TRUE -DZLIB_USE_STATIC_LIBS=TRUE ..
cmake --build . --target tdjson --config Release --parallel 2
cd ..
cp build\Release\tdjson.dll to-upload\tdjson.dll
- name: Info
# It should be possible to print the dependencies using dumpbin.exe
run: |
vcpkg list | Select-String openssl,zlib > to-upload\info.txt
cat to-upload\info.txt
- uses: actions/upload-artifact@v3
with:
name: tdlib-windows-x64
path: to-upload
test:
name: 'Test the ${{ matrix.os[1] }} pre-built libraries'
needs: [build-linux-x64, build-macos, build-windows-x64]
runs-on: ${{ matrix.os[0] }}
strategy:
fail-fast: false
matrix:
os:
- [ubuntu-latest, tdlib-linux-x64, libtdjson.so]
- [macos-latest, tdlib-macos, libtdjson.dylib]
- [windows-2019, tdlib-windows-x64, tdjson.dll]
env:
LIBTDJSON_PATH: ${{ matrix.os[2] }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
cache: npm
- run: npm install
- uses: actions/download-artifact@v3
with:
name: ${{ matrix.os[1] }}
- run: npm run integration-tests
publish:
name: 'Publish to npm'
needs: [test]
if: "${{ inputs.npm-version != '' }}"
runs-on: ubuntu-latest
env:
TEST_PREBUILT: 1
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
cache: npm
# registry-url is mandatory here
registry-url: 'https://registry.npmjs.org'
- run: npm install
- uses: actions/download-artifact@v3
with:
path: packages/prebuilt-tdlib/prebuilds/
- run: tree packages/prebuilt-tdlib
- run: npm run integration-tests
- run: |
git clone https://github.com/tdlib/td td
cd td
git checkout ${{ inputs.tdlib }}
echo "TDLIB_COMMIT_HASH=$(git rev-parse ${{ inputs.tdlib }})" >> "$GITHUB_ENV"
__ver=`grep -Po "(?<=TDLib VERSION )\d+\.\d+\.\d+" ./CMakeLists.txt`
echo "TDLIB_VERSION=$__ver" >> "$GITHUB_ENV"
- run: node packages/prebuilt-tdlib/check-prebuilds.js
- run: node packages/prebuilt-tdlib/write-tdlib-json.js $TDLIB_COMMIT_HASH $TDLIB_VERSION
- run: cat packages/prebuilt-tdlib/prebuilds/tdlib.json
- name: Update version
run: npm version ${{ inputs.npm-version }} --no-git-tag-version -w prebuilt-tdlib
- name: Publish
run: |
if test -z "{{ inputs.npm-tag }}"
then
npm publish -w prebuilt-tdlib
else
npm publish --tag ${{ inputs.npm-tag }} -w prebuilt-tdlib
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Set the td- tag
run: |
npm dist-tag add \
prebuilt-tdlib@${{ inputs.npm-version }} td-$TDLIB_VERSION \
-w prebuilt-tdlib
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}