-
Notifications
You must be signed in to change notification settings - Fork 0
322 lines (280 loc) · 11.1 KB
/
build-and-release.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
name: "Build: bootstrap"
on:
push:
paths:
- "lambda-with-server/**"
- "lambda-directly/**"
- "lambda-directly-optimized/**"
- "lambda-cosmo/**"
- ".github/workflows/build-and-release.yml"
defaults:
run:
shell: bash # Set the default shell to bash.
jobs:
build-cosmo:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: extractions/setup-just@v1
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
cache: true
- name: Install Zig toolchain
uses: korandoru/setup-zig@v1
with:
zig-version: 0.11.0
- name: Install Cargo Lambda
uses: jaxxstorm/[email protected]
with:
repo: cargo-lambda/cargo-lambda
platform: linux
arch: x86_64
- uses: mozilla-actions/[email protected]
name: 'Setup sccache'
- name: Build release build
run: just build lambda-cosmo
- uses: actions/upload-artifact@v3
with:
name: cosmo-arm
path: lambda-cosmo/target/lambda/router-cosmo/bootstrap
if-no-files-found: error
retention-days: 1
build-with-server:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- name: Build Apollo Router Lambda
uses: docker/build-push-action@v5
with:
context: lambda-with-server
load: true
tags: lambda
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Extract x86 bootstrap file
working-directory: lambda-with-server
run: |
export TMP_IMAGE_ID=$(docker create lambda)
docker cp $TMP_IMAGE_ID:/dist/apollo-router-lambda/target/lambda/apollo-router-lambda/bootstrap bootstrap
docker rm -v $TMP_IMAGE_ID
- uses: actions/upload-artifact@v3
with:
name: with-server-x86-64
path: lambda-with-server/bootstrap
if-no-files-found: error
retention-days: 1
build-directly:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- name: Build Apollo Router Lambda
uses: docker/build-push-action@v5
with:
context: lambda-directly
load: true
tags: lambda
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Extract bootstrap file
working-directory: lambda-directly
run: |
export TMP_IMAGE_ID=$(docker create lambda)
docker cp $TMP_IMAGE_ID:/dist/apollo-router-lambda/target/lambda/apollo-router-lambda/bootstrap bootstrap
docker rm -v $TMP_IMAGE_ID
- uses: actions/upload-artifact@v3
with:
name: directly-x86-64
path: lambda-directly/bootstrap
if-no-files-found: error
retention-days: 1
# build-directly-optimized-arm:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: docker/setup-qemu-action@v3
# - uses: docker/setup-buildx-action@v3
# - name: Build Apollo Router Lambda
# uses: docker/build-push-action@v5
# with:
# context: lambda-directly-optimized
# file: lambda-directly-optimized/Dockerfile-arm
# load: true
# tags: lambda
# platforms: linux/arm64
# cache-from: type=gha
# cache-to: type=gha,mode=max
# - name: Extract ARM bootstrap file
# working-directory: lambda-directly-optimized
# run: |
# mkdir -p arm
# export TMP_IMAGE_ID=$(docker create --platform linux/arm64 lambda)
# docker cp $TMP_IMAGE_ID:/dist/apollo-router-lambda/target/lambda/apollo-router-lambda/bootstrap arm/bootstrap
# docker rm -v $TMP_IMAGE_ID
# - uses: actions/upload-artifact@v3
# with:
# name: directly-optimized-arm
# path: lambda-directly-optimized/arm/bootstrap
# if-no-files-found: error
# retention-days: 1
# build-directly-optimized-arm-graviton:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: docker/setup-qemu-action@v3
# - uses: docker/setup-buildx-action@v3
# - name: Build Apollo Router Lambda
# uses: docker/build-push-action@v5
# with:
# context: lambda-directly-optimized
# file: lambda-directly-optimized/Dockerfile-arm-graviton
# load: true
# tags: lambda
# platforms: linux/arm64
# cache-from: type=gha
# cache-to: type=gha,mode=max
# - name: Extract ARM bootstrap file
# working-directory: lambda-directly-optimized
# run: |
# mkdir -p arm
# export TMP_IMAGE_ID=$(docker create --platform linux/arm64 lambda)
# docker cp $TMP_IMAGE_ID:/dist/apollo-router-lambda/target/lambda/apollo-router-lambda/bootstrap arm/bootstrap
# docker rm -v $TMP_IMAGE_ID
# - uses: actions/upload-artifact@v3
# with:
# name: directly-optimized-graviton-arm
# path: lambda-directly-optimized/arm/bootstrap
# if-no-files-found: error
# retention-days: 1
build-directly-optimized-arm-graviton-size:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: depot/setup-action@v1
- name: Build Apollo Router Lambda
uses: depot/build-push-action@v1
with:
project: 790k10m5qn
token: ${{ secrets.DEPOT_TOKEN }}
context: lambda-directly-optimized
file: lambda-directly-optimized/Dockerfile-arm-graviton-size-al2023
load: true
tags: lambda
platforms: linux/arm64
- name: Extract ARM bootstrap file
working-directory: lambda-directly-optimized
run: |
mkdir -p arm
export TMP_IMAGE_ID=$(docker create --platform linux/arm64 lambda)
docker cp $TMP_IMAGE_ID:/dist/apollo-router-lambda/target/lambda/apollo-router-lambda/bootstrap arm/bootstrap
docker rm -v $TMP_IMAGE_ID
- uses: actions/upload-artifact@v3
with:
name: directly-optimized-graviton-arm-size
path: lambda-directly-optimized/arm/bootstrap
if-no-files-found: error
retention-days: 1
build-directly-optimized-arm-graviton-speed:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: depot/setup-action@v1
- name: Build Apollo Router Lambda
uses: depot/build-push-action@v1
with:
project: 790k10m5qn
token: ${{ secrets.DEPOT_TOKEN }}
context: lambda-directly-optimized
file: lambda-directly-optimized/Dockerfile-arm-graviton-speed
load: true
tags: lambda
platforms: linux/arm64
- name: Extract ARM bootstrap file
working-directory: lambda-directly-optimized
run: |
mkdir -p arm
export TMP_IMAGE_ID=$(docker create --platform linux/arm64 lambda)
docker cp $TMP_IMAGE_ID:/dist/apollo-router-lambda/target/lambda/apollo-router-lambda/bootstrap arm/bootstrap
docker rm -v $TMP_IMAGE_ID
- uses: actions/upload-artifact@v3
with:
name: directly-optimized-graviton-arm-speed
path: lambda-directly-optimized/arm/bootstrap
if-no-files-found: error
retention-days: 1
# build-directly-optimized-x86:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: docker/setup-buildx-action@v3
# - name: Build Apollo Router Lambda
# uses: docker/build-push-action@v5
# with:
# context: lambda-directly-optimized
# file: lambda-directly-optimized/Dockerfile-x86
# load: true
# tags: lambda
# cache-from: type=gha
# cache-to: type=gha,mode=max
# - name: Extract x86 bootstrap file
# working-directory: lambda-directly-optimized
# run: |
# mkdir -p x86
# export TMP_IMAGE_ID=$(docker create lambda)
# docker cp $TMP_IMAGE_ID:/dist/apollo-router-lambda/target/lambda/apollo-router-lambda/bootstrap x86/bootstrap
# docker rm -v $TMP_IMAGE_ID
# - uses: actions/upload-artifact@v3
# with:
# name: directly-optimized-x86-64
# path: lambda-directly-optimized/x86/bootstrap
# if-no-files-found: error
# retention-days: 1
release:
runs-on: ubuntu-latest
needs:
[
build-with-server,
build-directly,
# build-directly-optimized-x86,
# build-directly-optimized-arm,
build-directly-optimized-arm-graviton-size,
build-directly-optimized-arm-graviton-speed,
build-cosmo,
]
steps:
- uses: actions/checkout@v4
- name: Setup artifact directory
run: mkdir -p ./release-artifacts
# Download all artifacts from previous jobs.
- uses: actions/download-artifact@v3
with:
path: ./release-artifacts/
- name: Rename release artifacts
run: |
mv release-artifacts/with-server-x86-64/bootstrap release-artifacts/bootstrap-with-server-x86-64
mv release-artifacts/directly-x86-64/bootstrap release-artifacts/bootstrap-directly-x86-64
# mv release-artifacts/directly-optimized-x86-64/bootstrap release-artifacts/bootstrap-directly-optimized-x86-64
# mv release-artifacts/directly-optimized-arm/bootstrap release-artifacts/bootstrap-directly-optimized-arm
mv release-artifacts/directly-optimized-graviton-arm-size/bootstrap release-artifacts/bootstrap-directly-optimized-graviton-arm-size
mv release-artifacts/directly-optimized-graviton-arm-speed/bootstrap release-artifacts/bootstrap-directly-optimized-graviton-arm-speed
mv release-artifacts/cosmo-arm/bootstrap release-artifacts/bootstrap-cosmo-arm
- name: Set release info
id: info
run: |
echo "git-sha=${GITHUB_SHA::10}" >> $GITHUB_OUTPUT
echo "tag-name=$(date +"%Y-%m-%d-at-%H-%M")" >> $GITHUB_OUTPUT
- uses: ncipollo/[email protected]
with:
# NOTE: release-artifacts/bootstrap-directly-optimized-arm is not included here.
# NOTE: release-artifacts/bootstrap-directly-optimized-x86-64 is not included here.
artifacts: "release-artifacts/bootstrap-with-server-x86-64,release-artifacts/bootstrap-directly-x86-64,release-artifacts/bootstrap-directly-optimized-graviton-arm-speed,release-artifacts/bootstrap-directly-optimized-graviton-arm-size,release-artifacts/bootstrap-cosmo-arm"
# Automatically create the tag from the commit if it doesn't exist.
tag: ${{ steps.info.outputs.tag-name }}
commit: ${{ github.sha }}
name: "Release ${{ steps.info.outputs.git-sha }}"
# Automatically generate the release notes, which can be configured. See more here
generateReleaseNotes: true
# Mark the deployment as the latest.
makeLatest: true