-
Notifications
You must be signed in to change notification settings - Fork 6.6k
495 lines (490 loc) · 19.4 KB
/
Copy pathpackaging.yml
File metadata and controls
495 lines (490 loc) · 19.4 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
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
---
# Handles building of binary packages for the agent.
name: Packages
on:
pull_request:
types:
- opened
- reopened
- labeled
- synchronize
push:
branches:
- master
workflow_dispatch:
inputs:
type:
description: Package build type
default: devel
required: true
version:
description: Package version
required: false
env:
DISABLE_TELEMETRY: 1
REPO_PREFIX: netdata/netdata
concurrency:
group: packages-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: true
jobs:
file-check: # Check what files changed if we’re being run in a PR or on a push.
name: Check Modified Files
runs-on: ubuntu-latest
outputs:
run: ${{ steps.check-run.outputs.run }}
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
submodules: recursive
- name: Check files
id: check-files
uses: step-security/changed-files@v45
with:
since_last_remote_commit: ${{ github.event_name != 'pull_request' }}
files: |
**/*.c
**/*.cc
**/*.h
**/*.hh
**/*.in
**/*.patch
**/*.cmake
netdata.spec.in
CMakeLists.txt
.github/data/distros.yml
.github/workflows/packaging.yml
.github/scripts/gen-matrix-packaging.py
.github/scripts/prepare-topology-ip-intel-stock.sh
.github/scripts/pkg-test.sh
packaging/cmake/
packaging/*.sh
packaging/*.version
packaging/*.checksums
src/go/tools/topology-ip-intel-downloader/**
src/crates/
src/aclk/aclk-schemas/
src/ml/dlib/
files_ignore: |
src/go/otel-collector/release-config.yaml.in
packaging/**/*.md
packaging/repoconfig/
src/aclk/aclk-schemas/**/*.md
src/crates/**/*.md
src/go/tools/topology-ip-intel-downloader/README.md
src/ml/dlib/**/*.md
- name: List all changed files in pattern
continue-on-error: true
env:
ALL_CHANGED_FILES: ${{ steps.check-files.outputs.all_changed_files }}
run: |
for file in ${ALL_CHANGED_FILES}; do
echo "$file was changed"
done
- name: Check Run
id: check-run
run: |
if [ "${{ steps.check-files.outputs.any_modified }}" == "true" ] || [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
echo 'run=true' >> "${GITHUB_OUTPUT}"
else
echo 'run=false' >> "${GITHUB_OUTPUT}"
fi
matrix:
name: Prepare Build Matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v7
- name: Prepare tools
id: prepare
run: |
sudo apt-get update || true
sudo apt-get install -y python3-ruamel.yaml
- name: Read build matrix
id: set-matrix
run: |
if [ "${{ github.event_name }}" = "pull_request" ] && \
[ "${{ !contains(github.event.pull_request.labels.*.name, 'run-ci/packaging') }}" = "true" ]; then
matrix="$(.github/scripts/gen-matrix-packaging.py 1)"
else
matrix="$(.github/scripts/gen-matrix-packaging.py 0)"
fi
echo "Generated matrix: ${matrix}"
echo "matrix=${matrix}" >> "${GITHUB_OUTPUT}"
- name: Failure Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: 'danger'
SLACK_ICON_EMOJI: ':github-actions:'
SLACK_TITLE: 'Package Build matrix generation failed:'
SLACK_USERNAME: 'GitHub Actions'
SLACK_MESSAGE: |-
${{ github.repository }}: Failed to generate build matrix for package build.
Checkout: ${{ steps.checkout.outcome }}
Prepare Tools: ${{ steps.prepare.outcome }}
Read Build Matrix: ${{ steps.set-matrix.outcome }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
if: >-
${{
failure()
&& github.event_name != 'pull_request'
&& startsWith(github.ref, 'refs/heads/master')
&& github.repository == 'netdata/netdata'
}}
version-check:
name: Version check
runs-on: ubuntu-latest
outputs:
repo: ${{ steps.check-version.outputs.repo }}
version: ${{ steps.check-version.outputs.version }}
retention: ${{ steps.check-version.outputs.retention }}
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v7
- name: Check Version
id: check-version
run: |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
case "${{ github.event.inputs.type }}" in
"release")
echo "repo=${REPO_PREFIX}" >> "${GITHUB_OUTPUT}"
echo "version=${{ github.event.inputs.version }}" >> "${GITHUB_OUTPUT}"
echo "retention=365" >> "${GITHUB_OUTPUT}"
;;
"nightly")
echo "repo=${REPO_PREFIX}-edge" >> "${GITHUB_OUTPUT}"
echo "version=$(tr -d 'v' < packaging/version)" >> "${GITHUB_OUTPUT}"
echo "retention=30" >> "${GITHUB_OUTPUT}"
;;
*)
echo "repo=${REPO_PREFIX}-devel" >> "${GITHUB_OUTPUT}"
echo "version=0.${GITHUB_SHA}" >> "${GITHUB_OUTPUT}"
echo "retention=30" >> "${GITHUB_OUTPUT}"
;;
esac
else
echo "version=$(cut -d'-' -f 1 packaging/version | tr -d 'v')" >> "${GITHUB_OUTPUT}"
echo "retention=0" >> "${GITHUB_OUTPUT}"
fi
- name: Failure Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: 'danger'
SLACK_ICON_EMOJI: ':github-actions:'
SLACK_TITLE: 'Package Build version check failed:'
SLACK_USERNAME: 'GitHub Actions'
SLACK_MESSAGE: |-
${{ github.repository }}: Failed to generate version information for package build.
Checkout: ${{ steps.checkout.outcome }}
Check Version: ${{ steps.check-version.outcome }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
if: >-
${{
failure()
&& github.event_name != 'pull_request'
&& startsWith(github.ref, 'refs/heads/master')
&& github.repository == 'netdata/netdata'
}}
prepare-ibm-mq-libs:
name: Prepare IBM MQ client libraries for build
runs-on: ubuntu-latest
needs:
- file-check
steps:
- name: Skip Check
id: skip
if: needs.file-check.outputs.run != 'true'
run: echo "SKIPPED"
- name: Checkout
id: checkout
if: needs.file-check.outputs.run == 'true'
uses: actions/checkout@v7
with:
fetch-depth: 1
submodules: false
- name: Fetch IBM MQ libs
id: fetch-ibm-mq
if: needs.file-check.outputs.run == 'true'
run: .github/scripts/prep-ibm-mq-libs.sh
- name: Upload IBM MQ libs artifact
id: upload-ibm-mq
if: needs.file-check.outputs.run == 'true'
uses: actions/upload-artifact@v7.0.0
with:
name: ibm-mq-libs
path: ${{ github.workspace }}/tmp/ibm_mq
include-hidden-files: true
- name: Failure Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: 'danger'
SLACK_ICON_EMOJI: ':github-actions:'
SLACK_TITLE: 'Packaging IBM MQ libs fetch failed:'
SLACK_USERNAME: 'GitHub Actions'
SLACK_MESSAGE: |-
${{ github.repository }}: Failed to fetch IBM MQ libs for package builds.
Checkout: ${{ steps.checkout.outcome }}
Fetch IBM MQ libs: ${{ steps.fetch-ibm-mq.outcome }}
Upload IBM MQ libs: ${{ steps.upload-ibm-mq.outcome }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
if: >-
${{
failure()
&& github.event_name != 'pull_request'
&& startsWith(github.ref, 'refs/heads/master')
&& github.repository == 'netdata/netdata'
&& needs.file-check.outputs.run == 'true'
}}
prepare-topology-ip-intel-stock:
name: Prepare topology-ip-intel stock payload
runs-on: ubuntu-latest
needs:
- file-check
steps:
- name: Skip Check
id: skip
if: needs.file-check.outputs.run != 'true'
run: echo "SKIPPED"
- name: Checkout
id: checkout
if: needs.file-check.outputs.run == 'true'
uses: actions/checkout@v7
with:
fetch-depth: 0
submodules: recursive
- name: Setup Go
id: setup-go
if: needs.file-check.outputs.run == 'true'
uses: actions/setup-go@v7
with:
go-version-file: src/go/go.mod
- name: Prepare synthetic stock payload
id: prepare-synthetic
if: needs.file-check.outputs.run == 'true' && github.event_name == 'pull_request'
run: |
.github/scripts/prepare-topology-ip-intel-stock.sh \
--mode synthetic \
--output-dir "${GITHUB_WORKSPACE}/.topology-ip-intel-stock"
- name: Prepare release stock payload
id: prepare-release
if: needs.file-check.outputs.run == 'true' && github.event_name != 'pull_request'
uses: nick-invision/retry@v4
with:
max_attempts: 3
retry_wait_seconds: 30
timeout_seconds: 1800
command: >
.github/scripts/prepare-topology-ip-intel-stock.sh
--mode release
--output-dir "${GITHUB_WORKSPACE}/.topology-ip-intel-stock"
- name: Upload topology-ip-intel stock payload
id: upload-stock
if: needs.file-check.outputs.run == 'true'
uses: actions/upload-artifact@v7.0.0
with:
name: topology-ip-intel-stock
path: ${{ github.workspace }}/.topology-ip-intel-stock/
include-hidden-files: true
- name: Failure Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: 'danger'
SLACK_ICON_EMOJI: ':github-actions:'
SLACK_TITLE: 'Topology stock payload preparation failed:'
SLACK_USERNAME: 'GitHub Actions'
SLACK_MESSAGE: |-
${{ github.repository }}: Failed to prepare topology-ip-intel stock payload.
Checkout: ${{ steps.checkout.outcome }}
Setup Go: ${{ steps.setup-go.outcome }}
Prepare synthetic payload: ${{ steps.prepare-synthetic.outcome }}
Prepare release payload: ${{ steps.prepare-release.outcome }}
Upload stock payload: ${{ steps.upload-stock.outcome }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
if: >-
${{
failure()
&& github.event_name != 'pull_request'
&& startsWith(github.ref, 'refs/heads/master')
&& github.repository == 'netdata/netdata'
&& needs.file-check.outputs.run == 'true'
}}
build:
name: Build
runs-on: ${{ matrix.runner }}
env:
DOCKER_CLI_EXPERIMENTAL: enabled
needs:
- matrix
- version-check
- file-check
- prepare-ibm-mq-libs
- prepare-topology-ip-intel-stock
strategy:
matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
# We intentiaonally disable the fail-fast behavior so that a
# build failure for one version doesn't prevent us from publishing
# successfully built and tested packages for another version.
fail-fast: false
max-parallel: 24
steps:
- name: Skip Check
id: skip
if: needs.file-check.outputs.run != 'true'
run: echo "SKIPPED"
- name: Checkout
id: checkout
if: needs.file-check.outputs.run == 'true'
uses: actions/checkout@v7
with:
fetch-depth: 0 # We need full history for versioning
submodules: recursive
- name: Set Sentry telemetry env vars
id: set-telemetry-env-vars
run: |
if [ "${{ github.repository }}" = 'netdata/netdata' ] && \
[ "${{ matrix.bundle_sentry }}" = 'true' ] && \
[ "${{ github.event_name }}" = 'workflow_dispatch' ]; then
echo "RELEASE_PIPELINE=Production" >> "${GITHUB_ENV}"
echo "UPLOAD_SENTRY=true" >> "${GITHUB_ENV}"
else
echo "RELEASE_PIPELINE=Unknown" >> "${GITHUB_ENV}"
echo "UPLOAD_SENTRY=false" >> "${GITHUB_ENV}"
fi
- name: Setup QEMU
id: qemu
if: matrix.qemu && needs.file-check.outputs.run == 'true'
run: |
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install -y qemu-user-static
- name: Fetch images
id: fetch-images
if: needs.file-check.outputs.run == 'true'
uses: nick-invision/retry@v4
with:
max_attempts: 3
retry_wait_seconds: 30
timeout_seconds: 900
command: |
docker pull --platform ${{ matrix.platform }} ${{ matrix.base_image }}
docker pull --platform ${{ matrix.platform }} netdata/package-builders:${{ matrix.distro }}${{ matrix.version }}-${{ matrix.builder_rev }}
- name: Download IBM MQ libs
id: fetch-ibm-mq
if: (matrix.arch == 'amd64' || matrix.arch == 'x86_64') && needs.file-check.outputs.run == 'true'
uses: actions/download-artifact@v8
with:
name: ibm-mq-libs
path: ${{ github.workspace }}/tmp/ibm_mq
- name: Download topology-ip-intel stock payload
id: fetch-topology-stock
if: needs.file-check.outputs.run == 'true'
uses: actions/download-artifact@v8
with:
name: topology-ip-intel-stock
path: ${{ github.workspace }}/.topology-ip-intel-stock
- name: Build Packages
id: build
if: needs.file-check.outputs.run == 'true'
shell: bash
run: |
docker run --security-opt seccomp=unconfined -e DISABLE_TELEMETRY=1 -e VERSION=${{ needs.version-check.outputs.version }} \
-e ENABLE_SENTRY=${{ matrix.bundle_sentry }} -e RELEASE_PIPELINE=${{ env.RELEASE_PIPELINE }} \
-e BUILD_DESTINATION=${{ matrix.distro }}${{ matrix.version }}_${{ matrix.arch }} -e UPLOAD_SENTRY=${{ env.UPLOAD_SENTRY }} \
-e SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_CLI_TOKEN }} -e NETDATA_SENTRY_DSN=${{ secrets.SENTRY_DSN }} \
-e NETDATA_TOPOLOGY_IP_INTEL_STOCK_DIR=/netdata/.topology-ip-intel-stock \
-e GOOS=$(echo ${{ matrix.platform }} | cut -f 1 -d '/') -e GOARCH=$(echo ${{ matrix.platform }} | cut -f 2 -d '/') \
--platform=${{ matrix.platform }} -v "$PWD":/netdata netdata/package-builders:${{ matrix.distro }}${{ matrix.version }}-${{ matrix.builder_rev }}
- name: Save Packages
id: artifacts
if: needs.file-check.outputs.run == 'true'
continue-on-error: true
uses: actions/upload-artifact@v7.0.1
with:
name: ${{ matrix.distro }}-${{ matrix.version }}-${{ matrix.arch }}-packages
path: ${{ github.workspace }}/artifacts/*${{ matrix.format }}
compression-level: 0
- name: Test Packages
id: test
if: needs.file-check.outputs.run == 'true'
shell: bash
run: |
docker run --security-opt seccomp=unconfined -e DISABLE_TELEMETRY=1 -e DISTRO=${{ matrix.distro }} \
-e VERSION=${{ needs.version-check.outputs.version }} -e DISTRO_VERSION=${{ matrix.version }} \
--platform=${{ matrix.platform }} -v "$PWD":/netdata ${{ matrix.base_image }} \
/netdata/.github/scripts/pkg-test.sh
- name: Import GPG Keys
id: import-keys
if: needs.file-check.outputs.run == 'true' && matrix.format == 'deb' && github.event_name != 'pull_request'
uses: crazy-max/ghaction-import-gpg@v7
with:
gpg_private_key: ${{ secrets.NETDATABOT_PACKAGE_SIGNING_KEY }}
- name: Sign DEB Packages
id: sign-deb
if: needs.file-check.outputs.run == 'true' && matrix.format == 'deb' && github.event_name != 'pull_request'
shell: bash
run: .github/scripts/deb-sign.sh artifacts ${{ steps.import-keys.outputs.fingerprint }}
- name: SSH setup
id: ssh-setup
if: github.event_name == 'workflow_dispatch' && github.repository == 'netdata/netdata' && needs.file-check.outputs.run == 'true'
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.NETDATABOT_PACKAGES_SSH_KEY }}
name: id_ecdsa
known_hosts: ${{ secrets.PACKAGES_KNOWN_HOSTS }}
- name: Upload to packages.netdata.cloud
id: package-upload
continue-on-error: true
if: github.event_name == 'workflow_dispatch' && github.repository == 'netdata/netdata' && needs.file-check.outputs.run == 'true'
run: |
.github/scripts/package-upload.sh \
packages.netdata.cloud \
${{ matrix.repo_distro }} \
${{ matrix.arch }} \
${{ matrix.format }} \
${{ needs.version-check.outputs.repo }}
- name: Upload to packages2.netdata.cloud
id: package2-upload
if: github.event_name == 'workflow_dispatch' && github.repository == 'netdata/netdata' && needs.file-check.outputs.run == 'true'
run: |
.github/scripts/package-upload.sh \
packages2.netdata.cloud \
${{ matrix.repo_distro }} \
${{ matrix.arch }} \
${{ matrix.format }} \
${{ needs.version-check.outputs.repo }}
- name: Failure Notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: 'danger'
SLACK_ICON_EMOJI: ':github-actions:'
SLACK_TITLE: 'Package Build failed:'
SLACK_USERNAME: 'GitHub Actions'
SLACK_MESSAGE: |-
${{ github.repository }}: ${{ matrix.repo_distro }} ${{ matrix.version }} package build for ${{ matrix.arch }} failed.
Checkout: ${{ steps.checkout.outcome }}
Setup QEMU: ${{ steps.qemu.outcome }}
Fetch images: ${{ steps.fetch-images.outcome }}
Fetch IBM MQ libs: ${{ steps.fetch-ibm-mq.outcome }}
Fetch topology stock payload: ${{ steps.fetch-topology-stock.outcome }}
Build: ${{ steps.build.outcome }}
Test: ${{ steps.test.outcome }}
Import GPG Keys: ${{ steps.import-keys.outcome }}
Sign DEB Packages: ${{ steps.sign-deb.outcome }}
Import SSH Key: ${{ steps.ssh-setup.outcome }}
Publish to packages.netdata.cloud: ${{ steps.package-upload.outcome }}
Publish to packages2.netdata.cloud: ${{ steps.package2-upload.outcome }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
if: >-
${{
failure()
&& github.event_name != 'pull_request'
&& startsWith(github.ref, 'refs/heads/master')
&& github.repository == 'netdata/netdata'
&& needs.file-check.outputs.run == 'true'
}}