1
+---
2
+# Ci code for building release artifacts.
3
+name: Build
4
+on:
5
+ push: # Master branch checks only validate the build and generate artifacts for testing.
6
+ branches:
7
+ - master
8
+ pull_request: null # PR checks only validate the build and generate artifacts for testing.
9
+ workflow_dispatch: # Dispatch runs build and validate, then push to the appropriate storage location.
10
+ inputs:
11
+ type:
12
+ description: Build Type
13
+ default: nightly
14
+ required: true
15
+ version:
16
+ description: Version Tag
17
+ default: nightly
18
+ required: true
19
+concurrency: # This keeps multiple instances of the job from running concurrently for the same ref and event type.
20
+ group: release-${{ github.ref }}-${{ github.event_name }}
21
+ cancel-in-progress: true
22
+jobs:
23
+ build-dist: # Build the distribution tarball and store it as an artifact.
24
+ name: Build Distribution Tarball
25
+ runs-on: ubuntu-latest
26
+ outputs:
27
+ distfile: ${{ steps.build.outputs.distfile }}
28
+ steps:
29
+ - name: Checkout
30
+ uses: actions/checkout@v2
31
+ with:
32
+ fetch-depth: 0
33
+ submodules: recursive
34
+ - name: Mark Stable
35
+ if: github.event_name == 'workflow_dispatch' && github.event.inputs.type != 'nightly'
36
+ run: |
37
+ sed -i 's/^RELEASE_CHANNEL="nightly" *#/RELEASE_CHANNEL="stable" #/' netdata-installer.sh
38
+ - name: Build
39
+ id: build
40
+ run: |
41
+ mkdir -p artifacts
42
+ ./packaging/installer/install-required-packages.sh --dont-wait --non-interactive netdata
43
+ autoreconf -ivf
44
+ ./configure --prefix=/usr \
45
+ --sysconfdir=/etc \
46
+ --localstatedir=/var \
47
+ --libexecdir=/usr/libexec \
48
+ --with-zlib \
49
+ --with-math \
50
+ --with-user=netdata
51
+ make dist
52
+ echo "::set-output name=distfile::$(find . -name 'netdata-*.tar.gz')"
53
+ cp netdata-*.tar.gz artifacts/
54
+ - name: Store
55
+ uses: actions/upload-artifact@v2
56
+ with:
57
+ name: dist-tarball
58
+ path: artifacts/*.tar.gz
59
+ retention-days: 30
60
+ - name: Failure Notification
61
+ uses: rtCamp/action-slack-notify@v2
62
+ env:
63
+ SLACK_COLOR: 'danger'
64
+ SLACK_FOOTER: ''
65
+ SLACK_ICON_EMOJI: ':github-actions:'
66
+ SLACK_TITLE: 'Distribution tarball build failed:'
67
+ SLACK_USERNAME: 'GitHub Actions'
68
+ SLACK_MESSAGE: "Distribution tarball build failed."
69
+ SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
70
+ if: >-
71
+ ${{
72
+ failure()
73
+ && startsWith(github.ref, 'refs/heads/master')
74
+ && github.event_name != 'pull_request'
75
+ }}
76
+
77
+ build-static: # Build the static binary archives, and store them as artifacts.
78
+ name: Build Static
79
+ runs-on: ubuntu-latest
80
+ strategy:
81
+ matrix:
82
+ arch:
83
+ - 'x86_64'
84
+ - 'armv7l'
85
+ - 'aarch64'
86
+ steps:
87
+ - name: Checkout
88
+ uses: actions/checkout@v2
89
+ with:
90
+ fetch-depth: 0
91
+ submodules: recursive
92
+ - name: Mark Stable
93
+ if: github.event_name == 'workflow_dispatch' && github.event.inputs.type != 'nightly'
94
+ run: |
95
+ sed -i 's/^RELEASE_CHANNEL="nightly" *#/RELEASE_CHANNEL="stable" #/' netdata-installer.sh packaging/makeself/install-or-update.sh
96
+ - name: Build
97
+ run: .github/scripts/build-static.sh ${{ matrix.arch }}
98
+ - name: Store
99
+ uses: actions/upload-artifact@v2
100
+ with:
101
+ name: static-archive
102
+ path: artifacts/*.gz.run
103
+ retention-days: 30
104
+ - name: Failure Notification
105
+ uses: rtCamp/action-slack-notify@v2
106
+ env:
107
+ SLACK_COLOR: 'danger'
108
+ SLACK_FOOTER: ''
109
+ SLACK_ICON_EMOJI: ':github-actions:'
110
+ SLACK_TITLE: 'Static build for ${{ matrix.arch }} failed:'
111
+ SLACK_USERNAME: 'GitHub Actions'
112
+ SLACK_MESSAGE: "Static build for ${{ matrix.arch }} failed."
113
+ SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
114
+ if: >-
115
+ ${{
116
+ failure()
117
+ && startsWith(github.ref, 'refs/heads/master')
118
+ && github.event_name != 'pull_request'
119
+ }}
120
+
121
+ matrix: # Generate the shared build matrix for our build tests.
122
+ name: Prepare Build Matrix
123
+ runs-on: ubuntu-latest
124
+ outputs:
125
+ matrix: ${{ steps.set-matrix.outputs.matrix }}
126
+ steps:
127
+ - name: Checkout
128
+ uses: actions/checkout@v2
129
+ - name: Prepare tools
130
+ run: |
131
+ sudo apt-get update && sudo apt-get install -y jq
132
+ - name: Read build matrix
133
+ id: set-matrix
134
+ run: |
135
+ TASKS="$(jq -c . .github/data/build-matrix.json)"
136
+ echo "Generated Matrix: $TASKS"
137
+ echo "::set-output name=matrix::$TASKS"
138
+
139
+ prepare-test-images: # Prepare the test environments for our build checks. This also checks dependency handling code for each tested environment.
140
+ name: Prepare Test Environments
141
+ runs-on: ubuntu-latest
142
+ needs:
143
+ - matrix
144
+ strategy:
145
+ # Unlike the actal build tests, this completes _very_ fast (average of about 3 minutes for each job), so we
146
+ # just run everything in parallel instead lof limiting job concurrency.
147
+ fail-fast: false
148
+ matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
149
+ steps:
150
+ - name: Git clone repository
151
+ uses: actions/checkout@v2
152
+ - name: Setup Buildx
153
+ uses: docker/setup-buildx-action@v1
154
+ - name: Build test environment
155
+ uses: docker/build-push-action@v2
156
+ with:
157
+ push: false
158
+ load: false
159
+ file: .github/dockerfiles/Dockerfile.build_test
160
+ build-args: |
161
+ BASE=${{ matrix.distro }}
162
+ PRE=${{ matrix.pre }}
163
+ RMJSONC=${{ matrix.rmjsonc }}
164
+ outputs: type=oci,dest=/tmp/image.tar
165
+ tags: test:${{ matrix.artifact_key }}
166
+ - name: Upload image artifact
167
+ uses: actions/upload-artifact@v2
168
+ with:
169
+ name: ${{ matrix.artifact_key }}-test-env
170
+ path: /tmp/image.tar
171
+ retention-days: 30
172
+ - name: Failure Notification
173
+ uses: rtCamp/action-slack-notify@v2
174
+ env:
175
+ SLACK_COLOR: 'danger'
176
+ SLACK_FOOTER: ''
177
+ SLACK_ICON_EMOJI: ':github-actions:'
178
+ SLACK_TITLE: 'Test environment preparation for ${{ matrix.distro }} failed:'
179
+ SLACK_USERNAME: 'GitHub Actions'
180
+ SLACK_MESSAGE: "Test environment preparation for ${{ matrix.distro }} failed."
181
+ SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
182
+ if: >-
183
+ ${{
184
+ failure()
185
+ && startsWith(github.ref, 'refs/heads/master')
186
+ && github.event_name != 'pull_request'
187
+ }}
188
+
189
+ source-build: # Test various source build arrangements.
190
+ name: Test Source Build
191
+ runs-on: ubuntu-latest
192
+ needs:
193
+ - matrix
194
+ - prepare-test-images
195
+ strategy:
196
+ fail-fast: false
197
+ max-parallel: 8
198
+ matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
199
+ steps:
200
+ - name: Git clone repository
201
+ uses: actions/checkout@v2
202
+ with:
203
+ submodules: recursive
204
+ - name: Fetch test environment
205
+ uses: actions/download-artifact@v2
206
+ with:
207
+ name: ${{ matrix.artifact_key }}-test-env
208
+ - name: Load test environment
209
+ id: load
210
+ run: |
211
+ docker load --input image.tar | tee image-info.txt
212
+ echo "::set-output name=image::$(cut -d ':' -f 3 image-info.txt)"
213
+ - name: Regular build on ${{ matrix.distro }}
214
+ run: |
215
+ docker run --security-opt seccomp=unconfined -w /netdata sha256:${{ steps.load.outputs.image }} \
216
+ /bin/sh -c 'autoreconf -ivf && ./configure && make -j2'
217
+ - name: netdata-installer on ${{ matrix.distro }}, disable cloud
218
+ run: |
219
+ docker run --security-opt seccomp=unconfined -w /netdata sha256:${{ steps.load.outputs.image }} \
220
+ /bin/sh -c './netdata-installer.sh --dont-wait --dont-start-it --disable-cloud'
221
+ - name: netdata-installer on ${{ matrix.distro }}, require cloud
222
+ run: |
223
+ docker run --security-opt seccomp=unconfined -w /netdata sha256:${{ steps.load.outputs.image }} \
224
+ /bin/sh -c './netdata-installer.sh --dont-wait --dont-start-it --require-cloud'
225
+ - name: netdata-installer on ${{ matrix.distro }}, require cloud, require ACLK-NG
226
+ run: |
227
+ docker run --security-opt seccomp=unconfined -w /netdata -e NETDATA_CONFIGURE_OPTIONS='--with-aclk-ng' \
228
+ sha256:${{ steps.load.outputs.image }} /bin/sh -c './netdata-installer.sh --dont-wait --dont-start-it --require-cloud'
229
+ - name: netdata-installer on ${{ matrix.distro }}, require cloud, no JSON-C
230
+ if: matrix.rmjsonc != ''
231
+ run: |
232
+ docker run --security-opt seccomp=unconfined -w /netdata sha256:${{ steps.load.outputs.image }} \
233
+ /bin/sh -c '/rmjsonc.sh && ./netdata-installer.sh --dont-wait --dont-start-it --require-cloud'
234
+ - name: Failure Notification
235
+ uses: rtCamp/action-slack-notify@v2
236
+ env:
237
+ SLACK_COLOR: 'danger'
238
+ SLACK_FOOTER: ''
239
+ SLACK_ICON_EMOJI: ':github-actions:'
240
+ SLACK_TITLE: 'Build tests for ${{ matrix.distro }} failed:'
241
+ SLACK_USERNAME: 'GitHub Actions'
242
+ SLACK_MESSAGE: "Build tests for ${{ matrix.distro }} failed."
243
+ SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
244
+ if: >-
245
+ ${{
246
+ failure()
247
+ && startsWith(github.ref, 'refs/heads/master')
248
+ && github.event_name != 'pull_request'
249
+ }}
250
+
251
+ updater-check: # Test the generated dist archive using the updater code.
252
+ name: Test Generated Distfile and Updater Code
253
+ runs-on: ubuntu-latest
254
+ needs:
255
+ - build-dist
256
+ - matrix
257
+ - prepare-test-images
258
+ strategy:
259
+ fail-fast: false
260
+ max-parallel: 8
261
+ matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
262
+ services:
263
+ apache: # This gets used to serve the dist tarball for the updater script.
264
+ image: httpd:2.4
265
+ ports:
266
+ - 8080:80
267
+ volumes:
268
+ - ${{ github.workspace }}:/usr/local/apache2/htdocs/
269
+ steps:
270
+ - name: Checkout
271
+ uses: actions/checkout@v2
272
+ - name: Fetch dist tarball artifacts
273
+ uses: actions/download-artifact@v2
274
+ with:
275
+ name: dist-tarball
276
+ path: dist-tarball
277
+ - name: Prepare artifact directory
278
+ run: |
279
+ mkdir -p artifacts || exit 1
280
+ echo "9999.0.0-0" > artifacts/latest-version.txt || exit 1
281
+ cp dist-tarball/* artifacts || exit 1
282
+ cd artifacts || exit 1
283
+ ln -s ${{ needs.build-dist.outputs.distfile }} netdata-latest.tar.gz || exit 1
284
+ sha256sum -b ./* > "sha256sums.txt" || exit 1
285
+ cat sha256sums.txt
286
+ - name: Fetch test environment
287
+ uses: actions/download-artifact@v2
288
+ with:
289
+ name: ${{ matrix.artifact_key }}-test-env
290
+ - name: Load test environment
291
+ id: load
292
+ run: |
293
+ docker load --input image.tar | tee image-info.txt
294
+ echo "::set-output name=image::$(cut -d ':' -f 3 image-info.txt)"
295
+ - name: Install netdata and run the updater on ${{ matrix.distro }}
296
+ run: |
297
+ docker run --security-opt seccomp=unconfined -e DO_NOT_TRACK=1 --network host -w /netdata sha256:${{ steps.load.outputs.image }} \
298
+ /netdata/.github/scripts/run-updater-check.sh
299
+ - name: Failure Notification
300
+ uses: rtCamp/action-slack-notify@v2
301
+ env:
302
+ SLACK_COLOR: 'danger'
303
+ SLACK_FOOTER: ''
304
+ SLACK_ICON_EMOJI: ':github-actions:'
305
+ SLACK_TITLE: 'Updater checks for ${{ matrix.distro }} failed:'
306
+ SLACK_USERNAME: 'GitHub Actions'
307
+ SLACK_MESSAGE: "Updater checks for ${{ matrix.distro }} failed."
308
+ SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
309
+ if: >-
310
+ ${{
311
+ failure()
312
+ && startsWith(github.ref, 'refs/heads/master')
313
+ && github.event_name != 'pull_request'
314
+ }}
315
+
316
+ prepare-upload: # Consolidate the artifacts for uploading or releasing.
317
+ name: Prepare Artifacts
318
+ runs-on: ubuntu-latest
319
+ needs:
320
+ - build-dist
321
+ - build-static
322
+ steps:
323
+ - name: Checkout
324
+ uses: actions/checkout@v2
325
+ - name: Prepare Environment
326
+ run: mkdir -p artifacts
327
+ - name: Retrieve Dist Tarball
328
+ uses: actions/download-artifact@v2
329
+ with:
330
+ name: dist-tarball
331
+ path: dist-tarball
332
+ - name: Retrieve Static Build Artifacts
333
+ uses: actions/download-artifact@v2
334
+ with:
335
+ name: static-archive
336
+ path: static-archive
337
+ - name: Prepare Artifacts
338
+ working-directory: ./artifacts/
339
+ run: |
340
+ mv ../dist-tarball/* . || exit 1
341
+ mv ../static-archive/* . || exit 1
342
+ ln -s ${{ needs.build-dist.outputs.distfile }} netdata-latest.tar.gz || exit 1
343
+ cp ../packaging/version ./latest-version.txt || exit 1
344
+ sha256sum -b ./* > sha256sums.txt || exit 1
345
+ cat sha256sums.txt
346
+ - name: Store Artifacts
347
+ uses: actions/upload-artifact@v2
348
+ with:
349
+ name: final-artifacts
350
+ path: artifacts/*
351
+ retention-days: 30
352
+ - name: Failure Notification
353
+ uses: rtCamp/action-slack-notify@v2
354
+ env:
355
+ SLACK_COLOR: 'danger'
356
+ SLACK_FOOTER: ''
357
+ SLACK_ICON_EMOJI: ':github-actions:'
358
+ SLACK_TITLE: 'Failed to prepare release artifacts for upload:'
359
+ SLACK_USERNAME: 'GitHub Actions'
360
+ SLACK_MESSAGE: "Failed to prepare release artifacts for upload."
361
+ SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
362
+ if: >-
363
+ ${{
364
+ failure()
365
+ && startsWith(github.ref, 'refs/heads/master')
366
+ && github.event_name != 'pull_request'
367
+ }}
368
+
369
+ artifact-verification-dist: # Verify the regular installer works with the consolidated artifacts.
370
+ name: Test Consolidated Artifacts (Source)
371
+ runs-on: ubuntu-latest
372
+ needs:
373
+ - prepare-upload
374
+ services:
375
+ apache: # This gets used to serve the dist tarball for the updater script.
376
+ image: httpd:2.4
377
+ ports:
378
+ - 8080:80
379
+ volumes:
380
+ - ${{ github.workspace }}:/usr/local/apache2/htdocs/
381
+ steps:
382
+ - name: Checkout
383
+ uses: actions/checkout@v2
384
+ - name: Fetch artifacts
385
+ uses: actions/download-artifact@v2
386
+ with:
387
+ name: final-artifacts
388
+ path: artifacts
389
+ - name: Verify that artifacts work with installer
390
+ env:
391
+ NETDATA_TARBALL_BASEURL: http://localhost:8080/artifacts
392
+ run: packaging/installer/kickstart.sh --dont-start-it --disable-telemetry --dont-wait
393
+ - name: Failure Notification
394
+ uses: rtCamp/action-slack-notify@v2
395
+ env:
396
+ SLACK_COLOR: 'danger'
397
+ SLACK_FOOTER: ''
398
+ SLACK_ICON_EMOJI: ':github-actions:'
399
+ SLACK_TITLE: 'Artifact verification for source tarball failed.'
400
+ SLACK_USERNAME: 'GitHub Actions'
401
+ SLACK_MESSAGE: "Artifact verification for source tarball failed."
402
+ SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
403
+ if: >-
404
+ ${{
405
+ failure()
406
+ && startsWith(github.ref, 'refs/heads/master')
407
+ && github.event_name != 'pull_request'
408
+ }}
409
+
410
+ artifact-verification-static: # Verify the static installer works with the consolidated artifacts.
411
+ name: Test Consolidated Artifacts (Static)
412
+ runs-on: ubuntu-latest
413
+ needs:
414
+ - prepare-upload
415
+ services:
416
+ apache: # This gets used to serve the static archives.
417
+ image: httpd:2.4
418
+ ports:
419
+ - 8080:80
420
+ volumes:
421
+ - ${{ github.workspace }}:/usr/local/apache2/htdocs/
422
+ steps:
423
+ - name: Checkout
424
+ uses: actions/checkout@v2
425
+ - name: Fetch artifacts
426
+ uses: actions/download-artifact@v2
427
+ with:
428
+ name: final-artifacts
429
+ path: artifacts
430
+ - name: Verify that artifacts work with installer
431
+ env:
432
+ NETDATA_TARBALL_BASEURL: http://localhost:8080/artifacts
433
+ run: packaging/installer/kickstart-static64.sh --dont-start-it --disable-telemetry
434
+ - name: Failure Notification
435
+ uses: rtCamp/action-slack-notify@v2
436
+ env:
437
+ SLACK_COLOR: 'danger'
438
+ SLACK_FOOTER: ''
439
+ SLACK_ICON_EMOJI: ':github-actions:'
440
+ SLACK_TITLE: 'Artifact verification for static build failed.'
441
+ SLACK_USERNAME: 'GitHub Actions'
442
+ SLACK_MESSAGE: "Artifact verification for static build failed."
443
+ SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
444
+ if: >-
445
+ ${{
446
+ failure()
447
+ && startsWith(github.ref, 'refs/heads/master')
448
+ && github.event_name != 'pull_request'
449
+ }}
450
+
451
+ upload-nightly: # Upload the nightly build artifacts to GCS.
452
+ name: Upload Nightly Artifacts
453
+ runs-on: ubuntu-latest
454
+ if: github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'nightly'
455
+ needs:
456
+ - updater-check
457
+ - source-build
458
+ - artifact-verification-dist
459
+ - artifact-verification-static
460
+ steps:
461
+ - name: Retrieve Artifacts
462
+ uses: actions/download-artifact@v2
463
+ with:
464
+ name: final-artifacts
465
+ path: final-artifacts
466
+ - name: Setup Gcloud
467
+ uses: google-github-actions/setup-gcloud@v0.2.1
468
+ with:
469
+ project_id: ${{ secrets.GCP_NIGHTLY_STORAGE_PROJECT }}
470
+ service_account_key: ${{ secrets.GCP_STORAGE_SERVICE_ACCOUNT_KEY }}
471
+ export_default_credentials: true
472
+ - name: Upload Artifacts
473
+ uses: google-github-actions/upload-cloud-storage@v0.4.0
474
+ with:
475
+ destination: ${{ secrets.GCP_NIGHTLY_STORAGE_BUCKET }}
476
+ gzip: false
477
+ path: ./final-artifacts
478
+ parent: false
479
+ - name: Failure Notification
480
+ uses: rtCamp/action-slack-notify@v2
481
+ env:
482
+ SLACK_COLOR: 'danger'
483
+ SLACK_FOOTER: ''
484
+ SLACK_ICON_EMOJI: ':github-actions:'
485
+ SLACK_TITLE: 'Failed to upload nightly release artifacts:'
486
+ SLACK_USERNAME: 'GitHub Actions'
487
+ SLACK_MESSAGE: "Failed to upload nightly release artifacts."
488
+ SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
489
+ if: >-
490
+ ${{
491
+ failure()
492
+ && startsWith(github.ref, 'refs/heads/master')
493
+ && github.event_name != 'pull_request'
494
+ }}
495
+
496
+ upload-release: # Create the draft release and upload the build artifacts.
497
+ name: Create Release Draft
498
+ runs-on: ubuntu-latest
499
+ if: github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'release'
500
+ needs:
501
+ - updater-check
502
+ - source-build
503
+ - artifact-verification-dist
504
+ - artifact-verification-static
505
+ steps:
506
+ - name: Checkout
507
+ uses: actions/checkout@v2
508
+ - name: Retrieve Artifacts
509
+ uses: actions/download-artifact@v2
510
+ with:
511
+ name: final-artifacts
512
+ path: final-artifacts
513
+ - name: Create Release
514
+ uses: ncipollo/release-action@v1
515
+ with:
516
+ allowUpdates: false
517
+ artifactErrorsFailBuild: true
518
+ artifacts: 'final-artifacts/sha256sums.txt,final-artifacts/netdata-*.tar.gz,final-artifacts/netdata-*.gz.run'
519
+ draft: true
520
+ tag: ${{ github.event.inputs.version }}
521
+ token: ${{ secrets.NETDATABOT_TOKEN }}
522
+ - name: Failure Notification
523
+ uses: rtCamp/action-slack-notify@v2
524
+ env:
525
+ SLACK_COLOR: 'danger'
526
+ SLACK_FOOTER: ''
527
+ SLACK_ICON_EMOJI: ':github-actions:'
528
+ SLACK_TITLE: 'Failed to draft release:'
529
+ SLACK_USERNAME: 'GitHub Actions'
530
+ SLACK_MESSAGE: "Failed to draft release."
531
+ SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
532
+ if: >-
533
+ ${{
534
+ failure()
535
+ && startsWith(github.ref, 'refs/heads/master')
536
+ && github.event_name == 'workflow_dispatch'
537
+ }}