build.yml 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775
  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: build-${{ 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. id: checkout
  31. uses: actions/checkout@v3
  32. with:
  33. fetch-depth: 0
  34. submodules: recursive
  35. - name: Mark Stable
  36. id: channel
  37. if: github.event_name == 'workflow_dispatch' && github.event.inputs.type != 'nightly'
  38. run: |
  39. sed -i 's/^RELEASE_CHANNEL="nightly" *#/RELEASE_CHANNEL="stable" #/' netdata-installer.sh
  40. - name: Build
  41. id: build
  42. run: |
  43. mkdir -p artifacts
  44. ./packaging/installer/install-required-packages.sh --dont-wait --non-interactive netdata
  45. autoreconf -ivf
  46. ./configure --prefix=/usr \
  47. --sysconfdir=/etc \
  48. --localstatedir=/var \
  49. --libexecdir=/usr/libexec \
  50. --with-zlib \
  51. --with-math \
  52. --with-user=netdata
  53. make dist
  54. echo "::set-output name=distfile::$(find . -name 'netdata-*.tar.gz')"
  55. cp netdata-*.tar.gz artifacts/
  56. - name: Store
  57. id: store
  58. uses: actions/upload-artifact@v3
  59. with:
  60. name: dist-tarball
  61. path: artifacts/*.tar.gz
  62. retention-days: 30
  63. - name: Failure Notification
  64. uses: rtCamp/action-slack-notify@v2
  65. env:
  66. SLACK_COLOR: 'danger'
  67. SLACK_FOOTER: ''
  68. SLACK_ICON_EMOJI: ':github-actions:'
  69. SLACK_TITLE: 'Distribution tarball creation failed:'
  70. SLACK_USERNAME: 'GitHub Actions'
  71. SLACK_MESSAGE: |-
  72. ${{ github.repository }}: Failed to create source tarball for distribution.
  73. Checkout: ${{ steps.checkout.outcome }}
  74. Mark stable: ${{ steps.channel.outcome }}
  75. Build: ${{ steps.build.outcome }}
  76. Store: ${{ steps.store.outcome }}
  77. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  78. if: >-
  79. ${{
  80. failure()
  81. && startsWith(github.ref, 'refs/heads/master')
  82. && github.event_name != 'pull_request'
  83. && github.repository == 'netdata/netdata'
  84. }}
  85. build-static: # Build the static binary archives, and store them as artifacts.
  86. name: Build Static
  87. runs-on: ubuntu-latest
  88. strategy:
  89. matrix:
  90. arch:
  91. - x86_64
  92. - armv7l
  93. - aarch64
  94. - ppc64le
  95. steps:
  96. - name: Checkout
  97. id: checkout
  98. uses: actions/checkout@v3
  99. with:
  100. fetch-depth: 0
  101. submodules: recursive
  102. - name: Mark Stable
  103. id: channel
  104. if: github.event_name == 'workflow_dispatch' && github.event.inputs.type != 'nightly'
  105. run: |
  106. sed -i 's/^RELEASE_CHANNEL="nightly" *#/RELEASE_CHANNEL="stable" #/' netdata-installer.sh packaging/makeself/install-or-update.sh
  107. - name: Get Cache Key
  108. id: cache-key
  109. run: .github/scripts/get-static-cache-key.sh ${{ matrix.arch }}
  110. - name: Cache
  111. id: cache
  112. uses: actions/cache@v3
  113. with:
  114. path: artifacts/cache
  115. key: ${{ steps.cache-key.outputs.key }}
  116. - name: Build
  117. if: github.event_name != 'workflow_dispatch' # Don’t use retries on PRs.
  118. run: .github/scripts/build-static.sh ${{ matrix.arch }}
  119. - name: Build
  120. if: github.event_name == 'workflow_dispatch'
  121. id: build
  122. uses: nick-fields/retry@v2
  123. with:
  124. timeout_minutes: 180
  125. retries: 3
  126. command: .github/scripts/build-static.sh ${{ matrix.arch }}
  127. - name: Store
  128. id: store
  129. uses: actions/upload-artifact@v3
  130. with:
  131. name: static-archive
  132. path: artifacts/*.gz.run
  133. retention-days: 30
  134. - name: Failure Notification
  135. uses: rtCamp/action-slack-notify@v2
  136. env:
  137. SLACK_COLOR: 'danger'
  138. SLACK_FOOTER: ''
  139. SLACK_ICON_EMOJI: ':github-actions:'
  140. SLACK_TITLE: 'Static build failed:'
  141. SLACK_USERNAME: 'GitHub Actions'
  142. SLACK_MESSAGE: |-
  143. ${{ github.repository }}: Failed to create static installer archive for ${{ matrix.arch }}.
  144. Checkout: ${{ steps.checkout.outcome }}
  145. Mark stable: ${{ steps.channel.outcome }}
  146. Build: ${{ steps.build.outcome }}
  147. Store: ${{ steps.store.outcome }}
  148. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  149. if: >-
  150. ${{
  151. failure()
  152. && startsWith(github.ref, 'refs/heads/master')
  153. && github.event_name != 'pull_request'
  154. && github.repository == 'netdata/netdata'
  155. }}
  156. matrix: # Generate the shared build matrix for our build tests.
  157. name: Prepare Build Matrix
  158. runs-on: ubuntu-latest
  159. outputs:
  160. matrix: ${{ steps.set-matrix.outputs.matrix }}
  161. steps:
  162. - name: Checkout
  163. id: checkout
  164. uses: actions/checkout@v3
  165. - name: Prepare tools
  166. id: prepare
  167. run: |
  168. sudo apt-get update && sudo apt-get install -y python3-ruamel.yaml
  169. - name: Read build matrix
  170. id: set-matrix
  171. shell: python3 {0}
  172. run: |
  173. from ruamel.yaml import YAML
  174. import json
  175. yaml = YAML(typ='safe')
  176. entries = list()
  177. with open('.github/data/distros.yml') as f:
  178. data = yaml.load(f)
  179. for i, v in enumerate(data['include']):
  180. e = {
  181. 'artifact_key': v['distro'] + str(v['version']).replace('.', ''),
  182. 'version': v['version'],
  183. }
  184. if 'base_image' in v:
  185. e['distro'] = ':'.join([v['base_image'], str(v['version'])])
  186. else:
  187. e['distro'] = ':'.join([v['distro'], str(v['version'])])
  188. if 'env_prep' in v:
  189. e['env_prep'] = v['env_prep']
  190. if 'jsonc_removal' in v:
  191. e['jsonc_removal'] = v['jsonc_removal']
  192. entries.append(e)
  193. entries.sort(key=lambda k: k['distro'])
  194. matrix = json.dumps({'include': entries}, sort_keys=True)
  195. print('Generated Matrix: ' + matrix)
  196. print('::set-output name=matrix::' + matrix)
  197. - name: Failure Notification
  198. uses: rtCamp/action-slack-notify@v2
  199. env:
  200. SLACK_COLOR: 'danger'
  201. SLACK_FOOTER: ''
  202. SLACK_ICON_EMOJI: ':github-actions:'
  203. SLACK_TITLE: 'Build matrix preparation failed:'
  204. SLACK_USERNAME: 'GitHub Actions'
  205. SLACK_MESSAGE: |-
  206. ${{ github.repository }}: Failed to prepare build matrix for build checks.
  207. Checkout: ${{ steps.checkout.outcome }}
  208. Prepare tools: ${{ steps.prepare.outcome }}
  209. Read build matrix: ${{ steps.set-matrix.outcome }}
  210. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  211. if: >-
  212. ${{
  213. failure()
  214. && startsWith(github.ref, 'refs/heads/master')
  215. && github.event_name != 'pull_request'
  216. && github.repository == 'netdata/netdata'
  217. }}
  218. prepare-test-images: # Prepare the test environments for our build checks. This also checks dependency handling code for each tested environment.
  219. name: Prepare Test Environments
  220. runs-on: ubuntu-latest
  221. needs:
  222. - matrix
  223. env:
  224. RETRY_DELAY: 300
  225. strategy:
  226. # Unlike the actal build tests, this completes _very_ fast (average of about 3 minutes for each job), so we
  227. # just run everything in parallel instead lof limiting job concurrency.
  228. fail-fast: false
  229. matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
  230. steps:
  231. - name: Checkout
  232. id: checkout
  233. uses: actions/checkout@v3
  234. - name: Setup Buildx
  235. id: buildx
  236. uses: docker/setup-buildx-action@v2
  237. - name: Build test environment
  238. id: build1
  239. uses: docker/build-push-action@v3
  240. continue-on-error: true # We retry 3 times at 5 minute intervals if there is a failure here.
  241. with:
  242. push: false
  243. load: false
  244. file: .github/dockerfiles/Dockerfile.build_test
  245. build-args: |
  246. BASE=${{ matrix.distro }}
  247. PRE=${{ matrix.env_prep }}
  248. RMJSONC=${{ matrix.jsonc_removal }}
  249. outputs: type=oci,dest=/tmp/image.tar
  250. tags: test:${{ matrix.artifact_key }}
  251. - name: Retry delay
  252. if: ${{ steps.build1.outcome == 'failure' }}
  253. run: sleep "${RETRY_DELAY}"
  254. - name: Build test environment (attempt 2)
  255. if: ${{ steps.build1.outcome == 'failure' }}
  256. id: build2
  257. uses: docker/build-push-action@v3
  258. continue-on-error: true # We retry 3 times at 5 minute intervals if there is a failure here.
  259. with:
  260. push: false
  261. load: false
  262. file: .github/dockerfiles/Dockerfile.build_test
  263. build-args: |
  264. BASE=${{ matrix.distro }}
  265. PRE=${{ matrix.env_prep }}
  266. RMJSONC=${{ matrix.jsonc_removal }}
  267. outputs: type=oci,dest=/tmp/image.tar
  268. tags: test:${{ matrix.artifact_key }}
  269. - name: Retry delay
  270. if: ${{ steps.build1.outcome == 'failure' && steps.build2.outcome == 'failure' }}
  271. run: sleep "${RETRY_DELAY}"
  272. - name: Build test environment (attempt 3)
  273. if: ${{ steps.build1.outcome == 'failure' && steps.build2.outcome == 'failure' }}
  274. id: build3
  275. uses: docker/build-push-action@v3
  276. with:
  277. push: false
  278. load: false
  279. file: .github/dockerfiles/Dockerfile.build_test
  280. build-args: |
  281. BASE=${{ matrix.distro }}
  282. PRE=${{ matrix.env_prep }}
  283. RMJSONC=${{ matrix.jsonc_removal }}
  284. outputs: type=oci,dest=/tmp/image.tar
  285. tags: test:${{ matrix.artifact_key }}
  286. - name: Upload image artifact
  287. id: upload
  288. uses: actions/upload-artifact@v3
  289. with:
  290. name: ${{ matrix.artifact_key }}-test-env
  291. path: /tmp/image.tar
  292. retention-days: 30
  293. - name: Failure Notification
  294. uses: rtCamp/action-slack-notify@v2
  295. env:
  296. SLACK_COLOR: 'danger'
  297. SLACK_FOOTER: ''
  298. SLACK_ICON_EMOJI: ':github-actions:'
  299. SLACK_TITLE: 'Test environment preparation for ${{ matrix.distro }} failed:'
  300. SLACK_USERNAME: 'GitHub Actions'
  301. SLACK_MESSAGE: |-
  302. ${{ github.repository }}: Test environment preparation for ${{ matrix.distro }} failed.
  303. Checkout: ${{ steps.checkout.outcome }}
  304. Set up Buildx: ${{ steps.buildx.outcome }}
  305. Build test environment: ${{ steps.build1.outcome }}
  306. Build test environment (attempt 2): ${{ steps.build2.outcome }}
  307. Build test environment (attempt 3): ${{ steps.build3.outcome }}
  308. Upload: ${{ steps.upload.outcome }}
  309. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  310. if: >-
  311. ${{
  312. failure()
  313. && startsWith(github.ref, 'refs/heads/master')
  314. && github.event_name != 'pull_request'
  315. && github.repository == 'netdata/netdata'
  316. }}
  317. source-build: # Test various source build arrangements.
  318. name: Test Source Build
  319. runs-on: ubuntu-latest
  320. needs:
  321. - matrix
  322. - prepare-test-images
  323. strategy:
  324. fail-fast: false
  325. max-parallel: 8
  326. matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
  327. steps:
  328. - name: Checkout
  329. id: checkout
  330. uses: actions/checkout@v3
  331. with:
  332. submodules: recursive
  333. - name: Fetch test environment
  334. id: fetch
  335. uses: actions/download-artifact@v3
  336. with:
  337. name: ${{ matrix.artifact_key }}-test-env
  338. - name: Load test environment
  339. id: load
  340. run: |
  341. docker load --input image.tar | tee image-info.txt
  342. echo "::set-output name=image::$(cut -d ':' -f 3 image-info.txt)"
  343. - name: Regular build on ${{ matrix.distro }}
  344. id: build-basic
  345. run: |
  346. docker run --security-opt seccomp=unconfined -w /netdata sha256:${{ steps.load.outputs.image }} \
  347. /bin/sh -c 'autoreconf -ivf && ./configure --disable-dependency-tracking && make -j2'
  348. - name: netdata-installer on ${{ matrix.distro }}, disable cloud
  349. id: build-no-cloud
  350. run: |
  351. docker run --security-opt seccomp=unconfined -w /netdata sha256:${{ steps.load.outputs.image }} \
  352. /bin/sh -c './netdata-installer.sh --dont-wait --dont-start-it --disable-cloud --one-time-build'
  353. - name: netdata-installer on ${{ matrix.distro }}, require cloud
  354. id: build-cloud
  355. run: |
  356. docker run --security-opt seccomp=unconfined -w /netdata sha256:${{ steps.load.outputs.image }} \
  357. /bin/sh -c './netdata-installer.sh --dont-wait --dont-start-it --require-cloud --one-time-build'
  358. - name: netdata-installer on ${{ matrix.distro }}, require cloud, no JSON-C
  359. id: build-no-jsonc
  360. if: matrix.jsonc_removal != ''
  361. run: |
  362. docker run --security-opt seccomp=unconfined -w /netdata sha256:${{ steps.load.outputs.image }} \
  363. /bin/sh -c '/rmjsonc.sh && ./netdata-installer.sh --dont-wait --dont-start-it --require-cloud --one-time-build'
  364. - name: Failure Notification
  365. uses: rtCamp/action-slack-notify@v2
  366. env:
  367. SLACK_COLOR: 'danger'
  368. SLACK_FOOTER: ''
  369. SLACK_ICON_EMOJI: ':github-actions:'
  370. SLACK_TITLE: 'Build tests for ${{ matrix.distro }} failed:'
  371. SLACK_USERNAME: 'GitHub Actions'
  372. SLACK_MESSAGE: |-
  373. ${{ github.repository }}: Build tests for ${{ matrix.distro }} failed.
  374. Checkout: ${{ steps.checkout.outcome }}
  375. Fetch test environment: ${{ steps.fetch.outcome }}
  376. Load test environment: ${{ steps.load.outcome }}
  377. Regular build: ${{ steps.build-basic.outcome }}
  378. netdata-installer, disable cloud: ${{ steps.build-no-cloud.outcome }}
  379. netdata-installer, require cloud: ${{ steps.build-cloud.outcome }}
  380. netdata-installer, no JSON-C: ${{ steps.build-no-jsonc.outcome }}
  381. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  382. if: >-
  383. ${{
  384. failure()
  385. && startsWith(github.ref, 'refs/heads/master')
  386. && github.event_name != 'pull_request'
  387. && github.repository == 'netdata/netdata'
  388. }}
  389. updater-check: # Test the generated dist archive using the updater code.
  390. name: Test Generated Distfile and Updater Code
  391. runs-on: ubuntu-latest
  392. needs:
  393. - build-dist
  394. - matrix
  395. - prepare-test-images
  396. strategy:
  397. fail-fast: false
  398. max-parallel: 8
  399. matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
  400. services:
  401. apache: # This gets used to serve the dist tarball for the updater script.
  402. image: httpd:2.4
  403. ports:
  404. - 8080:80
  405. volumes:
  406. - ${{ github.workspace }}:/usr/local/apache2/htdocs/
  407. steps:
  408. - name: Checkout
  409. id: checkout
  410. uses: actions/checkout@v3
  411. - name: Fetch dist tarball artifacts
  412. id: fetch-tarball
  413. uses: actions/download-artifact@v3
  414. with:
  415. name: dist-tarball
  416. path: dist-tarball
  417. - name: Prepare artifact directory
  418. id: prepare
  419. run: |
  420. mkdir -p artifacts || exit 1
  421. echo "9999.0.0-0" > artifacts/latest-version.txt || exit 1
  422. cp dist-tarball/* artifacts || exit 1
  423. cd artifacts || exit 1
  424. ln -s ${{ needs.build-dist.outputs.distfile }} netdata-latest.tar.gz || exit 1
  425. sha256sum -b ./* > "sha256sums.txt" || exit 1
  426. cat sha256sums.txt
  427. - name: Fetch test environment
  428. id: fetch-test-environment
  429. uses: actions/download-artifact@v3
  430. with:
  431. name: ${{ matrix.artifact_key }}-test-env
  432. - name: Load test environment
  433. id: load
  434. run: |
  435. docker load --input image.tar | tee image-info.txt
  436. echo "::set-output name=image::$(cut -d ':' -f 3 image-info.txt)"
  437. - name: Install netdata and run the updater on ${{ matrix.distro }}
  438. id: updater-check
  439. run: |
  440. docker run --security-opt seccomp=unconfined -e DISABLE_TELEMETRY=1 --network host -w /netdata sha256:${{ steps.load.outputs.image }} \
  441. /netdata/.github/scripts/run-updater-check.sh
  442. - name: Failure Notification
  443. uses: rtCamp/action-slack-notify@v2
  444. env:
  445. SLACK_COLOR: 'danger'
  446. SLACK_FOOTER: ''
  447. SLACK_ICON_EMOJI: ':github-actions:'
  448. SLACK_TITLE: 'Updater checks for ${{ matrix.distro }} failed:'
  449. SLACK_USERNAME: 'GitHub Actions'
  450. SLACK_MESSAGE: |-
  451. ${{ github.repository }}: Updater checks for ${{ matrix.distro }} failed.
  452. Checkout: ${{ steps.checkout.outcome }}
  453. Fetch dist tarball: ${{ steps.fetch-tarball.outcome }}
  454. Prepare artifact directory: ${{ steps.prepare.outcome }}
  455. Fetch test environment: ${{ steps.fetch-test-environment.outcome }}
  456. Load test environment: ${{ steps.load.outcome }}
  457. Updater check: ${{ steps.updater-check.outcome }}
  458. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  459. if: >-
  460. ${{
  461. failure()
  462. && startsWith(github.ref, 'refs/heads/master')
  463. && github.event_name != 'pull_request'
  464. && github.repository == 'netdata/netdata'
  465. }}
  466. prepare-upload: # Consolidate the artifacts for uploading or releasing.
  467. name: Prepare Artifacts
  468. runs-on: ubuntu-latest
  469. needs:
  470. - build-dist
  471. - build-static
  472. steps:
  473. - name: Checkout
  474. id: checkout
  475. uses: actions/checkout@v3
  476. - name: Prepare Environment
  477. id: prepare
  478. run: mkdir -p artifacts
  479. - name: Retrieve Dist Tarball
  480. id: fetch-dist
  481. uses: actions/download-artifact@v3
  482. with:
  483. name: dist-tarball
  484. path: dist-tarball
  485. - name: Retrieve Static Build Artifacts
  486. id: fetch-static
  487. uses: actions/download-artifact@v3
  488. with:
  489. name: static-archive
  490. path: static-archive
  491. - name: Prepare Artifacts
  492. id: consolidate
  493. working-directory: ./artifacts/
  494. run: |
  495. mv ../dist-tarball/* . || exit 1
  496. mv ../static-archive/* . || exit 1
  497. ln -s ${{ needs.build-dist.outputs.distfile }} netdata-latest.tar.gz || exit 1
  498. cp ../packaging/version ./latest-version.txt || exit 1
  499. sha256sum -b ./* > sha256sums.txt || exit 1
  500. cat sha256sums.txt
  501. - name: Store Artifacts
  502. id: store
  503. uses: actions/upload-artifact@v3
  504. with:
  505. name: final-artifacts
  506. path: artifacts/*
  507. retention-days: 30
  508. - name: Failure Notification
  509. uses: rtCamp/action-slack-notify@v2
  510. env:
  511. SLACK_COLOR: 'danger'
  512. SLACK_FOOTER: ''
  513. SLACK_ICON_EMOJI: ':github-actions:'
  514. SLACK_TITLE: 'Failed to prepare release artifacts for upload:'
  515. SLACK_USERNAME: 'GitHub Actions'
  516. SLACK_MESSAGE: |-
  517. ${{ github.repository }}: Failed to prepare release artifacts for upload.
  518. CHeckout: ${{ steps.checkout.outcome }}
  519. Prepare environment: ${{ steps.prepare.outcome }}
  520. Fetch dist tarball: ${{ steps.fetch-dist.outcome }}
  521. Fetch static builds: ${{ steps.fetch-static.outcome }}
  522. Consolidate artifacts: ${{ steps.consolidate.outcome }}
  523. Store: ${{ steps.store.outcome }}
  524. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  525. if: >-
  526. ${{
  527. failure()
  528. && startsWith(github.ref, 'refs/heads/master')
  529. && github.event_name != 'pull_request'
  530. && github.repository == 'netdata/netdata'
  531. }}
  532. artifact-verification-dist: # Verify the regular installer works with the consolidated artifacts.
  533. name: Test Consolidated Artifacts (Source)
  534. runs-on: ubuntu-latest
  535. needs:
  536. - prepare-upload
  537. services:
  538. apache: # This gets used to serve the dist tarball for the updater script.
  539. image: httpd:2.4
  540. ports:
  541. - 8080:80
  542. volumes:
  543. - ${{ github.workspace }}:/usr/local/apache2/htdocs/
  544. steps:
  545. - name: Checkout
  546. id: checkout
  547. uses: actions/checkout@v3
  548. - name: Fetch artifacts
  549. id: fetch
  550. uses: actions/download-artifact@v3
  551. with:
  552. name: final-artifacts
  553. path: artifacts
  554. - name: Verify that artifacts work with installer
  555. id: verify
  556. env:
  557. NETDATA_TARBALL_BASEURL: http://localhost:8080/artifacts
  558. run: packaging/installer/kickstart.sh --build-only --dont-start-it --disable-telemetry --dont-wait
  559. - name: Failure Notification
  560. uses: rtCamp/action-slack-notify@v2
  561. env:
  562. SLACK_COLOR: 'danger'
  563. SLACK_FOOTER: ''
  564. SLACK_ICON_EMOJI: ':github-actions:'
  565. SLACK_TITLE: 'Artifact verification for source tarball failed.'
  566. SLACK_USERNAME: 'GitHub Actions'
  567. SLACK_MESSAGE: |-
  568. ${{ github.repository }}: Artifact verification for source tarball failed.
  569. Checkout: ${{ steps.checkout.outcome }}
  570. Fetch artifacts: ${{ steps.fetch.outcome }}
  571. Verify artifacts: ${{ steps.verify.outcome }}
  572. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  573. if: >-
  574. ${{
  575. failure()
  576. && startsWith(github.ref, 'refs/heads/master')
  577. && github.event_name != 'pull_request'
  578. && github.repository == 'netdata/netdata'
  579. }}
  580. artifact-verification-static: # Verify the static installer works with the consolidated artifacts.
  581. name: Test Consolidated Artifacts (Static)
  582. runs-on: ubuntu-latest
  583. needs:
  584. - prepare-upload
  585. services:
  586. apache: # This gets used to serve the static archives.
  587. image: httpd:2.4
  588. ports:
  589. - 8080:80
  590. volumes:
  591. - ${{ github.workspace }}:/usr/local/apache2/htdocs/
  592. steps:
  593. - name: Checkout
  594. id: checkout
  595. uses: actions/checkout@v3
  596. - name: Fetch artifacts
  597. id: fetch-artifacts
  598. uses: actions/download-artifact@v3
  599. with:
  600. name: final-artifacts
  601. path: artifacts
  602. - name: Verify that artifacts work with installer
  603. id: verify
  604. env:
  605. NETDATA_TARBALL_BASEURL: http://localhost:8080/artifacts
  606. run: packaging/installer/kickstart.sh --static-only --dont-start-it --disable-telemetry
  607. - name: Failure Notification
  608. uses: rtCamp/action-slack-notify@v2
  609. env:
  610. SLACK_COLOR: 'danger'
  611. SLACK_FOOTER: ''
  612. SLACK_ICON_EMOJI: ':github-actions:'
  613. SLACK_TITLE: 'Artifact verification for static build failed.'
  614. SLACK_USERNAME: 'GitHub Actions'
  615. SLACK_MESSAGE: |-
  616. ${{ github.repository }}: Artifact verification for static build failed.
  617. Checkout: ${{ steps.checkout.outcome }}
  618. Fetch artifacts: ${{ steps.fetch-artifacts.outcome }}
  619. Verify artifacts: ${{ steps.verify.outcome }}
  620. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  621. if: >-
  622. ${{
  623. failure()
  624. && startsWith(github.ref, 'refs/heads/master')
  625. && github.event_name != 'pull_request'
  626. && github.repository == 'netdata/netdata'
  627. }}
  628. upload-nightly: # Upload the nightly build artifacts to GCS.
  629. name: Upload Nightly Artifacts
  630. runs-on: ubuntu-latest
  631. if: github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'nightly' && github.repository == 'netdata/netdata'
  632. needs:
  633. - updater-check
  634. - source-build
  635. - artifact-verification-dist
  636. - artifact-verification-static
  637. steps:
  638. - name: Retrieve Artifacts
  639. id: fetch
  640. uses: actions/download-artifact@v3
  641. with:
  642. name: final-artifacts
  643. path: final-artifacts
  644. - name: Setup Gcloud
  645. id: gcloud
  646. uses: google-github-actions/setup-gcloud@v0.6.0
  647. with:
  648. project_id: ${{ secrets.GCP_NIGHTLY_STORAGE_PROJECT }}
  649. service_account_key: ${{ secrets.GCP_STORAGE_SERVICE_ACCOUNT_KEY }}
  650. export_default_credentials: true
  651. - name: Upload Artifacts
  652. id: upload
  653. uses: google-github-actions/upload-cloud-storage@v0.10.2
  654. with:
  655. destination: ${{ secrets.GCP_NIGHTLY_STORAGE_BUCKET }}
  656. gzip: false
  657. path: ./final-artifacts
  658. parent: false
  659. - name: Failure Notification
  660. uses: rtCamp/action-slack-notify@v2
  661. env:
  662. SLACK_COLOR: 'danger'
  663. SLACK_FOOTER: ''
  664. SLACK_ICON_EMOJI: ':github-actions:'
  665. SLACK_TITLE: 'Failed to upload nightly release artifacts:'
  666. SLACK_USERNAME: 'GitHub Actions'
  667. SLACK_MESSAGE: |-
  668. ${{ github.repository }}: Failed to upload nightly release artifacts.
  669. Fetch artifacts: ${{ steps.fetch.outcome }}
  670. Setup GCloud: ${{ steps.gcloud.outcome }}
  671. Upload artifacts: ${{ steps.upload.outcome }}
  672. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  673. if: >-
  674. ${{
  675. failure()
  676. && startsWith(github.ref, 'refs/heads/master')
  677. && github.event_name != 'pull_request'
  678. }}
  679. normalize-tag: # Fix the release tag if needed
  680. name: Normalize Release Tag
  681. runs-on: ubuntu-latest
  682. if: github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'release'
  683. outputs:
  684. tag: ${{ steps.tag.outputs.tag }}
  685. steps:
  686. - name: Normalize Tag
  687. id: tag
  688. run: |
  689. if echo ${{ github.event.inputs.version }} | grep -qE '^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+$'; then
  690. echo "::set-output name=tag::v${{ github.event.inputs.version }}"
  691. else
  692. echo "::set-output name=tag::${{ github.event.inputs.version }}"
  693. fi
  694. upload-release: # Create the draft release and upload the build artifacts.
  695. name: Create Release Draft
  696. runs-on: ubuntu-latest
  697. if: github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'release' && github.repository == 'netdata/netdata'
  698. needs:
  699. - updater-check
  700. - source-build
  701. - artifact-verification-dist
  702. - artifact-verification-static
  703. - normalize-tag
  704. steps:
  705. - name: Checkout
  706. id: checkout
  707. uses: actions/checkout@v3
  708. - name: Retrieve Artifacts
  709. id: fetch
  710. uses: actions/download-artifact@v3
  711. with:
  712. name: final-artifacts
  713. path: final-artifacts
  714. - name: Create Release
  715. id: create-release
  716. uses: ncipollo/release-action@v1
  717. with:
  718. allowUpdates: false
  719. artifactErrorsFailBuild: true
  720. artifacts: 'final-artifacts/sha256sums.txt,final-artifacts/netdata-*.tar.gz,final-artifacts/netdata-*.gz.run'
  721. draft: true
  722. tag: ${{ needs.normalize-tag.outputs.tag }}
  723. token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
  724. - name: Failure Notification
  725. uses: rtCamp/action-slack-notify@v2
  726. env:
  727. SLACK_COLOR: 'danger'
  728. SLACK_FOOTER: ''
  729. SLACK_ICON_EMOJI: ':github-actions:'
  730. SLACK_TITLE: 'Failed to draft release:'
  731. SLACK_USERNAME: 'GitHub Actions'
  732. SLACK_MESSAGE: |-
  733. ${{ github.repository }}: Failed to create draft release or attach artifacts.
  734. Checkout: ${{ steps.checkout.outcome }}
  735. Fetch artifacts: ${{ steps.fetch.outcome }}
  736. Create draft release: ${{ steps.create-release.outcome }}
  737. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  738. if: >-
  739. ${{
  740. failure()
  741. && github.event_name == 'workflow_dispatch'
  742. }}
  743. - name: Success Notification
  744. uses: rtCamp/action-slack-notify@v2
  745. env:
  746. SLACK_COLOR: 'good'
  747. SLACK_FOOTER: ''
  748. SLACK_ICON_EMOJI: ':github-actions:'
  749. SLACK_TITLE: 'Created agent draft release:'
  750. SLACK_USERNAME: 'GitHub Actions'
  751. SLACK_MESSAGE: "${{ github.repository }}: ${{ steps.create-release.outputs.html_url }}"
  752. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  753. if: >-
  754. ${{
  755. success()
  756. && github.event_name == 'workflow_dispatch'
  757. }}