Repository navigation
296 lines (255 loc) · 11.5 KB
/
Copy pathrelease.yml
File metadata and controls
296 lines (255 loc) · 11.5 KB
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
name: release build
env:
AWS_ACCESS_KEY_ID: ${{ vars.NIGHTLY_BUILD_AWS_ACCESS_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.NIGHTLY_BUILD_AWS_SECRET_ACCESS_KEY }}
AWS_BUCKET: ${{ vars.NIGHTLY_BUILD_AWS_BUCKET }}
AWS_REGION: ${{ vars.NIGHTLY_BUILD_AWS_REGION }}
AWS_CLOUDFRONT_DISTRIBUTION_ID: ${{ vars.AWS_CF_DISTRIBUTION_NIGHTLY }}
AWS_CLOUDFRONT_GET_ID: ${{ vars.AWS_CF_GET }}
RELEASE: ${{ github.ref_type == 'tag' && github.ref_name || 'nightly' }}
VERSION_FLAG: ${{ github.ref_type == 'tag' && format('-Dversion={0}', github.ref_name) || '-Dversion=nightly' }}
on:
push:
tags:
- '*'
schedule:
- cron: "2 2 * * *"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
permissions:
contents: write
packages: read
jobs:
build-linux:
strategy:
fail-fast: false
matrix:
include:
- arch: x86_64
runner: ubuntu-22.04
cpu_flag: -Dcpu=x86_64
- arch: aarch64
# apt.llvm.org no longer publishes an LLVM 23 repo for 22.04
# see https://github.com/lightpanda-io/zig-v8-fork/pull/199
runner: ubuntu-24.04-arm
cpu_flag: -Dcpu=generic
env:
ARCH: ${{ matrix.arch }}
OS: linux
runs-on: ${{ matrix.runner }}
timeout-minutes: 30
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
fetch-depth: 0
- uses: ./.github/actions/install
with:
os: ${{env.OS}}
arch: ${{env.ARCH}}
- name: v8 snapshot
run: zig build -Dprebuilt_v8_path=v8/libc_v8.a -Doptimize=fast snapshot_creator -- src/snapshot.bin
- name: zig build
run: zig build -Dsnapshot_path=../../snapshot.bin -Dprebuilt_v8_path=v8/libc_v8.a -Doptimize=fast -Dorderfile=orderfile/lightpanda.ld ${{ matrix.cpu_flag }} ${{ env.VERSION_FLAG }}
# Reference partials for the docs site, pulled daily by its
# browser-reference workflow. A debug build: the output doesn't depend
# on the optimize mode, it compiles far faster than ReleaseFast, and its
# flags match the snapshot step's so the C deps come from the cache.
- name: docs reference
if: matrix.arch == 'x86_64'
run: |
zig build -Dprebuilt_v8_path=v8/libc_v8.a docs
tar -czf lightpanda-docs.tar.gz -C zig-out/docs .
- name: Rename binary
run: mv zig-out/bin/lightpanda lightpanda-${{ env.ARCH }}-${{ env.OS }}
# Debug info is over half the binary. Ship it stripped, with the debug
# info as a separate release asset (and on s3) to symbolize crash reports
# (addr2line -e lightpanda-ARCH-linux.debug ADDR...).
- name: Split debug info
run: |
BIN=lightpanda-${{ env.ARCH }}-${{ env.OS }}
objcopy --only-keep-debug --compress-debug-sections=zlib $BIN $BIN.debug
objcopy --strip-all --add-gnu-debuglink=$BIN.debug $BIN
ls -l $BIN $BIN.debug
- name: upload on s3
run: |
export DIR=`git show --no-patch --no-notes --pretty='%cs_%h'`
aws s3 cp --storage-class=GLACIER_IR lightpanda-${{ env.ARCH }}-${{ env.OS }} s3://lpd-nightly-build/${DIR}/lightpanda-${{ env.ARCH }}-${{ env.OS }}
aws s3 cp --storage-class=GLACIER_IR lightpanda-${{ env.ARCH }}-${{ env.OS }}.debug s3://lpd-nightly-build/${DIR}/lightpanda-${{ env.ARCH }}-${{ env.OS }}.debug
aws s3 cp lightpanda-${{ env.ARCH }}-${{ env.OS }} s3://lpd-nightly-build/${RELEASE}/lightpanda-${{ env.ARCH }}-${{ env.OS }}
aws s3 cp lightpanda-${{ env.ARCH }}-${{ env.OS }}.debug s3://lpd-nightly-build/${RELEASE}/lightpanda-${{ env.ARCH }}-${{ env.OS }}.debug
aws s3 cp lightpanda-${{ env.ARCH }}-${{ env.OS }} s3://lpd-nightly-build/agent-${RELEASE}/lightpanda-agent-${{ env.ARCH }}-${{ env.OS }}
- name: Upload the build
uses: ncipollo/release-action@339a81892b84b4eeb0f6e744e4574d79d0d9b8dd # v1.21.0
with:
allowUpdates: true
artifacts: lightpanda-${{ env.ARCH }}-${{ env.OS }},lightpanda-${{ env.ARCH }}-${{ env.OS }}.debug${{ matrix.arch == 'x86_64' && ',lightpanda-docs.tar.gz' || '' }}
tag: ${{ env.RELEASE }}
makeLatest: ${{ github.ref_type == 'tag' }}
- name: Share binary with packaging jobs
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: lightpanda-${{ env.ARCH }}-${{ env.OS }}
path: lightpanda-${{ env.ARCH }}-${{ env.OS }}
retention-days: 1
build-macos:
strategy:
fail-fast: false
matrix:
include:
# macos-14 runs on arm CPU. see
# https://github.com/actions/runner-images?tab=readme-ov-file
- arch: aarch64
runner: macos-14
- arch: x86_64
runner: macos-14-large
env:
ARCH: ${{ matrix.arch }}
OS: macos
runs-on: ${{ matrix.runner }}
timeout-minutes: 30
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
fetch-depth: 0
- uses: ./.github/actions/install
with:
os: ${{env.OS}}
arch: ${{env.ARCH}}
- name: v8 snapshot
run: zig build -Dprebuilt_v8_path=v8/libc_v8.a -Doptimize=fast snapshot_creator -- src/snapshot.bin
- name: zig build
run: zig build -Dsnapshot_path=../../snapshot.bin -Dprebuilt_v8_path=v8/libc_v8.a -Doptimize=fast ${{ env.VERSION_FLAG }}
- name: Rename binary
run: mv zig-out/bin/lightpanda lightpanda-${{ env.ARCH }}-${{ env.OS }}
- name: upload on s3
run: |
export DIR=`git show --no-patch --no-notes --pretty='%cs_%h'`
aws s3 cp --storage-class=GLACIER_IR lightpanda-${{ env.ARCH }}-${{ env.OS }} s3://lpd-nightly-build/${DIR}/lightpanda-${{ env.ARCH }}-${{ env.OS }}
aws s3 cp lightpanda-${{ env.ARCH }}-${{ env.OS }} s3://lpd-nightly-build/${RELEASE}/lightpanda-${{ env.ARCH }}-${{ env.OS }}
aws s3 cp lightpanda-${{ env.ARCH }}-${{ env.OS }} s3://lpd-nightly-build/agent-${RELEASE}/lightpanda-agent-${{ env.ARCH }}-${{ env.OS }}
- name: Upload the build
uses: ncipollo/release-action@339a81892b84b4eeb0f6e744e4574d79d0d9b8dd # v1.21.0
with:
allowUpdates: true
artifacts: lightpanda-${{ env.ARCH }}-${{ env.OS }}
tag: ${{ env.RELEASE }}
makeLatest: ${{ github.ref_type == 'tag' }}
package-debian:
if: github.ref_type == 'tag'
needs: build-linux
uses: ./.github/workflows/package-debian.yml
update-versions:
needs: [build-linux, build-macos]
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
fetch-depth: 0
- uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
with:
go-version: stable
- name: Download linux x86_64 binary (to read the version)
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: lightpanda-x86_64-linux
- uses: docker/login-action@af1e73f918a031802d376d3c8bbc3fe56130a9b0 # v4.4.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: "Generate and publish versions.json"
run: |
chmod +x lightpanda-x86_64-linux
VERSION=$(./lightpanda-x86_64-linux version)
aws s3 cp s3://lpd-nightly-build/get/versions.json current.json --content-type application/json
docker run --rm -v "$PWD:/work" -w /work \
ghcr.io/lightpanda-io/version-fmt:latest \
-release "${RELEASE}" -version "${VERSION}" /work/current.json > new.json
aws s3 cp new.json s3://lpd-nightly-build/get/versions.json --content-type application/json
aws cloudfront create-invalidation --distribution-id ${{ env.AWS_CLOUDFRONT_GET_ID }} --paths "/versions.json"
invalidate-cloudfront:
needs: [build-linux, build-macos]
runs-on: ubuntu-22.04
timeout-minutes: 5
steps:
- name: cloudfront cache invalidation
run: |
aws cloudfront create-invalidation --distribution-id ${{ env.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*"
build-docker-image:
needs: build-linux
runs-on: ubuntu-latest
steps:
- name: Generate token for browser-docker
id: app-token
uses: actions/create-github-app-token@fee1f7d63c2ff003460e3d139729b119787bc349 # v2.2.2
with:
app-id: ${{ secrets.DISTRIBUTION_APP_ID }}
private-key: ${{ secrets.DISTRIBUTION_APP_PRIVATE_KEY }}
owner: lightpanda-io
repositories: browser-docker
- name: Trigger docker image build
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
gh workflow run ci \
--repo lightpanda-io/browser-docker \
--field tag="${{ env.RELEASE }}"
update-homebrew-formula:
needs: [build-linux, build-macos]
runs-on: ubuntu-latest
steps:
- name: Generate token for homebrew-browser
id: app-token
uses: actions/create-github-app-token@fee1f7d63c2ff003460e3d139729b119787bc349 # v2.2.2
with:
app-id: ${{ secrets.DISTRIBUTION_APP_ID }}
private-key: ${{ secrets.DISTRIBUTION_APP_PRIVATE_KEY }}
owner: lightpanda-io
repositories: homebrew-browser
- name: Trigger homebrew formula update
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
gh workflow run "Update Formula" \
--repo lightpanda-io/homebrew-browser \
--field tag="${{ env.RELEASE }}"
update-python-package:
# Version tags only (never nightly): start the wheels build on
# lightpanda-python. It bundles this release's binaries, publishes to PyPI
# once a maintainer approves the `pypi` environment deployment there, and
# then records the matching release on that repo itself — the app token
# below can start workflows there but cannot write repository contents.
if: github.ref_type == 'tag'
needs: [build-linux, build-macos]
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Generate token for lightpanda-python
id: app-token
uses: actions/create-github-app-token@fee1f7d63c2ff003460e3d139729b119787bc349 # v2.2.2
with:
app-id: ${{ secrets.DISTRIBUTION_APP_ID }}
private-key: ${{ secrets.DISTRIBUTION_APP_PRIVATE_KEY }}
owner: lightpanda-io
repositories: lightpanda-python
- name: Start the lightpanda-python wheels build
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
PYTHON_REPO: lightpanda-io/lightpanda-python
run: |
if ! echo "$RELEASE" | grep -qE '^v?[0-9]+(\.[0-9]+)+$'; then
echo "tag $RELEASE is not version-shaped; not releasing to PyPI"
exit 0
fi
if gh release view "$RELEASE" --repo "$PYTHON_REPO" >/dev/null 2>&1; then
echo "release $RELEASE already exists on $PYTHON_REPO; nothing to do"
exit 0
fi
gh workflow run wheels.yml --repo "$PYTHON_REPO" \
--field release="$RELEASE" \
--field publish=pypi
echo "dispatched; the publish waits for pypi environment approval on $PYTHON_REPO"