build.yml 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839
  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 "distfile=$(find . -name 'netdata-*.tar.gz')" >> "${GITHUB_OUTPUT}"
  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. if: github.event_name != 'pull_request' || ! contains(github.event.pull_request.labels.*.name, 'run-ci/no-cache')
  121. id: cache-key
  122. run: .github/scripts/get-static-cache-key.sh ${{ matrix.arch }} "${{ contains(github.event.pull_request.labels.*.name, 'run-ci/no-cache') }}"
  123. - name: Cache
  124. if: github.event_name != 'pull_request' || ! contains(github.event.pull_request.labels.*.name, 'run-ci/no-cache')
  125. id: cache
  126. uses: actions/cache@v3
  127. with:
  128. path: artifacts/cache
  129. key: ${{ steps.cache-key.outputs.key }}
  130. - name: Build
  131. if: github.event_name != 'workflow_dispatch' # Don’t use retries on PRs.
  132. run: .github/scripts/build-static.sh ${{ matrix.arch }}
  133. - name: Build
  134. if: github.event_name == 'workflow_dispatch'
  135. id: build
  136. uses: nick-fields/retry@v2
  137. with:
  138. timeout_minutes: 180
  139. max_attempts: 3
  140. command: .github/scripts/build-static.sh ${{ matrix.arch }}
  141. - name: Store
  142. id: store
  143. uses: actions/upload-artifact@v3
  144. with:
  145. name: static-archive
  146. path: artifacts/*.gz.run
  147. retention-days: 30
  148. - name: Failure Notification
  149. uses: rtCamp/action-slack-notify@v2
  150. env:
  151. SLACK_COLOR: 'danger'
  152. SLACK_FOOTER: ''
  153. SLACK_ICON_EMOJI: ':github-actions:'
  154. SLACK_TITLE: 'Static build failed:'
  155. SLACK_USERNAME: 'GitHub Actions'
  156. SLACK_MESSAGE: |-
  157. ${{ github.repository }}: Failed to create static installer archive for ${{ matrix.arch }}.
  158. Checkout: ${{ steps.checkout.outcome }}
  159. Fix Tags: ${{ steps.fix-tags.outcome }}
  160. Mark stable: ${{ steps.channel.outcome }}
  161. Build: ${{ steps.build.outcome }}
  162. Store: ${{ steps.store.outcome }}
  163. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  164. if: >-
  165. ${{
  166. failure()
  167. && startsWith(github.ref, 'refs/heads/master')
  168. && github.event_name != 'pull_request'
  169. && github.repository == 'netdata/netdata'
  170. }}
  171. matrix: # Generate the shared build matrix for our build tests.
  172. name: Prepare Build Matrix
  173. runs-on: ubuntu-latest
  174. if: github.event_name != 'workflow_dispatch'
  175. outputs:
  176. matrix: ${{ steps.set-matrix.outputs.matrix }}
  177. steps:
  178. - name: Checkout
  179. id: checkout
  180. uses: actions/checkout@v3
  181. - name: Prepare tools
  182. id: prepare
  183. run: |
  184. sudo apt-get update && sudo apt-get install -y python3-ruamel.yaml
  185. - name: Read build matrix
  186. id: set-matrix
  187. run: |
  188. matrix="$(.github/scripts/gen-matrix-build.py)"
  189. echo "Generated matrix: ${matrix}"
  190. echo "matrix=${matrix}" >> "${GITHUB_OUTPUT}"
  191. - name: Failure Notification
  192. uses: rtCamp/action-slack-notify@v2
  193. env:
  194. SLACK_COLOR: 'danger'
  195. SLACK_FOOTER: ''
  196. SLACK_ICON_EMOJI: ':github-actions:'
  197. SLACK_TITLE: 'Build matrix preparation failed:'
  198. SLACK_USERNAME: 'GitHub Actions'
  199. SLACK_MESSAGE: |-
  200. ${{ github.repository }}: Failed to prepare build matrix for build checks.
  201. Checkout: ${{ steps.checkout.outcome }}
  202. Prepare tools: ${{ steps.prepare.outcome }}
  203. Read build matrix: ${{ steps.set-matrix.outcome }}
  204. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  205. if: >-
  206. ${{
  207. failure()
  208. && startsWith(github.ref, 'refs/heads/master')
  209. && github.event_name != 'pull_request'
  210. && github.repository == 'netdata/netdata'
  211. }}
  212. prepare-test-images: # Prepare the test environments for our build checks. This also checks dependency handling code for each tested environment.
  213. name: Prepare Test Environments
  214. runs-on: ubuntu-latest
  215. if: github.event_name != 'workflow_dispatch'
  216. needs:
  217. - matrix
  218. env:
  219. RETRY_DELAY: 300
  220. strategy:
  221. # Unlike the actual build tests, this completes _very_ fast (average of about 3 minutes for each job), so we
  222. # just run everything in parallel instead lof limiting job concurrency.
  223. fail-fast: false
  224. matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
  225. steps:
  226. - name: Checkout
  227. id: checkout
  228. uses: actions/checkout@v3
  229. - name: Setup Buildx
  230. id: buildx
  231. uses: docker/setup-buildx-action@v2
  232. - name: Build test environment
  233. id: build1
  234. uses: docker/build-push-action@v4
  235. continue-on-error: true # We retry 3 times at 5 minute intervals if there is a failure here.
  236. with:
  237. push: false
  238. load: false
  239. file: .github/dockerfiles/Dockerfile.build_test
  240. build-args: |
  241. BASE=${{ matrix.distro }}
  242. PRE=${{ matrix.env_prep }}
  243. RMJSONC=${{ matrix.jsonc_removal }}
  244. outputs: type=docker,dest=/tmp/image.tar
  245. tags: test:${{ matrix.artifact_key }}
  246. - name: Retry delay
  247. if: ${{ steps.build1.outcome == 'failure' }}
  248. run: sleep "${RETRY_DELAY}"
  249. - name: Build test environment (attempt 2)
  250. if: ${{ steps.build1.outcome == 'failure' }}
  251. id: build2
  252. uses: docker/build-push-action@v4
  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=docker,dest=/tmp/image.tar
  263. tags: test:${{ matrix.artifact_key }}
  264. - name: Retry delay
  265. if: ${{ steps.build1.outcome == 'failure' && steps.build2.outcome == 'failure' }}
  266. run: sleep "${RETRY_DELAY}"
  267. - name: Build test environment (attempt 3)
  268. if: ${{ steps.build1.outcome == 'failure' && steps.build2.outcome == 'failure' }}
  269. id: build3
  270. uses: docker/build-push-action@v4
  271. with:
  272. push: false
  273. load: false
  274. file: .github/dockerfiles/Dockerfile.build_test
  275. build-args: |
  276. BASE=${{ matrix.distro }}
  277. PRE=${{ matrix.env_prep }}
  278. RMJSONC=${{ matrix.jsonc_removal }}
  279. outputs: type=docker,dest=/tmp/image.tar
  280. tags: test:${{ matrix.artifact_key }}
  281. - name: Upload image artifact
  282. id: upload
  283. uses: actions/upload-artifact@v3
  284. with:
  285. name: ${{ matrix.artifact_key }}-test-env
  286. path: /tmp/image.tar
  287. retention-days: 30
  288. - name: Failure Notification
  289. uses: rtCamp/action-slack-notify@v2
  290. env:
  291. SLACK_COLOR: 'danger'
  292. SLACK_FOOTER: ''
  293. SLACK_ICON_EMOJI: ':github-actions:'
  294. SLACK_TITLE: 'Test environment preparation for ${{ matrix.distro }} failed:'
  295. SLACK_USERNAME: 'GitHub Actions'
  296. SLACK_MESSAGE: |-
  297. ${{ github.repository }}: Test environment preparation for ${{ matrix.distro }} failed.
  298. Checkout: ${{ steps.checkout.outcome }}
  299. Set up Buildx: ${{ steps.buildx.outcome }}
  300. Build test environment: ${{ steps.build1.outcome }}
  301. Build test environment (attempt 2): ${{ steps.build2.outcome }}
  302. Build test environment (attempt 3): ${{ steps.build3.outcome }}
  303. Upload: ${{ steps.upload.outcome }}
  304. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  305. if: >-
  306. ${{
  307. failure()
  308. && startsWith(github.ref, 'refs/heads/master')
  309. && github.event_name != 'pull_request'
  310. && github.repository == 'netdata/netdata'
  311. }}
  312. source-build: # Test various source build arrangements.
  313. name: Test Source Build
  314. runs-on: ubuntu-latest
  315. if: github.event_name != 'workflow_dispatch'
  316. needs:
  317. - matrix
  318. - prepare-test-images
  319. strategy:
  320. fail-fast: false
  321. max-parallel: 8
  322. matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
  323. steps:
  324. - name: Checkout
  325. id: checkout
  326. uses: actions/checkout@v3
  327. with:
  328. submodules: recursive
  329. - name: Fetch test environment
  330. id: fetch
  331. uses: actions/download-artifact@v3
  332. with:
  333. name: ${{ matrix.artifact_key }}-test-env
  334. - name: Load test environment
  335. id: load
  336. run: docker load --input image.tar
  337. - name: Regular build on ${{ matrix.distro }}
  338. id: build-basic
  339. run: |
  340. docker run --security-opt seccomp=unconfined -w /netdata test:${{ matrix.artifact_key }} \
  341. /bin/sh -c 'autoreconf -ivf && ./configure --disable-dependency-tracking && make -j2'
  342. - name: netdata-installer on ${{ matrix.distro }}, disable cloud
  343. id: build-no-cloud
  344. run: |
  345. docker run --security-opt seccomp=unconfined -w /netdata test:${{ matrix.artifact_key }} \
  346. /bin/sh -c './netdata-installer.sh --dont-wait --dont-start-it --disable-cloud --one-time-build'
  347. - name: netdata-installer on ${{ matrix.distro }}, require cloud
  348. id: build-cloud
  349. run: |
  350. docker run --security-opt seccomp=unconfined -w /netdata test:${{ matrix.artifact_key }} \
  351. /bin/sh -c './netdata-installer.sh --dont-wait --dont-start-it --require-cloud --one-time-build'
  352. - name: netdata-installer on ${{ matrix.distro }}, require cloud, no JSON-C
  353. id: build-no-jsonc
  354. if: matrix.jsonc_removal != ''
  355. run: |
  356. docker run --security-opt seccomp=unconfined -w /netdata test:${{ matrix.artifact_key }} \
  357. /bin/sh -c '/rmjsonc.sh && ./netdata-installer.sh --dont-wait --dont-start-it --require-cloud --one-time-build'
  358. - name: Failure Notification
  359. uses: rtCamp/action-slack-notify@v2
  360. env:
  361. SLACK_COLOR: 'danger'
  362. SLACK_FOOTER: ''
  363. SLACK_ICON_EMOJI: ':github-actions:'
  364. SLACK_TITLE: 'Build tests for ${{ matrix.distro }} failed:'
  365. SLACK_USERNAME: 'GitHub Actions'
  366. SLACK_MESSAGE: |-
  367. ${{ github.repository }}: Build tests for ${{ matrix.distro }} failed.
  368. Checkout: ${{ steps.checkout.outcome }}
  369. Fetch test environment: ${{ steps.fetch.outcome }}
  370. Load test environment: ${{ steps.load.outcome }}
  371. Regular build: ${{ steps.build-basic.outcome }}
  372. netdata-installer, disable cloud: ${{ steps.build-no-cloud.outcome }}
  373. netdata-installer, require cloud: ${{ steps.build-cloud.outcome }}
  374. netdata-installer, no JSON-C: ${{ steps.build-no-jsonc.outcome }}
  375. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  376. if: >-
  377. ${{
  378. failure()
  379. && startsWith(github.ref, 'refs/heads/master')
  380. && github.event_name != 'pull_request'
  381. && github.repository == 'netdata/netdata'
  382. }}
  383. updater-check: # Test the generated dist archive using the updater code.
  384. name: Test Generated Distfile and Updater Code
  385. runs-on: ubuntu-latest
  386. if: github.event_name != 'workflow_dispatch'
  387. needs:
  388. - build-dist
  389. - matrix
  390. - prepare-test-images
  391. strategy:
  392. fail-fast: false
  393. max-parallel: 8
  394. matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
  395. services:
  396. apache: # This gets used to serve the dist tarball for the updater script.
  397. image: httpd:2.4
  398. ports:
  399. - 8080:80
  400. volumes:
  401. - ${{ github.workspace }}:/usr/local/apache2/htdocs/
  402. steps:
  403. - name: Checkout
  404. id: checkout
  405. uses: actions/checkout@v3
  406. - name: Fetch dist tarball artifacts
  407. id: fetch-tarball
  408. uses: actions/download-artifact@v3
  409. with:
  410. name: dist-tarball
  411. path: dist-tarball
  412. - name: Prepare artifact directory
  413. id: prepare
  414. run: |
  415. mkdir -p artifacts/download/latest || exit 1
  416. echo "9999.0.0-0" > artifacts/download/latest/latest-version.txt || exit 1
  417. cp dist-tarball/* artifacts/download/latest || exit 1
  418. cd artifacts/download/latest || exit 1
  419. ln -s ${{ needs.build-dist.outputs.distfile }} netdata-latest.tar.gz || exit 1
  420. sha256sum -b ./* > "sha256sums.txt" || exit 1
  421. cat sha256sums.txt
  422. - name: Fetch test environment
  423. id: fetch-test-environment
  424. uses: actions/download-artifact@v3
  425. with:
  426. name: ${{ matrix.artifact_key }}-test-env
  427. - name: Load test environment
  428. id: load
  429. run: docker load --input image.tar
  430. - name: Install netdata and run the updater on ${{ matrix.distro }}
  431. id: updater-check
  432. run: |
  433. docker run --security-opt seccomp=unconfined -e DISABLE_TELEMETRY=1 --network host -w /netdata test:${{ matrix.artifact_key }} \
  434. /netdata/.github/scripts/run-updater-check.sh
  435. - name: Failure Notification
  436. uses: rtCamp/action-slack-notify@v2
  437. env:
  438. SLACK_COLOR: 'danger'
  439. SLACK_FOOTER: ''
  440. SLACK_ICON_EMOJI: ':github-actions:'
  441. SLACK_TITLE: 'Updater checks for ${{ matrix.distro }} failed:'
  442. SLACK_USERNAME: 'GitHub Actions'
  443. SLACK_MESSAGE: |-
  444. ${{ github.repository }}: Updater checks for ${{ matrix.distro }} failed.
  445. Checkout: ${{ steps.checkout.outcome }}
  446. Fetch dist tarball: ${{ steps.fetch-tarball.outcome }}
  447. Prepare artifact directory: ${{ steps.prepare.outcome }}
  448. Fetch test environment: ${{ steps.fetch-test-environment.outcome }}
  449. Load test environment: ${{ steps.load.outcome }}
  450. Updater check: ${{ steps.updater-check.outcome }}
  451. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  452. if: >-
  453. ${{
  454. failure()
  455. && startsWith(github.ref, 'refs/heads/master')
  456. && github.event_name != 'pull_request'
  457. && github.repository == 'netdata/netdata'
  458. }}
  459. prepare-upload: # Consolidate the artifacts for uploading or releasing.
  460. name: Prepare Artifacts
  461. runs-on: ubuntu-latest
  462. needs:
  463. - build-dist
  464. - build-static
  465. steps:
  466. - name: Checkout
  467. id: checkout
  468. uses: actions/checkout@v3
  469. - name: Prepare Environment
  470. id: prepare
  471. run: mkdir -p artifacts
  472. - name: Retrieve Dist Tarball
  473. id: fetch-dist
  474. uses: actions/download-artifact@v3
  475. with:
  476. name: dist-tarball
  477. path: dist-tarball
  478. - name: Retrieve Static Build Artifacts
  479. id: fetch-static
  480. uses: actions/download-artifact@v3
  481. with:
  482. name: static-archive
  483. path: static-archive
  484. - name: Prepare Artifacts
  485. id: consolidate
  486. working-directory: ./artifacts/
  487. run: |
  488. mv ../dist-tarball/* . || exit 1
  489. mv ../static-archive/* . || exit 1
  490. ln -s ${{ needs.build-dist.outputs.distfile }} netdata-latest.tar.gz || exit 1
  491. cp ../packaging/version ./latest-version.txt || exit 1
  492. sha256sum -b ./* > sha256sums.txt || exit 1
  493. cat sha256sums.txt
  494. - name: Store Artifacts
  495. id: store
  496. uses: actions/upload-artifact@v3
  497. with:
  498. name: final-artifacts
  499. path: artifacts/*
  500. retention-days: 30
  501. - name: Failure Notification
  502. uses: rtCamp/action-slack-notify@v2
  503. env:
  504. SLACK_COLOR: 'danger'
  505. SLACK_FOOTER: ''
  506. SLACK_ICON_EMOJI: ':github-actions:'
  507. SLACK_TITLE: 'Failed to prepare release artifacts for upload:'
  508. SLACK_USERNAME: 'GitHub Actions'
  509. SLACK_MESSAGE: |-
  510. ${{ github.repository }}: Failed to prepare release artifacts for upload.
  511. CHeckout: ${{ steps.checkout.outcome }}
  512. Prepare environment: ${{ steps.prepare.outcome }}
  513. Fetch dist tarball: ${{ steps.fetch-dist.outcome }}
  514. Fetch static builds: ${{ steps.fetch-static.outcome }}
  515. Consolidate artifacts: ${{ steps.consolidate.outcome }}
  516. Store: ${{ steps.store.outcome }}
  517. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  518. if: >-
  519. ${{
  520. failure()
  521. && startsWith(github.ref, 'refs/heads/master')
  522. && github.event_name != 'pull_request'
  523. && github.repository == 'netdata/netdata'
  524. }}
  525. artifact-verification-dist: # Verify the regular installer works with the consolidated artifacts.
  526. name: Test Consolidated Artifacts (Source)
  527. runs-on: ubuntu-latest
  528. needs:
  529. - prepare-upload
  530. services:
  531. apache: # This gets used to serve the dist tarball for the updater script.
  532. image: httpd:2.4
  533. ports:
  534. - 8080:80
  535. volumes:
  536. - ${{ github.workspace }}:/usr/local/apache2/htdocs/
  537. steps:
  538. - name: Checkout
  539. id: checkout
  540. uses: actions/checkout@v3
  541. - name: Fetch artifacts
  542. id: fetch
  543. uses: actions/download-artifact@v3
  544. with:
  545. name: final-artifacts
  546. path: artifacts
  547. - name: Prepare artifacts directory
  548. id: prepare
  549. run: |
  550. mkdir -p download/latest
  551. mv artifacts/* download/latest
  552. - name: Verify that artifacts work with installer
  553. id: verify
  554. env:
  555. NETDATA_TARBALL_BASEURL: http://localhost:8080/
  556. run: packaging/installer/kickstart.sh --build-only --dont-start-it --disable-telemetry --dont-wait
  557. - name: Failure Notification
  558. uses: rtCamp/action-slack-notify@v2
  559. env:
  560. SLACK_COLOR: 'danger'
  561. SLACK_FOOTER: ''
  562. SLACK_ICON_EMOJI: ':github-actions:'
  563. SLACK_TITLE: 'Artifact verification for source tarball failed.'
  564. SLACK_USERNAME: 'GitHub Actions'
  565. SLACK_MESSAGE: |-
  566. ${{ github.repository }}: Artifact verification for source tarball failed.
  567. Checkout: ${{ steps.checkout.outcome }}
  568. Fetch artifacts: ${{ steps.fetch.outcome }}
  569. Verify artifacts: ${{ steps.verify.outcome }}
  570. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  571. if: >-
  572. ${{
  573. failure()
  574. && startsWith(github.ref, 'refs/heads/master')
  575. && github.event_name != 'pull_request'
  576. && github.repository == 'netdata/netdata'
  577. }}
  578. artifact-verification-static: # Verify the static installer works with the consolidated artifacts.
  579. name: Test Consolidated Artifacts (Static)
  580. runs-on: ubuntu-latest
  581. needs:
  582. - prepare-upload
  583. services:
  584. apache: # This gets used to serve the static archives.
  585. image: httpd:2.4
  586. ports:
  587. - 8080:80
  588. volumes:
  589. - ${{ github.workspace }}:/usr/local/apache2/htdocs/
  590. steps:
  591. - name: Checkout
  592. id: checkout
  593. uses: actions/checkout@v3
  594. - name: Fetch artifacts
  595. id: fetch-artifacts
  596. uses: actions/download-artifact@v3
  597. with:
  598. name: final-artifacts
  599. path: artifacts
  600. - name: Prepare artifacts directory
  601. id: prepare
  602. run: |
  603. mkdir -p download/latest
  604. mv artifacts/* download/latest
  605. - name: Verify that artifacts work with installer
  606. id: verify
  607. env:
  608. NETDATA_TARBALL_BASEURL: http://localhost:8080/
  609. run: packaging/installer/kickstart.sh --static-only --dont-start-it --disable-telemetry
  610. - name: Failure Notification
  611. uses: rtCamp/action-slack-notify@v2
  612. env:
  613. SLACK_COLOR: 'danger'
  614. SLACK_FOOTER: ''
  615. SLACK_ICON_EMOJI: ':github-actions:'
  616. SLACK_TITLE: 'Artifact verification for static build failed.'
  617. SLACK_USERNAME: 'GitHub Actions'
  618. SLACK_MESSAGE: |-
  619. ${{ github.repository }}: Artifact verification for static build failed.
  620. Checkout: ${{ steps.checkout.outcome }}
  621. Fetch artifacts: ${{ steps.fetch-artifacts.outcome }}
  622. Verify artifacts: ${{ steps.verify.outcome }}
  623. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  624. if: >-
  625. ${{
  626. failure()
  627. && startsWith(github.ref, 'refs/heads/master')
  628. && github.event_name != 'pull_request'
  629. && github.repository == 'netdata/netdata'
  630. }}
  631. upload-nightly: # Upload the nightly build artifacts to GCS.
  632. name: Upload Nightly Artifacts
  633. runs-on: ubuntu-latest
  634. if: github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'nightly' && github.repository == 'netdata/netdata'
  635. needs:
  636. - artifact-verification-dist
  637. - artifact-verification-static
  638. steps:
  639. - name: Retrieve Artifacts
  640. id: fetch
  641. uses: actions/download-artifact@v3
  642. with:
  643. name: final-artifacts
  644. path: final-artifacts
  645. - name: Authenticate to GCS
  646. id: gcs-auth
  647. uses: google-github-actions/auth@v1
  648. with:
  649. project_id: ${{ secrets.GCP_NIGHTLY_STORAGE_PROJECT }}
  650. credentials_json: ${{ secrets.GCS_STORAGE_SERVICE_KEY_JSON }}
  651. - name: Setup GCS
  652. id: gcs-setup
  653. uses: google-github-actions/setup-gcloud@v1.1.0
  654. - name: Upload Artifacts
  655. id: upload
  656. uses: google-github-actions/upload-cloud-storage@v1.0.1
  657. with:
  658. destination: ${{ secrets.GCP_NIGHTLY_STORAGE_BUCKET }}
  659. gzip: false
  660. path: ./final-artifacts
  661. parent: false
  662. - name: Failure Notification
  663. uses: rtCamp/action-slack-notify@v2
  664. env:
  665. SLACK_COLOR: 'danger'
  666. SLACK_FOOTER: ''
  667. SLACK_ICON_EMOJI: ':github-actions:'
  668. SLACK_TITLE: 'Failed to upload nightly release artifacts:'
  669. SLACK_USERNAME: 'GitHub Actions'
  670. SLACK_MESSAGE: |-
  671. ${{ github.repository }}: Failed to upload nightly release artifacts.
  672. Fetch artifacts: ${{ steps.fetch.outcome }}
  673. Authenticatie GCS: ${{ steps.gcs-auth.outcome }}
  674. Setup GCS: ${{ steps.gcs-setup.outcome }}
  675. Upload artifacts: ${{ steps.upload.outcome }}
  676. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  677. if: >-
  678. ${{
  679. failure()
  680. && startsWith(github.ref, 'refs/heads/master')
  681. && github.event_name != 'pull_request'
  682. }}
  683. create-nightly: # Create a nightly build release in netdata/netdata-nightlies
  684. name: Create Nightly Release
  685. runs-on: ubuntu-latest
  686. if: github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'nightly' && github.repository == 'netdata/netdata'
  687. needs:
  688. - artifact-verification-dist
  689. - artifact-verification-static
  690. steps:
  691. - name: Checkout Main Repo
  692. id: checkout-main
  693. uses: actions/checkout@v3
  694. with:
  695. path: main
  696. - name: Checkout Nightly Repo
  697. id: checkout-nightly
  698. uses: actions/checkout@v3
  699. with:
  700. repository: netdata/netdata-nightlies
  701. path: nightlies
  702. token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
  703. - name: Retrieve Artifacts
  704. id: fetch
  705. uses: actions/download-artifact@v3
  706. with:
  707. name: final-artifacts
  708. path: final-artifacts
  709. - name: Prepare version info
  710. id: version
  711. run: |
  712. # shellcheck disable=SC2129
  713. echo "version=$(cat main/packaging/version)" >> "${GITHUB_OUTPUT}"
  714. echo "commit=$(cd nightlies && git rev-parse HEAD)" >> "${GITHUB_OUTPUT}"
  715. echo "date=$(date +%F)" >> "${GITHUB_OUTPUT}"
  716. - name: Create Release
  717. id: create-release
  718. uses: ncipollo/release-action@v1
  719. with:
  720. allowUpdates: false
  721. artifactErrorsFailBuild: true
  722. artifacts: 'final-artifacts/sha256sums.txt,final-artifacts/netdata-*.tar.gz,final-artifacts/netdata-*.gz.run'
  723. owner: netdata
  724. repo: netdata-nightlies
  725. body: Netdata nightly build for ${{ steps.version.outputs.date }}.
  726. commit: ${{ steps.version.outputs.commit }}
  727. makeLatest: true
  728. tag: ${{ steps.version.outputs.version }}
  729. token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
  730. - name: Failure Notification
  731. uses: rtCamp/action-slack-notify@v2
  732. env:
  733. SLACK_COLOR: 'danger'
  734. SLACK_FOOTER: ''
  735. SLACK_ICON_EMOJI: ':github-actions:'
  736. SLACK_TITLE: 'Failed to draft release:'
  737. SLACK_USERNAME: 'GitHub Actions'
  738. SLACK_MESSAGE: |-
  739. ${{ github.repository }}: Failed to create nightly release or attach artifacts.
  740. Checkout netdata/netdata: ${{ steps.checkout-main.outcome }}
  741. Checkout netdata/netdata-nightlies: ${{ steps.checkout-nightly.outcome }}
  742. Fetch artifacts: ${{ steps.fetch.outcome }}
  743. Prepare version info: ${{ steps.version.outcome }}
  744. Create release: ${{ steps.create-release.outcome }}
  745. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  746. if: >-
  747. ${{
  748. failure()
  749. && github.event_name == 'workflow_dispatch'
  750. }}
  751. normalize-tag: # Fix the release tag if needed
  752. name: Normalize Release Tag
  753. runs-on: ubuntu-latest
  754. if: github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'release'
  755. outputs:
  756. tag: ${{ steps.tag.outputs.tag }}
  757. steps:
  758. - name: Normalize Tag
  759. id: tag
  760. run: |
  761. if echo ${{ github.event.inputs.version }} | grep -qE '^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+$'; then
  762. echo "tag=v${{ github.event.inputs.version }}" >> "${GITHUB_OUTPUT}"
  763. else
  764. echo "tag=${{ github.event.inputs.version }}" >> "${GITHUB_OUTPUT}"
  765. fi
  766. upload-release: # Create the draft release and upload the build artifacts.
  767. name: Create Release Draft
  768. runs-on: ubuntu-latest
  769. if: github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'release' && github.repository == 'netdata/netdata'
  770. needs:
  771. - artifact-verification-dist
  772. - artifact-verification-static
  773. - normalize-tag
  774. steps:
  775. - name: Checkout
  776. id: checkout
  777. uses: actions/checkout@v3
  778. - name: Retrieve Artifacts
  779. id: fetch
  780. uses: actions/download-artifact@v3
  781. with:
  782. name: final-artifacts
  783. path: final-artifacts
  784. - name: Create Release
  785. id: create-release
  786. uses: ncipollo/release-action@v1
  787. with:
  788. allowUpdates: false
  789. artifactErrorsFailBuild: true
  790. artifacts: 'final-artifacts/sha256sums.txt,final-artifacts/netdata-*.tar.gz,final-artifacts/netdata-*.gz.run'
  791. draft: true
  792. tag: ${{ needs.normalize-tag.outputs.tag }}
  793. token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
  794. - name: Failure Notification
  795. uses: rtCamp/action-slack-notify@v2
  796. env:
  797. SLACK_COLOR: 'danger'
  798. SLACK_FOOTER: ''
  799. SLACK_ICON_EMOJI: ':github-actions:'
  800. SLACK_TITLE: 'Failed to draft release:'
  801. SLACK_USERNAME: 'GitHub Actions'
  802. SLACK_MESSAGE: |-
  803. ${{ github.repository }}: Failed to create draft release or attach artifacts.
  804. Checkout: ${{ steps.checkout.outcome }}
  805. Fetch artifacts: ${{ steps.fetch.outcome }}
  806. Create draft release: ${{ steps.create-release.outcome }}
  807. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  808. if: >-
  809. ${{
  810. failure()
  811. && github.event_name == 'workflow_dispatch'
  812. }}
  813. - name: Success Notification
  814. uses: rtCamp/action-slack-notify@v2
  815. env:
  816. SLACK_COLOR: 'good'
  817. SLACK_FOOTER: ''
  818. SLACK_ICON_EMOJI: ':github-actions:'
  819. SLACK_TITLE: 'Created agent draft release:'
  820. SLACK_USERNAME: 'GitHub Actions'
  821. SLACK_MESSAGE: "${{ github.repository }}: ${{ steps.create-release.outputs.html_url }}"
  822. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  823. if: >-
  824. ${{
  825. success()
  826. && github.event_name == 'workflow_dispatch'
  827. }}