-
Notifications
You must be signed in to change notification settings - Fork 52
268 lines (266 loc) · 9.54 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
name: Pre-built 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-patch=0
on:
workflow_dispatch:
inputs:
tdlib:
description: 'TDLib git ref (e.g. v1.8.0 or a commit hash)'
type: string
required: true
npm-patch:
description: 'prebuilt-tdlib patch version, required to publish (e.g. 0, 1)'
type: string
required: false
npm-tag:
description: 'npm tag (e.g. latest, beta)'
type: string
required: false
default: 'latest'
# NOTE: The ZLIB_USE_STATIC_LIBS option requires CMake >= 3.24
jobs:
build-linux-x64:
name: Build TDLib (Linux x86_64 glibc)
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v27
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Build TDLib
run: |
set -ex
cd packages/prebuilt-tdlib
mkdir to-upload
_fetchparams=$(nix run nixpkgs#nix-prefetch-github -- \
tdlib td --rev "${{ inputs.tdlib }}" --no-deep-clone)
nix-build build-scripts/tdlib-linux.nix --arg fetchparams "''$_fetchparams''" -v
tree result/
cp -L ./result/lib/libtdjson.so to-upload/libtdjson.so
ldd to-upload/libtdjson.so
# - name: Setup tmate session
# uses: mxschmitt/action-tmate@v3
# if: always()
# with:
# limit-access-to-actor: true
- uses: actions/upload-artifact@v4
with:
name: tdlib-linux-x64
path: to-upload
build-macos-x64:
name: Build TDLib (macOS x86_64)
runs-on: macos-13
steps:
# - uses: actions/checkout@v4
# with:
# repository: 'tdlib/td'
# ref: ${{ inputs.tdlib }}
# - name: Install dependencies (homebrew)
# run: HOMEBREW_NO_INSTALL_CLEANUP=1 brew install gperf zlib openssl
# - name: Build TDLib
# run: |
# set -ex
# cmake --version
# mkdir -p to-upload && mkdir -p build && cd build
# MACOSX_DEPLOYMENT_TARGET=10.14 cmake \
# -DCMAKE_BUILD_TYPE=Release \
# -DCMAKE_OSX_ARCHITECTURES='x86_64' \
# -DOPENSSL_USE_STATIC_LIBS=TRUE \
# -DZLIB_USE_STATIC_LIBS=TRUE \
# -DZLIB_LIBRARY=/usr/local/opt/zlib/lib/libz.a \
# -DZLIB_INCLUDE_DIR=/usr/local/opt/zlib/include \
# -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl \
# ..
# cmake --build . --target tdjson -- -j 4
# cd ..
# cp -L build/libtdjson.dylib to-upload/libtdjson.dylib
# cd to-upload
# install_name_tool -id @rpath/libtdjson.dylib libtdjson.dylib
# echo "clang:" >> info.txt && clang --version >> info.txt
# echo "openssl:" >> info.txt && /usr/local/opt/openssl/bin/openssl version >> info.txt
# file libtdjson.dylib
# otool -L libtdjson.dylib
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v27
with:
nix_path: nixpkgs=channel:nixpkgs-unstable
- name: Build TDLib
run: |
set -ex
cd packages/prebuilt-tdlib
mkdir to-upload
_fetchparams=$(nix run nixpkgs#nix-prefetch-github -- \
tdlib td --rev "${{ inputs.tdlib }}" --no-deep-clone)
nix-build build-scripts/tdlib-macos.nix --arg fetchparams "''$_fetchparams''" -v
tree result/
cp -L ./result/lib/libtdjson.dylib to-upload/libtdjson.dylib
otool -L to-upload/libtdjson.dylib
- uses: actions/upload-artifact@v4
with:
name: temp-macos-x64
path: to-upload
build-macos-arm64:
name: Build TDLib (macOS arm64)
runs-on: macos-14
steps:
- uses: actions/checkout@v4
with:
repository: 'tdlib/td'
ref: ${{ inputs.tdlib }}
- name: Install dependencies (homebrew)
run: HOMEBREW_NO_INSTALL_CLEANUP=1 brew install gperf zlib openssl
- name: Build TDLib
run: |
set -ex
cmake --version
mkdir -p to-upload && mkdir -p build && cd build
MACOSX_DEPLOYMENT_TARGET=11.0 cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_OSX_ARCHITECTURES='arm64' \
-DOPENSSL_USE_STATIC_LIBS=TRUE \
-DZLIB_USE_STATIC_LIBS=TRUE \
-DZLIB_LIBRARY=/opt/homebrew/zlib/lib/libz.a \
-DZLIB_INCLUDE_DIR=/opt/homebrew/zlib/include \
-DOPENSSL_ROOT_DIR=/opt/homebrew/openssl \
..
cmake --build . --target tdjson -- -j 2
cd ..
cp -L build/libtdjson.dylib to-upload/libtdjson.dylib
cd to-upload
install_name_tool -id @rpath/libtdjson.dylib libtdjson.dylib
echo "clang:" >> info.txt && clang --version >> info.txt
echo "openssl:" >> info.txt && /opt/homebrew/openssl/bin/openssl version >> info.txt
file libtdjson.dylib
otool -L libtdjson.dylib
- uses: actions/upload-artifact@v4
with:
name: temp-macos-arm64
path: to-upload
build-macos:
name: Create universal macOS shared library
needs: [build-macos-x64, build-macos-arm64]
runs-on: macos-13
steps:
- uses: actions/download-artifact@v4
with:
name: temp-macos-*
merge-multiple: true
- name: Combine shared libraries
run: |
mkdir -p to-upload
lipo temp-macos-x64/libtdjson.dylib temp-macos-arm64/libtdjson.dylib \
-output to-upload/libtdjson.dylib -create
cd to-upload
echo "--x86_64--" >> info.txt
cat ../temp-macos-x64/libtdjson.dylib >> info.txt
echo "--arm64--" >> info.txt
cat ../temp-macos-arm64/libtdjson.dylib >> info.txt
- uses: actions/upload-artifact@v4
with:
name: build-macos
path: to-upload
build-windows-x64:
name: Build TDLib (Windows x86_64)
runs-on: windows-2019
if: ${{ false }}
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 4
cd ..
cp build\Release\tdjson.dll to-upload\tdjson.dll
# It should be possible to print the dependencies using dumpbin.exe
vcpkg list | Select-String openssl,zlib > to-upload\info.txt
cat to-upload\info.txt
- uses: actions/upload-artifact@v4
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]
- [macos-latest, tdlib-macos]
- [windows-latest, tdlib-windows-x64]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
cache: npm
- run: npm install
- name: Uninstall the prebuilt-tdlib dev dependency
run: npm uninstall -D prebuilt-tdlib # just in case
- uses: actions/download-artifact@v4
with:
name: ${{ matrix.os[1] }}
merge-multiple: true
- run: npm run test:integration
env:
LIBDIR_PATH: '.'
publish:
name: 'Publish to npm'
needs: [test]
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
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
- run: npm uninstall -D prebuilt-tdlib
- uses: actions/download-artifact@v4
with:
pattern: tdlib-*
path: packages/prebuilt-tdlib/prebuilds
- run: tree packages/prebuilt-tdlib
- run: du -hsc packages/prebuilt-tdlib/prebuilds/*
- run: npm run test:integration
env:
PREBUILT_PATH: packages/prebuilt-tdlib
- 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"
echo NPM_TAG=${{ inputs.npm-tag }} >> "$GITHUB_ENV"
- name: Publish
run: node packages/prebuilt-tdlib/publish.js ${{ inputs.npm-patch }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
if: "${{ inputs.npm-patch != '' }}"