build.yml 30 KB

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