forked from jirutka/nginx-binaries
-
Notifications
You must be signed in to change notification settings - Fork 0
243 lines (212 loc) · 7.9 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
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
# Don't update binaries with unchanged sources.
SKIP_SAME_SOURCES: true
jobs:
nginx-multi-linux:
name: nginx-${{ matrix.NGINX_VERSION }}-${{ matrix.ARCH }}-linux
runs-on: ubuntu-latest
strategy:
matrix:
NGINX_VERSION:
- 1.25.x
- 1.26.x
ARCH:
- x86_64
- aarch64
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: 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:
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-13
strategy:
matrix:
NGINX_VERSION:
- 1.25.x
- 1.26.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 }}
# 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 /usr/local/opt/jansson/lib/*.dylib
rm /usr/local/opt/openssl/lib/*.dylib
rm /usr/local/opt/pcre/lib/*.dylib
rm /usr/local/opt/zlib/lib/*.dylib
- name: Build nginx
env:
CFLAGS: ${{ env.CFLAGS }} -I/usr/local/opt/jansson/include -I/usr/local/opt/openssl/include -I/usr/local/opt/pcre/include -I/usr/local/opt/zlib/include
LDFLAGS: ${{ env.DARWIN_LDFLAGS }} -L/usr/local/opt/jansson/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/pcre/lib -L/usr/local/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-aarch64-darwin:
name: nginx-${{ matrix.NGINX_VERSION }}-aarch64-darwin
runs-on: macos-14
strategy:
matrix:
NGINX_VERSION:
- 1.25.x
- 1.26.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 }}
# 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:
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 }}-aarch64-darwin
path: artifact/*
upload:
name: Upload binaries
needs:
- nginx-multi-linux
- nginx-x86_64-darwin
- nginx-aarch64-darwin
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