build.yml 41 KB

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