build.yml 32 KB

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