-
-
Notifications
You must be signed in to change notification settings - Fork 14
404 lines (357 loc) · 13 KB
/
binaries.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
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
name: binaries
on:
push:
# Don't run on version tags (these are used for JS module).
tags-ignore:
- 'v**'
branches:
- '**'
paths:
- .github/workflows/binaries.yml
- patches/*
- scripts/*
pull_request:
schedule:
- cron: '0 0 * * 0' # run each Sunday
env:
ALPINE_BRANCH: v3.18
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JOBS: 3
CFLAGS: -Os -fomit-frame-pointer -pipe
LINUX_LDFLAGS: -static -Wl,--as-needed -Wl,-Map,linker.map
DARWIN_LDFLAGS: -Wl,-map,linker.map
WIN32_LDFLAGS: -Wl,--as-needed -Wl,-Map,linker.map
# List of extra nginx modules to download.
# NOTE: nginx/njs is not defined here, but directly in the jobs.
NGINX_MODULES: >-
kjdev/nginx-auth-jwt
kjdev/nginx-keyval
vision5/ngx_devel_kit
openresty/echo-nginx-module
openresty/headers-more-nginx-module
openresty/set-misc-nginx-module
# The same as above, but for Windows.
# - kjdev/nginx-auth-jwt, kjdev/nginx-keyval: a bit complicated to build (TODO)
NGINX_MODULES_WIN32: >-
vision5/ngx_devel_kit
openresty/echo-nginx-module
openresty/headers-more-nginx-module
openresty/set-misc-nginx-module
# Don't update binaries with unchanged sources.
SKIP_SAME_SOURCES: true
jobs:
njs-multi-linux:
name: njs-${{ matrix.NJS_VERSION }}${{ matrix.VARIANT }}-${{ matrix.ARCH }}-linux
runs-on: ubuntu-latest
strategy:
matrix:
NJS_VERSION:
- 0.x.x
VARIANT:
- '-debug'
- ''
ARCH:
- x86_64
- aarch64
- ppc64le
steps:
- name: Checkout master branch
uses: actions/checkout@v4
with:
path: master
- name: Download and extract njs
run: ./master/scripts/fetch-sources -d . nginx/njs@${{ matrix.NJS_VERSION }}
- name: Install Alpine ${{ env.ALPINE_BRANCH }} for ${{ matrix.ARCH }}
uses: jirutka/setup-alpine@v1
with:
arch: ${{ matrix.ARCH }}
branch: ${{ env.ALPINE_BRANCH }}
packages: >
build-base
libedit-dev
libedit-static
ncurses-dev
ncurses-static
openssl-dev
openssl-libs-static
pcre-dev
zlib-static
- name: Build njs
env:
VARIANT: ${{ matrix.VARIANT }}
CFLAGS: ${{ env.CFLAGS }}
LDFLAGS: ${{ env.LINUX_LDFLAGS }}
run: ./master/scripts/build-njs
shell: alpine.sh {0}
- name: Upload njs binary to artifacts
uses: actions/upload-artifact@v4
with:
name: njs-${{ matrix.NJS_VERSION }}${{ matrix.VARIANT }}-${{ matrix.ARCH }}-linux
path: artifact/*
njs-x86_64-darwin:
name: njs-${{ matrix.NJS_VERSION }}${{ matrix.VARIANT }}-x86_64-darwin
runs-on: macos-latest
strategy:
matrix:
NJS_VERSION:
- 0.x.x
VARIANT:
- '-debug'
- ''
steps:
- name: Install dependencies
run: brew install gsed jq libedit openssl@3 ncurses pcre zlib
- name: Checkout master branch
uses: actions/checkout@v4
with:
path: master
- name: Download and extract njs
run: ./master/scripts/fetch-sources -d . nginx/njs@${{ matrix.NJS_VERSION }}
# cmake prefers dynamic libs and there's no option to change it, so
# we have to remove them to give it no other option than using static.
- name: Remove dylibs
run: |
rm /opt/homebrew/opt/libedit/lib/*.dylib
rm /opt/homebrew/opt/openssl/lib/*.dylib
rm /opt/homebrew/opt/ncurses/lib/*.dylib
rm /opt/homebrew/opt/pcre/lib/*.dylib
rm /opt/homebrew/opt/zlib/lib/*.dylib
- name: Build njs
env:
VARIANT: ${{ matrix.VARIANT }}
CFLAGS: ${{ env.CFLAGS }} -I/opt/homebrew/opt/libedit/include -I/opt/homebrew/opt/openssl/include -I/opt/homebrew/opt/ncurses/include -I/opt/homebrew/opt/pcre/include -I/opt/homebrew/opt/zlib/include
LDFLAGS: ${{ env.DARWIN_LDFLAGS }} -L/opt/homebrew/opt/libedit/lib -L/opt/homebrew/opt/openssl/lib -L/opt/homebrew/opt/ncurses/lib -L/opt/homebrew/opt/pcre/lib -L/opt/homebrew/opt/zlib/lib
run: ./master/scripts/build-njs
- name: Upload njs binary to artifacts
uses: actions/upload-artifact@v4
with:
name: njs-${{ matrix.NJS_VERSION }}${{ matrix.VARIANT }}-x86_64-darwin
path: artifact/*
nginx-multi-linux:
name: nginx-${{ matrix.NGINX_VERSION }}-${{ matrix.ARCH }}-linux
runs-on: ubuntu-latest
strategy:
matrix:
NGINX_VERSION:
- 1.24.x
- 1.25.x
- 1.26.x
ARCH:
- x86_64
- aarch64
- ppc64le
include:
- NJS_VERSION: 0.x.x
# Pin older njs version for old stable nginx.
- NGINX_VERSION: 1.24.x
NJS_VERSION: 0.8.x
steps:
- name: Checkout master branch
uses: actions/checkout@v4
with:
path: master
- name: Download and extract nginx
run: ./master/scripts/fetch-sources -d . nginx/nginx@release-${{ matrix.NGINX_VERSION }}
- name: Download and extract nginx modules
run: ./master/scripts/fetch-sources nginx/njs@${{ matrix.NJS_VERSION }} $NGINX_MODULES
- name: Install Alpine ${{ env.ALPINE_BRANCH }} for ${{ matrix.ARCH }}
uses: jirutka/setup-alpine@v1
with:
arch: ${{ matrix.ARCH }}
branch: ${{ env.ALPINE_BRANCH }}
packages: >
build-base
jansson-dev
jansson-static
linux-headers
openssl-dev
openssl-libs-static
pcre-dev
zlib-dev
zlib-static
- name: Build nginx
env:
NGINX_MODULES: nginx/njs ${{ env.NGINX_MODULES }}
CFLAGS: ${{ env.CFLAGS }}
LDFLAGS: ${{ env.LINUX_LDFLAGS }}
run: ./master/scripts/build-nginx
shell: alpine.sh {0}
- name: Upload nginx binary to artifacts
uses: actions/upload-artifact@v4
with:
name: nginx-${{ matrix.NGINX_VERSION }}-${{ matrix.ARCH }}-linux
path: artifact/*
nginx-x86_64-darwin:
name: nginx-${{ matrix.NGINX_VERSION }}-x86_64-darwin
runs-on: macos-latest
strategy:
matrix:
NGINX_VERSION:
- 1.24.x
- 1.25.x
- 1.26.x
include:
- NJS_VERSION: 0.x.x
# Pin older njs version for old nginx.
- NGINX_VERSION: 1.24.x
NJS_VERSION: 0.8.x
steps:
- name: Install dependencies
run: brew install gsed jansson jq openssl@3 pcre zlib
- name: Checkout master branch
uses: actions/checkout@v4
with:
path: master
- name: Download and extract nginx
run: ./master/scripts/fetch-sources -d . nginx/nginx@release-${{ matrix.NGINX_VERSION }}
- name: Download and extract nginx modules
run: ./master/scripts/fetch-sources nginx/njs@${{ matrix.NJS_VERSION }} $NGINX_MODULES
# cmake prefers dynamic libs and there's no option to change it, so
# we have to remove them to give it no other option than using static.
- name: Remove dylibs
run: |
rm /opt/homebrew/opt/jansson/lib/*.dylib
rm /opt/homebrew/opt/openssl/lib/*.dylib
rm /opt/homebrew/opt/pcre/lib/*.dylib
rm /opt/homebrew/opt/zlib/lib/*.dylib
- name: Build nginx
env:
NGINX_MODULES: nginx/njs ${{ env.NGINX_MODULES }}
CFLAGS: ${{ env.CFLAGS }} -I/opt/homebrew/opt/jansson/include -I/opt/homebrew/opt/openssl/include -I/opt/homebrew/opt/pcre/include -I/opt/homebrew/opt/zlib/include
LDFLAGS: ${{ env.DARWIN_LDFLAGS }} -L/opt/homebrew/opt/jansson/lib -L/opt/homebrew/opt/openssl/lib -L/opt/homebrew/opt/pcre/lib -L/opt/homebrew/opt/zlib/lib
run: ./master/scripts/build-nginx
- name: Upload nginx binary to artifacts
uses: actions/upload-artifact@v4
with:
name: nginx-${{ matrix.NGINX_VERSION }}-x86_64-darwin
path: artifact/*
nginx-x86_64-win32:
name: nginx-${{ matrix.NGINX_VERSION }}-x86_64-win32
runs-on: windows-latest
strategy:
matrix:
NGINX_VERSION:
- 1.24.x
- 1.25.x
- 1.26.x
steps:
- name: Setup MSYS2 and install packages
uses: msys2/setup-msys2@v2
with:
update: false
install: base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-jq
- name: Checkout master branch
uses: actions/checkout@v4
with:
path: master
- name: Download and extract nginx
shell: msys2 {0}
run: ./master/scripts/fetch-sources -d . nginx/nginx@release-${{ matrix.NGINX_VERSION }}
- name: Download and extract nginx MSYS2 patches
shell: msys2 {0}
run: ./master/scripts/fetch-sources -d msys2 "myfreeer/[email protected]"
- name: Download and extract nginx modules
shell: msys2 {0}
run: ./master/scripts/fetch-sources $NGINX_MODULES_WIN32
- name: Download and extract libraries
shell: msys2 {0}
run: ./master/scripts/fetch-sources '[email protected]' '[email protected]' 'madler/[email protected]'
- name: Apply patches
shell: msys2 {0}
run: |
case "${{ matrix.NGINX_VERSION }}" in
1.2[0-2].x)
for i in msys2/nginx-*.patch; do
patch -p1 < $i
done
;;
# Other patches are not needed since 1.23.4.
*) patch -p1 < msys2/nginx-0007-logs-write-access-log-to-stderr.patch;;
esac
- name: Build nginx
shell: msys2 {0}
env:
NGINX_MODULES: ${{ env.NGINX_MODULES_WIN32 }}
# -DFD_SETSIZE=1024 is per official nginx win32 binary.
CFLAGS: ${{ env.CFLAGS }} -DFD_SETSIZE=1024
LDFLAGS: ${{ env.WIN32_LDFLAGS }}
run: ./master/scripts/build-nginx
- name: Upload nginx binary to artifacts
uses: actions/upload-artifact@v4
with:
name: nginx-${{ matrix.NGINX_VERSION }}-x86_64-win32
path: artifact/*
upload:
name: Upload binaries
needs:
- njs-multi-linux
- njs-x86_64-darwin
- nginx-multi-linux
- nginx-x86_64-darwin
- nginx-x86_64-win32
if: github.ref == 'refs/heads/master' && github.event_name != 'pull_request'
runs-on: ubuntu-latest
container:
image: docker://alpine:3.18
steps:
- name: Install dependencies
run: apk add -U git nodejs tree
- name: Checkout master branch
uses: actions/checkout@v4
with:
path: master
- name: Checkout binaries branch
uses: actions/checkout@v4
with:
ref: binaries
path: binaries
- name: Download and unpack all workflow run artifacts
uses: actions/download-artifact@v4
with:
path: artifact
merge-multiple: true
- name: List unpacked artifact files
run: ls -lah artifact/
# XXX: Windows builds of nginx and macOS builds of njs-debug are not reproducible.
# This is a workaround to avoid unnecessary updates of binaries that are built from
# very same sources as the existing (note that we track even used system libs).
- name: Move binaries with changed source checksums to the repository
if: env.SKIP_SAME_SOURCES == 'true'
working-directory: binaries
run: |
mv ../artifact/*.sources .
for name in $(git status --porcelain | cut -c4-); do
mv -v ../artifact/${name%.sources}* .
done
- name: Move all binaries to the repository
if: env.SKIP_SAME_SOURCES != 'true'
run: mv -v artifact/* binaries/
- name: Generate index.json
run: ./master/scripts/generate-index --json binaries/ binaries/index.json
- name: Generate index.csv
run: ./master/scripts/generate-index --csv binaries/ binaries/index.csv
- name: Generate index.html
working-directory: binaries
run: tree -hv -H . -o index.html .
- name: Check if there are any changes
id: has_changes
working-directory: binaries
run: |
git status || exit 1
test -n "$(git status --porcelain)" && result=yes || result=no
echo "result=$result" >> $GITHUB_OUTPUT
- name: Commit changes
if: steps.has_changes.outputs.result == 'yes'
working-directory: binaries
run: |
git config --local user.email "[email protected]"
git config --local user.name "github-actions[bot]"
git add --all
git commit -m "Built from ${{ github.sha }}"
- name: Push changes back to origin
if: steps.has_changes.outputs.result == 'yes'
working-directory: binaries
run: |
# XXX: workaround for https://github.com/orgs/community/discussions/55820
git config --global http.version HTTP/1.1
git push https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git binaries