-
-
Notifications
You must be signed in to change notification settings - Fork 242
465 lines (399 loc) · 16.1 KB
/
build.yml
File metadata and controls
465 lines (399 loc) · 16.1 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
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
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
name: Release Build
on:
push:
branches:
- release/**
workflow_call:
inputs:
is-snapshot:
type: boolean
default: false
checkout-ref:
type: string
default: ''
jobs:
linux:
strategy:
fail-fast: false
matrix:
include:
- arch: i686
target: i686-unknown-linux-musl
container: i686-musl
- arch: x86_64
target: x86_64-unknown-linux-musl
container: x86_64-musl
- arch: armv7
target: armv7-unknown-linux-musleabi
container: armv7-musleabi
- arch: aarch64
target: aarch64-unknown-linux-musl
container: aarch64-musl
name: Linux ${{ matrix.arch }}
runs-on: ubuntu-24.04
container:
image: messense/rust-musl-cross:${{ matrix.container }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
with:
ref: ${{ inputs.checkout-ref }}
- name: Add Rustup Target
run: |
rustup set profile minimal
rustup target add ${{ matrix.target }}
- name: Cache Dependencies
uses: swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # 2.8.2
- name: Build
run: cargo build --release --target=${{ matrix.target }} --locked
- name: Rename Binary
run: mv target/${{ matrix.target }}/release/sentry-cli sentry-cli-Linux-${{ matrix.arch }}
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # 7.0.0
with:
name: artifact-bin-linux-${{ matrix.arch }}
path: sentry-cli-Linux-${{ matrix.arch }}
if-no-files-found: 'error'
macos:
strategy:
fail-fast: false
matrix:
include:
- arch: x86_64
target: x86_64-apple-darwin
- arch: arm64
target: aarch64-apple-darwin
name: macOS ${{ matrix.arch }}
runs-on: macos-14
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
with:
ref: ${{ inputs.checkout-ref }}
- name: Add Rustup Target
run: rustup target add ${{ matrix.target }}
# On x86_64, this environment variable specifies to the openssl-sys crate
# where to find the OpenSSL library.
- name: Set OpenSSL env (x86_64)
if: matrix.arch == 'x86_64'
run: echo "X86_64_APPLE_DARWIN_OPENSSL_DIR=${{ github.workspace }}/openssl-x86_64" >> $GITHUB_ENV
- name: Get OpenSSL cache month (x86_64)
if: matrix.arch == 'x86_64'
id: cache-date
run: echo "month=$(date +%Y-%m)" >> $GITHUB_OUTPUT
- name: Cache x86_64 OpenSSL
if: matrix.arch == 'x86_64'
id: cache-openssl-x86
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # 5.0.3
with:
path: ${{ env.X86_64_APPLE_DARWIN_OPENSSL_DIR }}
key: openssl-x86_64-${{ runner.os }}-${{ steps.cache-date.outputs.month }}
# To cross-compile for x86_64 from an ARM-based macOS runner, we need to have the
# x86_64 OpenSSL libraries installed locally.
- name: Download x86_64 OpenSSL
if: matrix.arch == 'x86_64' && steps.cache-openssl-x86.outputs.cache-hit != 'true'
run: |
brew fetch --bottle-tag=sonoma openssl@3
mkdir -p $X86_64_APPLE_DARWIN_OPENSSL_DIR
tar xzf $(brew --cache --bottle-tag=sonoma openssl@3) -C $X86_64_APPLE_DARWIN_OPENSSL_DIR --strip-components=2
- name: Cache Dependencies
uses: swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # 2.8.2
- name: Run Cargo Build
run: cargo build --target=${{ matrix.target }} --release --locked
- name: Rename Binary
run: mv target/${{ matrix.target }}/release/sentry-cli sentry-cli-Darwin-${{ matrix.arch }}
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # 7.0.0
with:
name: unsigned-bin-macos-${{ matrix.arch }}
path: sentry-cli-Darwin-${{ matrix.arch }}
if-no-files-found: 'error'
macos_universal:
needs: macos
name: macOS universal
runs-on: macos-14
steps:
- uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # 8.0.0
with:
pattern: unsigned-bin-macos-*
merge-multiple: true
- name: Link universal binary
run: lipo -create -output sentry-cli-Darwin-universal sentry-cli-Darwin-x86_64 sentry-cli-Darwin-arm64
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # 7.0.0
with:
name: unsigned-bin-macos-universal
path: sentry-cli-Darwin-universal
if-no-files-found: 'error'
sign-macos-binaries:
strategy:
fail-fast: false
matrix:
include:
- arch: universal
- arch: x86_64
- arch: arm64
needs: [macos, macos_universal]
name: Sign & Notarize macOS Binary (${{ matrix.arch }})
runs-on: ubuntu-24.04
env:
APPLE_CERT_PATH: /tmp/certs.p12
APPLE_API_KEY_PATH: /tmp/apple_key.json
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
with:
ref: ${{ inputs.checkout-ref }}
- name: Install `rcodesign`
run: |
curl -L https://github.com/indygreg/apple-platform-rs/releases/download/apple-codesign%2F0.29.0/apple-codesign-0.29.0-x86_64-unknown-linux-musl.tar.gz \
-o rcodesign.tar.gz
echo "dbe85cedd8ee4217b64e9a0e4c2aef92ab8bcaaa41f20bde99781ff02e600002 rcodesign.tar.gz" | sha256sum -c -
tar -xz --strip-components=1 -f rcodesign.tar.gz
mv rcodesign /usr/local/bin/rcodesign
rm rcodesign.tar.gz
- name: Decode Apple signing certificate and API key
env:
APPLE_CERT_DATA: ${{ secrets.APPLE_CERT_DATA }}
APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
run: |
echo "$APPLE_CERT_DATA" | base64 --decode > ${{ env.APPLE_CERT_PATH }}
echo "$APPLE_API_KEY" | base64 --decode > ${{ env.APPLE_API_KEY_PATH }}
- name: Download unsigned binary
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # 8.0.0
with:
name: unsigned-bin-macos-${{ matrix.arch }}
- name: Sign binary
run: |
rcodesign sign \
--for-notarization \
--entitlements-xml-path entitlements.plist \
--p12-file ${{ env.APPLE_CERT_PATH }} \
--p12-password ${{ secrets.APPLE_CERT_PASSWORD }} \
sentry-cli-Darwin-${{ matrix.arch }}
- name: Zip signed binary
run: |
zip sentry-cli-Darwin-${{ matrix.arch }}.zip sentry-cli-Darwin-${{ matrix.arch }}
- name: Notarize binary
run: |
rcodesign notary-submit \
--api-key-file ${{ env.APPLE_API_KEY_PATH }} \
--wait \
sentry-cli-Darwin-${{ matrix.arch }}.zip
- name: Upload signed binary
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # 7.0.0
with:
name: artifact-bin-macos-${{ matrix.arch }}
path: sentry-cli-Darwin-${{ matrix.arch }}
if-no-files-found: 'error'
windows:
strategy:
fail-fast: false
matrix:
arch: [i686, x86_64, aarch64]
env:
TARGET: ${{ matrix.arch }}-pc-windows-msvc
name: Windows ${{ matrix.arch }}
runs-on: windows-2022
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
with:
ref: ${{ inputs.checkout-ref }}
# When rustup is updated, it tries to replace its binary, which on Windows is somehow locked.
# This can result in the CI failure, see: https://github.com/rust-lang/rustup/issues/3029
- name: Disable rustup self-update
shell: bash
run: rustup set auto-self-update disable
- name: Add Rustup Target
run: rustup target add ${{ env.TARGET }}
- name: Cache Dependencies
uses: swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # 2.8.2
- name: Run Cargo Build
run: cargo build --target=${{ env.TARGET }} --release --locked
- name: Rename Binary
run: mv target/${{ env.TARGET }}/release/sentry-cli.exe sentry-cli-Windows-${{ matrix.arch }}.exe
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # 7.0.0
with:
name: artifact-bin-windows-${{ matrix.arch }}
path: sentry-cli-Windows-${{ matrix.arch }}.exe
if-no-files-found: 'error'
node:
name: NPM Package
runs-on: ubuntu-24.04
needs: [linux, sign-macos-binaries, windows]
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
with:
ref: ${{ inputs.checkout-ref }}
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # 6.2.0
with:
node-version: '20.10.0'
- name: Install dependencies
run: npm ci --ignore-scripts
- name: Download compiled binaries
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # 8.0.0
with:
pattern: artifact-bin-*
merge-multiple: true
- name: Calculate and store checksums
shell: bash
run: |
sha256sum sentry-cli-* | awk '{printf("%s=%s\n", $2, $1)}' > checksums.txt
cat checksums.txt
- run: npm pack
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # 7.0.0
with:
name: artifact-pkg-node
path: '*.tgz'
if-no-files-found: 'error'
python-base:
if: ${{ !inputs.is-snapshot }}
name: python (base)
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
with:
ref: ${{ inputs.checkout-ref }}
- name: Add Rustup Target
run: rustup target add x86_64-unknown-linux-musl
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # 6.2.0
with:
python-version: '3.11'
- run: python3 -m pip install build && python3 -m build
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # 7.0.0
with:
name: python-base
path: dist/*
if-no-files-found: 'error'
python:
if: ${{ !inputs.is-snapshot }}
name: python
runs-on: ubuntu-24.04
needs: [linux, sign-macos-binaries, windows, python-base]
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
with:
ref: ${{ inputs.checkout-ref }}
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # 6.2.0
with:
python-version: '3.11'
- uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # 8.0.0
with:
pattern: artifact-bin-*
merge-multiple: true
path: binaries
- uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # 8.0.0
with:
name: python-base
merge-multiple: true
path: python-base
- run: scripts/wheels --binaries binaries --base python-base --dest dist
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # 7.0.0
with:
name: artifact-pkg-python
path: dist/*
if-no-files-found: 'error'
npm-distributions:
name: 'Build NPM distributions'
runs-on: ubuntu-24.04
needs: [linux, sign-macos-binaries, windows]
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
with:
ref: ${{ inputs.checkout-ref }}
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # 6.2.0
with:
node-version: '20.10.0'
- uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # 8.0.0
with:
pattern: artifact-bin-*
merge-multiple: true
path: binary-artifacts
- name: Move binaries into distribution packages
run: |
mv binary-artifacts/sentry-cli-Darwin-universal npm-binary-distributions/darwin/bin/sentry-cli
mv binary-artifacts/sentry-cli-Linux-armv7 npm-binary-distributions/linux-arm/bin/sentry-cli
mv binary-artifacts/sentry-cli-Linux-aarch64 npm-binary-distributions/linux-arm64/bin/sentry-cli
mv binary-artifacts/sentry-cli-Linux-i686 npm-binary-distributions/linux-i686/bin/sentry-cli
mv binary-artifacts/sentry-cli-Linux-x86_64 npm-binary-distributions/linux-x64/bin/sentry-cli
mv binary-artifacts/sentry-cli-Windows-i686.exe npm-binary-distributions/win32-i686/bin/sentry-cli.exe
mv binary-artifacts/sentry-cli-Windows-x86_64.exe npm-binary-distributions/win32-x64/bin/sentry-cli.exe
mv binary-artifacts/sentry-cli-Windows-aarch64.exe npm-binary-distributions/win32-arm64/bin/sentry-cli.exe
- name: Remove binary placeholders
run: rm -rf npm-binary-distributions/*/bin/.gitkeep
- name: Make Linux binaries executable
run: chmod +x npm-binary-distributions/*/bin/sentry-cli
- name: Package distribution packages
run: |
for dir in npm-binary-distributions/*; do
cd $dir
npm pack
cd -
done
- name: Upload packaged npm binary distributions
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # 7.0.0
with:
name: artifact-npm-binary-distributions
path: npm-binary-distributions/*/*.tgz
if-no-files-found: 'error'
platform-specific-docker:
if: ${{ !inputs.is-snapshot }}
name: Build Docker Image (${{ matrix.platform }})
strategy:
matrix:
include:
- platform: amd64
runner: ubuntu-24.04
- platform: arm64
runner: ubuntu-24.04-arm
runs-on: ${{ matrix.runner }}
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
with:
ref: ${{ inputs.checkout-ref }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # 4.0.0
- name: Login to GitHub Container Registry
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # 4.0.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # 7.0.0
with:
context: .
push: true
platforms: linux/${{ matrix.platform }}
tags: ghcr.io/${{ github.repository }}:${{ github.sha }}-${{ matrix.platform }}
cache-from: type=gha,scope=${{ matrix.platform }}
cache-to: type=gha,mode=max,scope=${{ matrix.platform }}
multiarch-docker:
if: ${{ !inputs.is-snapshot }}
name: Create Multi-Architecture Docker Image
needs: platform-specific-docker
runs-on: ubuntu-24.04
permissions:
packages: write
steps:
- name: Login to GitHub Container Registry
uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # 4.0.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create multi-architecture image
run: |
docker buildx imagetools create -t ghcr.io/${{ github.repository }}:${{ github.sha }} \
ghcr.io/${{ github.repository }}:${{ github.sha }}-amd64 \
ghcr.io/${{ github.repository }}:${{ github.sha }}-arm64
merge:
if: ${{ !inputs.is-snapshot }}
name: Create Release Artifact
runs-on: ubuntu-24.04
needs: [linux, sign-macos-binaries, windows, npm-distributions, node, python]
steps:
- uses: actions/upload-artifact/merge@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # 7.0.0
with:
# Craft expects release assets to be a single artifact named after the sha.
name: ${{ github.sha }}
pattern: artifact-*
delete-merged: true