build.yml 33 KB

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