build.yml 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039
  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. file-check: # Check what files changed if we’re being run in a PR or on a push.
  24. name: Check Modified Files
  25. runs-on: ubuntu-latest
  26. outputs:
  27. run: ${{ steps.check-run.outputs.run }}
  28. steps:
  29. - name: Checkout
  30. id: checkout
  31. uses: actions/checkout@v4
  32. with:
  33. fetch-depth: 0
  34. submodules: recursive
  35. - name: Check files
  36. id: check-files
  37. uses: tj-actions/changed-files@v43
  38. with:
  39. since_last_remote_commit: ${{ github.event_name != 'pull_request' }}
  40. files: |
  41. **/*.c
  42. **/*.cc
  43. **/*.h
  44. **/*.hh
  45. **/*.in
  46. **/*.patch
  47. **/*.cmake
  48. CMakeLists.txt
  49. netdata-installer.sh
  50. .github/data/distros.yml
  51. .github/workflows/build.yml
  52. .github/scripts/build-static.sh
  53. .github/scripts/get-static-cache-key.sh
  54. .github/scripts/gen-matrix-build.py
  55. .github/scripts/run-updater-check.sh
  56. packaging/cmake/
  57. packaging/makeself/
  58. packaging/installer/
  59. packaging/*.sh
  60. packaging/*.version
  61. packaging/*.checksums
  62. src/aclk/aclk-schemas/
  63. src/ml/dlib/
  64. src/fluent-bit/
  65. src/web/server/h2o/libh2o/
  66. files_ignore: |
  67. netdata.spec.in
  68. **/*.md
  69. - name: List all changed files in pattern
  70. continue-on-error: true
  71. env:
  72. ALL_CHANGED_FILES: ${{ steps.check-files.outputs.all_changed_files }}
  73. run: |
  74. for file in ${ALL_CHANGED_FILES}; do
  75. echo "$file was changed"
  76. done
  77. - name: Check Run
  78. id: check-run
  79. run: |
  80. if [ "${{ steps.check-files.outputs.any_modified }}" == "true" ] || [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
  81. echo 'run=true' >> "${GITHUB_OUTPUT}"
  82. else
  83. echo 'run=false' >> "${GITHUB_OUTPUT}"
  84. fi
  85. build-dist: # Build the distribution tarball and store it as an artifact.
  86. name: Build Distribution Tarball
  87. runs-on: ubuntu-latest
  88. needs:
  89. - file-check
  90. outputs:
  91. distfile: ${{ steps.build.outputs.distfile }}
  92. steps:
  93. - name: Skip Check
  94. id: skip
  95. if: needs.file-check.outputs.run != 'true'
  96. run: echo "SKIPPED"
  97. - name: Checkout
  98. id: checkout
  99. if: needs.file-check.outputs.run == 'true'
  100. uses: actions/checkout@v4
  101. with:
  102. fetch-depth: 0
  103. submodules: recursive
  104. - name: Fix tags
  105. id: fix-tags
  106. if: github.event_name != 'push' && needs.file-check.outputs.run == 'true'
  107. run: |
  108. git fetch --tags --force
  109. - name: Mark Stable
  110. id: channel
  111. if: github.event_name == 'workflow_dispatch' && github.event.inputs.type != 'nightly' && needs.file-check.outputs.run == 'true'
  112. run: |
  113. sed -i 's/^RELEASE_CHANNEL="nightly"/RELEASE_CHANNEL="stable"/' netdata-installer.sh
  114. - name: Build
  115. id: build
  116. if: needs.file-check.outputs.run == 'true'
  117. run: |
  118. mkdir -p artifacts/
  119. tar --create --file "artifacts/netdata-$(git describe).tar.gz" \
  120. --sort=name --posix --auto-compress --exclude=artifacts/ --exclude=.git \
  121. --exclude=.gitignore --exclude=.gitattributes --exclude=.gitmodules \
  122. --transform "s/^\\.\\//netdata-$(git describe)\\//" --verbose .
  123. cd artifacts/
  124. echo "distfile=$(find . -name 'netdata-*.tar.gz')" >> "${GITHUB_OUTPUT}"
  125. - name: Store
  126. id: store
  127. if: needs.file-check.outputs.run == 'true'
  128. uses: actions/upload-artifact@v4
  129. with:
  130. name: dist-tarball
  131. path: artifacts/*.tar.gz
  132. retention-days: 30
  133. - name: Failure Notification
  134. uses: rtCamp/action-slack-notify@v2
  135. env:
  136. SLACK_COLOR: 'danger'
  137. SLACK_FOOTER: ''
  138. SLACK_ICON_EMOJI: ':github-actions:'
  139. SLACK_TITLE: 'Distribution tarball creation failed:'
  140. SLACK_USERNAME: 'GitHub Actions'
  141. SLACK_MESSAGE: |-
  142. ${{ github.repository }}: Failed to create source tarball for distribution.
  143. Checkout: ${{ steps.checkout.outcome }}
  144. Fix Tags: ${{ steps.fix-tags.outcome }}
  145. Mark stable: ${{ steps.channel.outcome }}
  146. Build: ${{ steps.build.outcome }}
  147. Store: ${{ steps.store.outcome }}
  148. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  149. if: >-
  150. ${{
  151. failure()
  152. && startsWith(github.ref, 'refs/heads/master')
  153. && github.event_name != 'pull_request'
  154. && github.repository == 'netdata/netdata'
  155. && needs.file-check.outputs.run == 'true'
  156. }}
  157. build-static: # Build the static binary archives, and store them as artifacts.
  158. name: Build Static
  159. runs-on: ubuntu-latest
  160. needs:
  161. - file-check
  162. strategy:
  163. matrix:
  164. arch:
  165. - x86_64
  166. - armv6l
  167. - armv7l
  168. - aarch64
  169. - ppc64le
  170. steps:
  171. - name: Skip Check
  172. id: skip
  173. if: needs.file-check.outputs.run != 'true'
  174. run: echo "SKIPPED"
  175. - name: Checkout
  176. id: checkout
  177. if: needs.file-check.outputs.run == 'true'
  178. uses: actions/checkout@v4
  179. with:
  180. fetch-depth: 0
  181. submodules: recursive
  182. - name: Fix tags
  183. id: fix-tags
  184. if: github.event_name != 'push' && needs.file-check.outputs.run == 'true'
  185. run: |
  186. git fetch --tags --force
  187. - name: Mark Stable
  188. id: channel
  189. if: github.event_name == 'workflow_dispatch' && github.event.inputs.type != 'nightly' && needs.file-check.outputs.run == 'true'
  190. run: |
  191. sed -i 's/^RELEASE_CHANNEL="nightly"/RELEASE_CHANNEL="stable"/' netdata-installer.sh packaging/makeself/install-or-update.sh
  192. - name: Get Cache Key
  193. if: (github.event_name != 'pull_request' || ! contains(github.event.pull_request.labels.*.name, 'run-ci/no-cache')) && needs.file-check.outputs.run == 'true'
  194. id: cache-key
  195. run: .github/scripts/get-static-cache-key.sh ${{ matrix.arch }} "${{ contains(github.event.pull_request.labels.*.name, 'run-ci/no-cache') }}"
  196. - name: Cache
  197. if: (github.event_name != 'pull_request' || ! contains(github.event.pull_request.labels.*.name, 'run-ci/no-cache')) && needs.file-check.outputs.run == 'true'
  198. id: cache
  199. uses: actions/cache@v4
  200. with:
  201. path: artifacts/cache
  202. key: ${{ steps.cache-key.outputs.key }}
  203. - name: Build
  204. if: github.event_name != 'workflow_dispatch' && needs.file-check.outputs.run == 'true' # Don’t use retries on PRs.
  205. run: .github/scripts/build-static.sh ${{ matrix.arch }}
  206. - name: Build
  207. if: github.event_name == 'workflow_dispatch' && needs.file-check.outputs.run == 'true'
  208. id: build
  209. uses: nick-fields/retry@v3
  210. with:
  211. timeout_minutes: 180
  212. max_attempts: 3
  213. command: .github/scripts/build-static.sh ${{ matrix.arch }}
  214. - name: Store
  215. id: store
  216. if: needs.file-check.outputs.run == 'true'
  217. uses: actions/upload-artifact@v4
  218. with:
  219. name: dist-static-${{ matrix.arch }}
  220. path: artifacts/*.gz.run
  221. retention-days: 30
  222. - name: Failure Notification
  223. uses: rtCamp/action-slack-notify@v2
  224. env:
  225. SLACK_COLOR: 'danger'
  226. SLACK_FOOTER: ''
  227. SLACK_ICON_EMOJI: ':github-actions:'
  228. SLACK_TITLE: 'Static build failed:'
  229. SLACK_USERNAME: 'GitHub Actions'
  230. SLACK_MESSAGE: |-
  231. ${{ github.repository }}: Failed to create static installer archive for ${{ matrix.arch }}.
  232. Checkout: ${{ steps.checkout.outcome }}
  233. Fix Tags: ${{ steps.fix-tags.outcome }}
  234. Mark stable: ${{ steps.channel.outcome }}
  235. Build: ${{ steps.build.outcome }}
  236. Store: ${{ steps.store.outcome }}
  237. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  238. if: >-
  239. ${{
  240. failure()
  241. && startsWith(github.ref, 'refs/heads/master')
  242. && github.event_name != 'pull_request'
  243. && github.repository == 'netdata/netdata'
  244. && needs.file-check.outputs.run == 'true'
  245. }}
  246. matrix: # Generate the shared build matrix for our build tests.
  247. name: Prepare Build Matrix
  248. runs-on: ubuntu-latest
  249. if: github.event_name != 'workflow_dispatch'
  250. outputs:
  251. matrix: ${{ steps.set-matrix.outputs.matrix }}
  252. steps:
  253. - name: Checkout
  254. id: checkout
  255. uses: actions/checkout@v4
  256. - name: Prepare tools
  257. id: prepare
  258. run: |
  259. sudo apt-get update && sudo apt-get install -y python3-ruamel.yaml
  260. - name: Read build matrix
  261. id: set-matrix
  262. run: |
  263. matrix="$(.github/scripts/gen-matrix-build.py)"
  264. echo "Generated matrix: ${matrix}"
  265. echo "matrix=${matrix}" >> "${GITHUB_OUTPUT}"
  266. - name: Failure Notification
  267. uses: rtCamp/action-slack-notify@v2
  268. env:
  269. SLACK_COLOR: 'danger'
  270. SLACK_FOOTER: ''
  271. SLACK_ICON_EMOJI: ':github-actions:'
  272. SLACK_TITLE: 'Build matrix preparation failed:'
  273. SLACK_USERNAME: 'GitHub Actions'
  274. SLACK_MESSAGE: |-
  275. ${{ github.repository }}: Failed to prepare build matrix for build checks.
  276. Checkout: ${{ steps.checkout.outcome }}
  277. Prepare tools: ${{ steps.prepare.outcome }}
  278. Read build matrix: ${{ steps.set-matrix.outcome }}
  279. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  280. if: >-
  281. ${{
  282. failure()
  283. && startsWith(github.ref, 'refs/heads/master')
  284. && github.event_name != 'pull_request'
  285. && github.repository == 'netdata/netdata'
  286. }}
  287. prepare-test-images: # Prepare the test environments for our build checks. This also checks dependency handling code for each tested environment.
  288. name: Prepare Test Environments
  289. runs-on: ubuntu-latest
  290. if: github.event_name != 'workflow_dispatch'
  291. needs:
  292. - matrix
  293. env:
  294. RETRY_DELAY: 300
  295. strategy:
  296. # Unlike the actual build tests, this completes _very_ fast (average of about 3 minutes for each job), so we
  297. # just run everything in parallel instead lof limiting job concurrency.
  298. fail-fast: false
  299. matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
  300. steps:
  301. - name: Checkout
  302. id: checkout
  303. uses: actions/checkout@v4
  304. - name: Setup Buildx
  305. id: buildx
  306. uses: docker/setup-buildx-action@v3
  307. - name: Build test environment
  308. id: build1
  309. uses: docker/build-push-action@v5
  310. continue-on-error: true # We retry 3 times at 5 minute intervals if there is a failure here.
  311. with:
  312. push: false
  313. load: false
  314. file: .github/dockerfiles/Dockerfile.build_test
  315. build-args: |
  316. BASE=${{ matrix.distro }}
  317. PRE=${{ matrix.env_prep }}
  318. RMJSONC=${{ matrix.jsonc_removal }}
  319. outputs: type=docker,dest=/tmp/image.tar
  320. tags: test:${{ matrix.artifact_key }}
  321. - name: Retry delay
  322. if: ${{ steps.build1.outcome == 'failure' }}
  323. run: sleep "${RETRY_DELAY}"
  324. - name: Build test environment (attempt 2)
  325. if: ${{ steps.build1.outcome == 'failure' }}
  326. id: build2
  327. uses: docker/build-push-action@v5
  328. continue-on-error: true # We retry 3 times at 5 minute intervals if there is a failure here.
  329. with:
  330. push: false
  331. load: false
  332. file: .github/dockerfiles/Dockerfile.build_test
  333. build-args: |
  334. BASE=${{ matrix.distro }}
  335. PRE=${{ matrix.env_prep }}
  336. RMJSONC=${{ matrix.jsonc_removal }}
  337. outputs: type=docker,dest=/tmp/image.tar
  338. tags: test:${{ matrix.artifact_key }}
  339. - name: Retry delay
  340. if: ${{ steps.build1.outcome == 'failure' && steps.build2.outcome == 'failure' }}
  341. run: sleep "${RETRY_DELAY}"
  342. - name: Build test environment (attempt 3)
  343. if: ${{ steps.build1.outcome == 'failure' && steps.build2.outcome == 'failure' }}
  344. id: build3
  345. uses: docker/build-push-action@v5
  346. with:
  347. push: false
  348. load: false
  349. file: .github/dockerfiles/Dockerfile.build_test
  350. build-args: |
  351. BASE=${{ matrix.distro }}
  352. PRE=${{ matrix.env_prep }}
  353. RMJSONC=${{ matrix.jsonc_removal }}
  354. outputs: type=docker,dest=/tmp/image.tar
  355. tags: test:${{ matrix.artifact_key }}
  356. - name: Upload image artifact
  357. id: upload
  358. uses: actions/upload-artifact@v4
  359. with:
  360. name: ${{ matrix.artifact_key }}-test-env
  361. path: /tmp/image.tar
  362. retention-days: 30
  363. - name: Failure Notification
  364. uses: rtCamp/action-slack-notify@v2
  365. env:
  366. SLACK_COLOR: 'danger'
  367. SLACK_FOOTER: ''
  368. SLACK_ICON_EMOJI: ':github-actions:'
  369. SLACK_TITLE: 'Test environment preparation for ${{ matrix.distro }} failed:'
  370. SLACK_USERNAME: 'GitHub Actions'
  371. SLACK_MESSAGE: |-
  372. ${{ github.repository }}: Test environment preparation for ${{ matrix.distro }} failed.
  373. Checkout: ${{ steps.checkout.outcome }}
  374. Set up Buildx: ${{ steps.buildx.outcome }}
  375. Build test environment: ${{ steps.build1.outcome }}
  376. Build test environment (attempt 2): ${{ steps.build2.outcome }}
  377. Build test environment (attempt 3): ${{ steps.build3.outcome }}
  378. Upload: ${{ steps.upload.outcome }}
  379. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  380. if: >-
  381. ${{
  382. failure()
  383. && startsWith(github.ref, 'refs/heads/master')
  384. && github.event_name != 'pull_request'
  385. && github.repository == 'netdata/netdata'
  386. }}
  387. source-build: # Test various source build arrangements.
  388. name: Test Source Build
  389. runs-on: ubuntu-latest
  390. if: github.event_name != 'workflow_dispatch'
  391. needs:
  392. - matrix
  393. - prepare-test-images
  394. - file-check
  395. strategy:
  396. fail-fast: false
  397. max-parallel: 8
  398. matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
  399. steps:
  400. - name: Skip Check
  401. id: skip
  402. if: needs.file-check.outputs.run != 'true'
  403. run: echo "SKIPPED"
  404. - name: Checkout
  405. id: checkout
  406. if: needs.file-check.outputs.run == 'true'
  407. uses: actions/checkout@v4
  408. with:
  409. submodules: recursive
  410. - name: Fetch test environment
  411. id: fetch
  412. if: needs.file-check.outputs.run == 'true'
  413. uses: Wandalen/wretry.action@v1
  414. with:
  415. action: actions/download-artifact@v4
  416. with: |
  417. name: ${{ matrix.artifact_key }}-test-env
  418. path: .
  419. attempt_limit: 3
  420. attempt_delay: 2000
  421. - name: Load test environment
  422. id: load
  423. if: needs.file-check.outputs.run == 'true'
  424. run: docker load --input image.tar
  425. - name: netdata-installer on ${{ matrix.distro }}, disable cloud
  426. id: build-no-cloud
  427. if: needs.file-check.outputs.run == 'true'
  428. run: |
  429. docker run --security-opt seccomp=unconfined -w /netdata test:${{ matrix.artifact_key }} \
  430. /bin/sh -c './netdata-installer.sh --dont-wait --dont-start-it --disable-cloud --one-time-build'
  431. - name: netdata-installer on ${{ matrix.distro }}, require cloud
  432. id: build-cloud
  433. if: needs.file-check.outputs.run == 'true'
  434. run: |
  435. docker run --security-opt seccomp=unconfined -w /netdata test:${{ matrix.artifact_key }} \
  436. /bin/sh -c './netdata-installer.sh --dont-wait --dont-start-it --require-cloud --one-time-build'
  437. - name: netdata-installer on ${{ matrix.distro }}, require cloud, no JSON-C
  438. id: build-no-jsonc
  439. if: matrix.jsonc_removal != '' && needs.file-check.outputs.run == 'true'
  440. run: |
  441. docker run --security-opt seccomp=unconfined -w /netdata test:${{ matrix.artifact_key }} \
  442. /bin/sh -c '/rmjsonc.sh && ./netdata-installer.sh --dont-wait --dont-start-it --require-cloud --one-time-build'
  443. - name: Failure Notification
  444. uses: rtCamp/action-slack-notify@v2
  445. env:
  446. SLACK_COLOR: 'danger'
  447. SLACK_FOOTER: ''
  448. SLACK_ICON_EMOJI: ':github-actions:'
  449. SLACK_TITLE: 'Build tests for ${{ matrix.distro }} failed:'
  450. SLACK_USERNAME: 'GitHub Actions'
  451. SLACK_MESSAGE: |-
  452. ${{ github.repository }}: Build tests for ${{ matrix.distro }} failed.
  453. Checkout: ${{ steps.checkout.outcome }}
  454. Fetch test environment: ${{ steps.fetch.outcome }}
  455. Load test environment: ${{ steps.load.outcome }}
  456. netdata-installer, disable cloud: ${{ steps.build-no-cloud.outcome }}
  457. netdata-installer, require cloud: ${{ steps.build-cloud.outcome }}
  458. netdata-installer, no JSON-C: ${{ steps.build-no-jsonc.outcome }}
  459. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  460. if: >-
  461. ${{
  462. failure()
  463. && startsWith(github.ref, 'refs/heads/master')
  464. && github.event_name != 'pull_request'
  465. && github.repository == 'netdata/netdata'
  466. && needs.file-check.outputs.run == 'true'
  467. }}
  468. updater-check: # Test the generated dist archive using the updater code.
  469. name: Test Generated Distfile and Updater Code
  470. runs-on: ubuntu-latest
  471. if: github.event_name != 'workflow_dispatch'
  472. needs:
  473. - build-dist
  474. - matrix
  475. - prepare-test-images
  476. - file-check
  477. strategy:
  478. fail-fast: false
  479. max-parallel: 8
  480. matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
  481. services:
  482. apache: # This gets used to serve the dist tarball for the updater script.
  483. image: httpd:2.4
  484. ports:
  485. - 8080:80
  486. volumes:
  487. - ${{ github.workspace }}:/usr/local/apache2/htdocs/
  488. steps:
  489. - name: Skip Check
  490. id: skip
  491. if: needs.file-check.outputs.run != 'true'
  492. run: echo "SKIPPED"
  493. - name: Checkout
  494. id: checkout
  495. if: needs.file-check.outputs.run == 'true'
  496. uses: actions/checkout@v4
  497. - name: Fetch dist tarball artifacts
  498. id: fetch-tarball
  499. if: needs.file-check.outputs.run == 'true'
  500. uses: Wandalen/wretry.action@v1
  501. with:
  502. action: actions/download-artifact@v4
  503. with: |
  504. name: dist-tarball
  505. path: dist-tarball
  506. attempt_limit: 3
  507. attempt_delay: 2000
  508. - name: Prepare artifact directory
  509. id: prepare
  510. if: needs.file-check.outputs.run == 'true'
  511. run: |
  512. mkdir -p artifacts/download/v9999.0.0 || exit 1
  513. mkdir -p artifacts/latest || exit 1
  514. echo "v9999.0.0" > artifacts/latest/latest-version.txt || exit 1
  515. cp dist-tarball/* artifacts/download/v9999.0.0 || exit 1
  516. cd artifacts/download/v9999.0.0 || exit 1
  517. ln -s ${{ needs.build-dist.outputs.distfile }} netdata-latest.tar.gz || exit 1
  518. ls -lFh
  519. sha256sum -b ./* > "sha256sums.txt" || exit 1
  520. cat sha256sums.txt
  521. cd ../.. || exit 1
  522. ls -lR
  523. - name: Fetch test environment
  524. id: fetch-test-environment
  525. if: needs.file-check.outputs.run == 'true'
  526. uses: Wandalen/wretry.action@v1
  527. with:
  528. action: actions/download-artifact@v4
  529. with: |
  530. name: ${{ matrix.artifact_key }}-test-env
  531. path: .
  532. attempt_limit: 3
  533. attempt_delay: 2000
  534. - name: Load test environment
  535. id: load
  536. if: needs.file-check.outputs.run == 'true'
  537. run: docker load --input image.tar
  538. - name: Install netdata and run the updater on ${{ matrix.distro }}
  539. id: updater-check
  540. if: needs.file-check.outputs.run == 'true'
  541. run: |
  542. docker run --security-opt seccomp=unconfined -e DISABLE_TELEMETRY=1 --network host -w /netdata test:${{ matrix.artifact_key }} \
  543. /netdata/.github/scripts/run-updater-check.sh
  544. - name: Failure Notification
  545. uses: rtCamp/action-slack-notify@v2
  546. env:
  547. SLACK_COLOR: 'danger'
  548. SLACK_FOOTER: ''
  549. SLACK_ICON_EMOJI: ':github-actions:'
  550. SLACK_TITLE: 'Updater checks for ${{ matrix.distro }} failed:'
  551. SLACK_USERNAME: 'GitHub Actions'
  552. SLACK_MESSAGE: |-
  553. ${{ github.repository }}: Updater checks for ${{ matrix.distro }} failed.
  554. Checkout: ${{ steps.checkout.outcome }}
  555. Fetch dist tarball: ${{ steps.fetch-tarball.outcome }}
  556. Prepare artifact directory: ${{ steps.prepare.outcome }}
  557. Fetch test environment: ${{ steps.fetch-test-environment.outcome }}
  558. Load test environment: ${{ steps.load.outcome }}
  559. Updater check: ${{ steps.updater-check.outcome }}
  560. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  561. if: >-
  562. ${{
  563. failure()
  564. && startsWith(github.ref, 'refs/heads/master')
  565. && github.event_name != 'pull_request'
  566. && github.repository == 'netdata/netdata'
  567. && needs.file-check.outputs.run == 'true'
  568. }}
  569. prepare-upload: # Consolidate the artifacts for uploading or releasing.
  570. name: Prepare Artifacts
  571. runs-on: ubuntu-latest
  572. needs:
  573. - build-dist
  574. - build-static
  575. - file-check
  576. steps:
  577. - name: Skip Check
  578. id: skip
  579. if: needs.file-check.outputs.run != 'true'
  580. run: echo "SKIPPED"
  581. - name: Checkout
  582. id: checkout
  583. if: needs.file-check.outputs.run == 'true'
  584. uses: actions/checkout@v4
  585. - name: Prepare Environment
  586. id: prepare
  587. if: needs.file-check.outputs.run == 'true'
  588. run: mkdir -p artifacts
  589. - name: Retrieve Build Artifacts
  590. id: fetch-dist
  591. if: needs.file-check.outputs.run == 'true'
  592. uses: Wandalen/wretry.action@v1
  593. with:
  594. action: actions/download-artifact@v4
  595. with: |
  596. pattern: dist-*
  597. path: dist-artifacts
  598. merge-multiple: true
  599. attempt_limit: 3
  600. attempt_delay: 2000
  601. - name: Prepare Artifacts
  602. id: consolidate
  603. if: needs.file-check.outputs.run == 'true'
  604. working-directory: ./artifacts/
  605. run: |
  606. mv ../dist-artifacts/* . || exit 1
  607. ln -s ${{ needs.build-dist.outputs.distfile }} netdata-latest.tar.gz || exit 1
  608. cp ../packaging/version ./latest-version.txt || exit 1
  609. cp ../integrations/integrations.js ./integrations.js || exit 1
  610. sha256sum -b ./* > sha256sums.txt || exit 1
  611. cat sha256sums.txt
  612. - name: Store Artifacts
  613. id: store
  614. if: needs.file-check.outputs.run == 'true'
  615. uses: actions/upload-artifact@v4
  616. with:
  617. name: final-artifacts
  618. path: artifacts/*
  619. retention-days: 30
  620. - name: Failure Notification
  621. uses: rtCamp/action-slack-notify@v2
  622. env:
  623. SLACK_COLOR: 'danger'
  624. SLACK_FOOTER: ''
  625. SLACK_ICON_EMOJI: ':github-actions:'
  626. SLACK_TITLE: 'Failed to prepare release artifacts for upload:'
  627. SLACK_USERNAME: 'GitHub Actions'
  628. SLACK_MESSAGE: |-
  629. ${{ github.repository }}: Failed to prepare release artifacts for upload.
  630. CHeckout: ${{ steps.checkout.outcome }}
  631. Prepare environment: ${{ steps.prepare.outcome }}
  632. Fetch dist tarball: ${{ steps.fetch-dist.outcome }}
  633. Fetch static builds: ${{ steps.fetch-static.outcome }}
  634. Consolidate artifacts: ${{ steps.consolidate.outcome }}
  635. Store: ${{ steps.store.outcome }}
  636. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  637. if: >-
  638. ${{
  639. failure()
  640. && startsWith(github.ref, 'refs/heads/master')
  641. && github.event_name != 'pull_request'
  642. && github.repository == 'netdata/netdata'
  643. && needs.file-check.outputs.run == 'true'
  644. }}
  645. artifact-verification-dist: # Verify the regular installer works with the consolidated artifacts.
  646. name: Test Consolidated Artifacts (Source)
  647. runs-on: ubuntu-latest
  648. needs:
  649. - prepare-upload
  650. - file-check
  651. services:
  652. apache: # This gets used to serve the dist tarball for the updater script.
  653. image: httpd:2.4
  654. ports:
  655. - 8080:80
  656. volumes:
  657. - ${{ github.workspace }}:/usr/local/apache2/htdocs/
  658. steps:
  659. - name: Skip Check
  660. id: skip
  661. if: needs.file-check.outputs.run != 'true'
  662. run: echo "SKIPPED"
  663. - name: Checkout
  664. id: checkout
  665. if: needs.file-check.outputs.run == 'true'
  666. uses: actions/checkout@v4
  667. - name: Fetch artifacts
  668. id: fetch
  669. if: needs.file-check.outputs.run == 'true'
  670. uses: Wandalen/wretry.action@v1
  671. with:
  672. action: actions/download-artifact@v4
  673. with: |
  674. name: final-artifacts
  675. path: artifacts
  676. attempt_limit: 3
  677. attempt_delay: 2000
  678. - name: Prepare artifacts directory
  679. id: prepare
  680. if: needs.file-check.outputs.run == 'true'
  681. run: |
  682. mkdir -p download/latest
  683. mv artifacts/* download/latest
  684. ls -al download/latest
  685. - name: Verify that artifacts work with installer
  686. id: verify
  687. if: needs.file-check.outputs.run == 'true'
  688. env:
  689. NETDATA_TARBALL_BASEURL: http://localhost:8080/
  690. run: packaging/installer/kickstart.sh --build-only --dont-start-it --disable-telemetry --dont-wait
  691. - name: Failure Notification
  692. uses: rtCamp/action-slack-notify@v2
  693. env:
  694. SLACK_COLOR: 'danger'
  695. SLACK_FOOTER: ''
  696. SLACK_ICON_EMOJI: ':github-actions:'
  697. SLACK_TITLE: 'Artifact verification for source tarball failed.'
  698. SLACK_USERNAME: 'GitHub Actions'
  699. SLACK_MESSAGE: |-
  700. ${{ github.repository }}: Artifact verification for source tarball failed.
  701. Checkout: ${{ steps.checkout.outcome }}
  702. Fetch artifacts: ${{ steps.fetch.outcome }}
  703. Verify artifacts: ${{ steps.verify.outcome }}
  704. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  705. if: >-
  706. ${{
  707. failure()
  708. && startsWith(github.ref, 'refs/heads/master')
  709. && github.event_name != 'pull_request'
  710. && github.repository == 'netdata/netdata'
  711. && needs.file-check.outputs.run == 'true'
  712. }}
  713. artifact-verification-static: # Verify the static installer works with the consolidated artifacts.
  714. name: Test Consolidated Artifacts (Static)
  715. runs-on: ubuntu-latest
  716. needs:
  717. - prepare-upload
  718. - file-check
  719. services:
  720. apache: # This gets used to serve the static archives.
  721. image: httpd:2.4
  722. ports:
  723. - 8080:80
  724. volumes:
  725. - ${{ github.workspace }}:/usr/local/apache2/htdocs/
  726. steps:
  727. - name: Skip Check
  728. id: skip
  729. if: needs.file-check.outputs.run != 'true'
  730. run: echo "SKIPPED"
  731. - name: Checkout
  732. id: checkout
  733. if: needs.file-check.outputs.run == 'true'
  734. uses: actions/checkout@v4
  735. - name: Fetch artifacts
  736. id: fetch-artifacts
  737. if: needs.file-check.outputs.run == 'true'
  738. uses: Wandalen/wretry.action@v1
  739. with:
  740. action: actions/download-artifact@v4
  741. with: |
  742. name: final-artifacts
  743. path: artifacts
  744. attempt_limit: 3
  745. attempt_delay: 2000
  746. - name: Prepare artifacts directory
  747. id: prepare
  748. if: needs.file-check.outputs.run == 'true'
  749. run: |
  750. mkdir -p download/latest
  751. mv artifacts/* download/latest
  752. ls -al download/latest
  753. - name: Verify that artifacts work with installer
  754. id: verify
  755. if: needs.file-check.outputs.run == 'true'
  756. env:
  757. NETDATA_TARBALL_BASEURL: http://localhost:8080/
  758. run: packaging/installer/kickstart.sh --static-only --dont-start-it --disable-telemetry
  759. - name: Failure Notification
  760. uses: rtCamp/action-slack-notify@v2
  761. env:
  762. SLACK_COLOR: 'danger'
  763. SLACK_FOOTER: ''
  764. SLACK_ICON_EMOJI: ':github-actions:'
  765. SLACK_TITLE: 'Artifact verification for static build failed.'
  766. SLACK_USERNAME: 'GitHub Actions'
  767. SLACK_MESSAGE: |-
  768. ${{ github.repository }}: Artifact verification for static build failed.
  769. Checkout: ${{ steps.checkout.outcome }}
  770. Fetch artifacts: ${{ steps.fetch-artifacts.outcome }}
  771. Verify artifacts: ${{ steps.verify.outcome }}
  772. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  773. if: >-
  774. ${{
  775. failure()
  776. && startsWith(github.ref, 'refs/heads/master')
  777. && github.event_name != 'pull_request'
  778. && github.repository == 'netdata/netdata'
  779. && needs.file-check.outputs.run == 'true'
  780. }}
  781. upload-nightly: # Upload the nightly build artifacts to GCS.
  782. name: Upload Nightly Artifacts
  783. runs-on: ubuntu-latest
  784. if: github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'nightly' && github.repository == 'netdata/netdata'
  785. needs:
  786. - artifact-verification-dist
  787. - artifact-verification-static
  788. steps:
  789. - name: Retrieve Artifacts
  790. id: fetch
  791. uses: Wandalen/wretry.action@v1
  792. with:
  793. action: actions/download-artifact@v4
  794. with: |
  795. name: final-artifacts
  796. path: final-artifacts
  797. attempt_limit: 3
  798. attempt_delay: 2000
  799. - name: Authenticate to GCS
  800. id: gcs-auth
  801. uses: google-github-actions/auth@v2
  802. with:
  803. project_id: ${{ secrets.GCP_NIGHTLY_STORAGE_PROJECT }}
  804. credentials_json: ${{ secrets.GCS_STORAGE_SERVICE_KEY_JSON }}
  805. - name: Setup GCS
  806. id: gcs-setup
  807. uses: google-github-actions/setup-gcloud@v2.0.1
  808. - name: Upload Artifacts
  809. id: upload
  810. uses: google-github-actions/upload-cloud-storage@v2.0.0
  811. with:
  812. destination: ${{ secrets.GCP_NIGHTLY_STORAGE_BUCKET }}
  813. gzip: false
  814. path: ./final-artifacts/latest-version.txt
  815. parent: false
  816. - name: Failure Notification
  817. uses: rtCamp/action-slack-notify@v2
  818. env:
  819. SLACK_COLOR: 'danger'
  820. SLACK_FOOTER: ''
  821. SLACK_ICON_EMOJI: ':github-actions:'
  822. SLACK_TITLE: 'Failed to upload nightly release artifacts:'
  823. SLACK_USERNAME: 'GitHub Actions'
  824. SLACK_MESSAGE: |-
  825. ${{ github.repository }}: Failed to upload nightly release artifacts.
  826. Fetch artifacts: ${{ steps.fetch.outcome }}
  827. Authenticatie GCS: ${{ steps.gcs-auth.outcome }}
  828. Setup GCS: ${{ steps.gcs-setup.outcome }}
  829. Upload artifacts: ${{ steps.upload.outcome }}
  830. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  831. if: >-
  832. ${{
  833. failure()
  834. && startsWith(github.ref, 'refs/heads/master')
  835. && github.event_name != 'pull_request'
  836. }}
  837. create-nightly: # Create a nightly build release in netdata/netdata-nightlies
  838. name: Create Nightly Release
  839. runs-on: ubuntu-latest
  840. if: github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'nightly' && github.repository == 'netdata/netdata'
  841. needs:
  842. - artifact-verification-dist
  843. - artifact-verification-static
  844. steps:
  845. - name: Checkout Main Repo
  846. id: checkout-main
  847. uses: actions/checkout@v4
  848. with:
  849. path: main
  850. - name: Checkout Nightly Repo
  851. id: checkout-nightly
  852. uses: actions/checkout@v4
  853. with:
  854. repository: netdata/netdata-nightlies
  855. path: nightlies
  856. token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
  857. - name: Retrieve Artifacts
  858. id: fetch
  859. uses: Wandalen/wretry.action@v1
  860. with:
  861. action: actions/download-artifact@v4
  862. with: |
  863. name: final-artifacts
  864. path: final-artifacts
  865. attempt_limit: 3
  866. attempt_delay: 2000
  867. - name: Prepare version info
  868. id: version
  869. run: |
  870. # shellcheck disable=SC2129
  871. echo "version=$(cat main/packaging/version)" >> "${GITHUB_OUTPUT}"
  872. echo "commit=$(cd nightlies && git rev-parse HEAD)" >> "${GITHUB_OUTPUT}"
  873. echo "date=$(date +%F)" >> "${GITHUB_OUTPUT}"
  874. - name: Create Release
  875. id: create-release
  876. uses: ncipollo/release-action@v1
  877. with:
  878. allowUpdates: false
  879. artifactErrorsFailBuild: true
  880. artifacts: 'final-artifacts/sha256sums.txt,final-artifacts/netdata-*.tar.gz,final-artifacts/netdata-*.gz.run,final-artifacts/integrations.js'
  881. owner: netdata
  882. repo: netdata-nightlies
  883. body: Netdata nightly build for ${{ steps.version.outputs.date }}.
  884. commit: ${{ steps.version.outputs.commit }}
  885. makeLatest: true
  886. tag: ${{ steps.version.outputs.version }}
  887. token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
  888. - name: Checkout netdata main Repo # Checkout back to netdata/netdata repo to the update latest packaged versions
  889. id: checkout-netdata
  890. uses: actions/checkout@v4
  891. with:
  892. token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
  893. - name: Init python environment for publish release metadata
  894. uses: actions/setup-python@v5
  895. id: init-python
  896. with:
  897. python-version: "3.12"
  898. - name: Setup python environment
  899. id: setup-python
  900. run: |
  901. pip install -r .github/scripts/modules/requirements.txt
  902. - name: Check if the version is latest and published
  903. id: check-latest-version
  904. run: |
  905. python .github/scripts/check_latest_versions.py ${{ steps.version.outputs.version }}
  906. - name: SSH setup
  907. id: ssh-setup
  908. if: github.event_name == 'workflow_dispatch' && github.repository == 'netdata/netdata' && steps.check-latest-version.outputs.versions_needs_update == 'true'
  909. uses: shimataro/ssh-key-action@v2
  910. with:
  911. key: ${{ secrets.NETDATABOT_PACKAGES_SSH_KEY }}
  912. name: id_ecdsa
  913. known_hosts: ${{ secrets.PACKAGES_KNOWN_HOSTS }}
  914. - name: Sync newer releases
  915. id: sync-releases
  916. if: github.event_name == 'workflow_dispatch' && github.repository == 'netdata/netdata' && steps.check-latest-version.outputs.versions_needs_update == 'true'
  917. run: |
  918. .github/scripts/upload-new-version-tags.sh
  919. - name: Failure Notification
  920. uses: rtCamp/action-slack-notify@v2
  921. env:
  922. SLACK_COLOR: 'danger'
  923. SLACK_FOOTER: ''
  924. SLACK_ICON_EMOJI: ':github-actions:'
  925. SLACK_TITLE: 'Failed to draft release:'
  926. SLACK_USERNAME: 'GitHub Actions'
  927. SLACK_MESSAGE: |-
  928. ${{ github.repository }}: Failed to create nightly release or attach artifacts.
  929. Checkout netdata/netdata: ${{ steps.checkout-main.outcome }}
  930. Checkout netdata/netdata-nightlies: ${{ steps.checkout-nightly.outcome }}
  931. Fetch artifacts: ${{ steps.fetch.outcome }}
  932. Prepare version info: ${{ steps.version.outcome }}
  933. Create release: ${{ steps.create-release.outcome }}
  934. Checkout back netdata/netdata: ${{ steps.checkout-netdata.outcome }}
  935. Init python environment: ${{ steps.init-python.outcome }}
  936. Setup python environment: ${{ steps.setup-python.outcome }}
  937. Check the nearly published release against the advertised: ${{ steps.check-latest-version.outcome }}
  938. Setup ssh: ${{ steps.ssh-setup.outcome }}
  939. Sync with the releases: ${{ steps.sync-releases.outcome }}
  940. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  941. if: >-
  942. ${{
  943. failure()
  944. && github.event_name == 'workflow_dispatch'
  945. }}
  946. normalize-tag: # Fix the release tag if needed
  947. name: Normalize Release Tag
  948. runs-on: ubuntu-latest
  949. if: github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'release'
  950. outputs:
  951. tag: ${{ steps.tag.outputs.tag }}
  952. steps:
  953. - name: Normalize Tag
  954. id: tag
  955. run: |
  956. if echo ${{ github.event.inputs.version }} | grep -qE '^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+$'; then
  957. echo "tag=v${{ github.event.inputs.version }}" >> "${GITHUB_OUTPUT}"
  958. else
  959. echo "tag=${{ github.event.inputs.version }}" >> "${GITHUB_OUTPUT}"
  960. fi
  961. upload-release: # Create the draft release and upload the build artifacts.
  962. name: Create Release Draft
  963. runs-on: ubuntu-latest
  964. if: github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'release' && github.repository == 'netdata/netdata'
  965. needs:
  966. - artifact-verification-dist
  967. - artifact-verification-static
  968. - normalize-tag
  969. steps:
  970. - name: Checkout
  971. id: checkout
  972. uses: actions/checkout@v4
  973. - name: Retrieve Artifacts
  974. id: fetch
  975. uses: Wandalen/wretry.action@v1
  976. with:
  977. action: actions/download-artifact@v4
  978. with: |
  979. name: final-artifacts
  980. path: final-artifacts
  981. attempt_limit: 3
  982. attempt_delay: 2000
  983. - name: Create Release
  984. id: create-release
  985. uses: ncipollo/release-action@v1
  986. with:
  987. allowUpdates: false
  988. artifactErrorsFailBuild: true
  989. artifacts: 'final-artifacts/sha256sums.txt,final-artifacts/netdata-*.tar.gz,final-artifacts/netdata-*.gz.run,final-artifacts/integrations.js'
  990. draft: true
  991. tag: ${{ needs.normalize-tag.outputs.tag }}
  992. token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
  993. - name: Failure Notification
  994. uses: rtCamp/action-slack-notify@v2
  995. env:
  996. SLACK_COLOR: 'danger'
  997. SLACK_FOOTER: ''
  998. SLACK_ICON_EMOJI: ':github-actions:'
  999. SLACK_TITLE: 'Failed to draft release:'
  1000. SLACK_USERNAME: 'GitHub Actions'
  1001. SLACK_MESSAGE: |-
  1002. ${{ github.repository }}: Failed to create draft release or attach artifacts.
  1003. Checkout: ${{ steps.checkout.outcome }}
  1004. Fetch artifacts: ${{ steps.fetch.outcome }}
  1005. Create draft release: ${{ steps.create-release.outcome }}
  1006. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  1007. if: >-
  1008. ${{
  1009. failure()
  1010. && github.event_name == 'workflow_dispatch'
  1011. }}
  1012. - name: Success Notification
  1013. uses: rtCamp/action-slack-notify@v2
  1014. env:
  1015. SLACK_COLOR: 'good'
  1016. SLACK_FOOTER: ''
  1017. SLACK_ICON_EMOJI: ':github-actions:'
  1018. SLACK_TITLE: 'Created agent draft release:'
  1019. SLACK_USERNAME: 'GitHub Actions'
  1020. SLACK_MESSAGE: "${{ github.repository }}: ${{ steps.create-release.outputs.html_url }}"
  1021. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  1022. if: >-
  1023. ${{
  1024. success()
  1025. && github.event_name == 'workflow_dispatch'
  1026. }}