build.yml 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070
  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. cp ../integrations/integrations.js ./integrations.js || exit 1
  434. sha256sum -b ./* > sha256sums.txt || exit 1
  435. cat sha256sums.txt
  436. - name: Store Artifacts
  437. id: store
  438. if: needs.file-check.outputs.run == 'true'
  439. uses: actions/upload-artifact@v4.4.2
  440. with:
  441. name: final-artifacts
  442. path: artifacts/*
  443. retention-days: 30
  444. - name: Failure Notification
  445. uses: rtCamp/action-slack-notify@v2
  446. env:
  447. SLACK_COLOR: 'danger'
  448. SLACK_FOOTER: ''
  449. SLACK_ICON_EMOJI: ':github-actions:'
  450. SLACK_TITLE: 'Failed to prepare release artifacts for upload:'
  451. SLACK_USERNAME: 'GitHub Actions'
  452. SLACK_MESSAGE: |-
  453. ${{ github.repository }}: Failed to prepare release artifacts for upload.
  454. Checkout: ${{ steps.checkout.outcome }}
  455. Prepare environment: ${{ steps.prepare.outcome }}
  456. Fetch dist artifacts: ${{ steps.fetch-dist.outcome }}
  457. Fetch Windows installers: ${{ steps.fetch-windows.outcome }}
  458. Consolidate artifacts: ${{ steps.consolidate.outcome }}
  459. Store: ${{ steps.store.outcome }}
  460. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  461. if: >-
  462. ${{
  463. failure()
  464. && startsWith(github.ref, 'refs/heads/master')
  465. && github.event_name != 'pull_request'
  466. && github.repository == 'netdata/netdata'
  467. && needs.file-check.outputs.run == 'true'
  468. }}
  469. artifact-verification-dist: # Verify the regular installer works with the consolidated artifacts.
  470. name: Test Consolidated Artifacts (Source)
  471. runs-on: ubuntu-latest
  472. needs:
  473. - prepare-upload
  474. - file-check
  475. services:
  476. apache: # This gets used to serve the dist tarball for the updater script.
  477. image: httpd:2.4
  478. ports:
  479. - 8080:80
  480. volumes:
  481. - ${{ github.workspace }}:/usr/local/apache2/htdocs/
  482. steps:
  483. - name: Skip Check
  484. id: skip
  485. if: needs.file-check.outputs.run != 'true'
  486. run: echo "SKIPPED"
  487. - name: Checkout
  488. id: checkout
  489. if: needs.file-check.outputs.run == 'true'
  490. uses: actions/checkout@v4
  491. - name: Fetch artifacts
  492. id: fetch
  493. if: needs.file-check.outputs.run == 'true'
  494. uses: Wandalen/wretry.action@v3
  495. with:
  496. action: actions/download-artifact@v4
  497. with: |
  498. name: final-artifacts
  499. path: artifacts
  500. attempt_limit: 3
  501. attempt_delay: 2000
  502. - name: Prepare artifacts directory
  503. id: prepare
  504. if: needs.file-check.outputs.run == 'true'
  505. run: |
  506. mkdir -p download/latest
  507. mv artifacts/* download/latest
  508. ls -al download/latest
  509. - name: Verify that artifacts work with installer
  510. id: verify
  511. if: needs.file-check.outputs.run == 'true'
  512. env:
  513. NETDATA_TARBALL_BASEURL: http://localhost:8080/
  514. run: sh -x packaging/installer/kickstart.sh --build-only --dont-start-it --disable-telemetry --dont-wait
  515. - name: Failure Notification
  516. uses: rtCamp/action-slack-notify@v2
  517. env:
  518. SLACK_COLOR: 'danger'
  519. SLACK_FOOTER: ''
  520. SLACK_ICON_EMOJI: ':github-actions:'
  521. SLACK_TITLE: 'Artifact verification for source tarball failed.'
  522. SLACK_USERNAME: 'GitHub Actions'
  523. SLACK_MESSAGE: |-
  524. ${{ github.repository }}: Artifact verification for source tarball failed.
  525. Checkout: ${{ steps.checkout.outcome }}
  526. Fetch artifacts: ${{ steps.fetch.outcome }}
  527. Verify artifacts: ${{ steps.verify.outcome }}
  528. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  529. if: >-
  530. ${{
  531. failure()
  532. && startsWith(github.ref, 'refs/heads/master')
  533. && github.event_name != 'pull_request'
  534. && github.repository == 'netdata/netdata'
  535. && needs.file-check.outputs.run == 'true'
  536. }}
  537. artifact-verification-static: # Verify the static installer works with the consolidated artifacts.
  538. name: Test Consolidated Artifacts (Static)
  539. runs-on: ubuntu-latest
  540. needs:
  541. - prepare-upload
  542. - file-check
  543. services:
  544. apache: # This gets used to serve the static archives.
  545. image: httpd:2.4
  546. ports:
  547. - 8080:80
  548. volumes:
  549. - ${{ github.workspace }}:/usr/local/apache2/htdocs/
  550. steps:
  551. - name: Skip Check
  552. id: skip
  553. if: needs.file-check.outputs.run != 'true'
  554. run: echo "SKIPPED"
  555. - name: Checkout
  556. id: checkout
  557. if: needs.file-check.outputs.run == 'true'
  558. uses: actions/checkout@v4
  559. - name: Fetch artifacts
  560. id: fetch-artifacts
  561. if: needs.file-check.outputs.run == 'true'
  562. uses: Wandalen/wretry.action@v3
  563. with:
  564. action: actions/download-artifact@v4
  565. with: |
  566. name: final-artifacts
  567. path: artifacts
  568. attempt_limit: 3
  569. attempt_delay: 2000
  570. - name: Prepare artifacts directory
  571. id: prepare
  572. if: needs.file-check.outputs.run == 'true'
  573. run: |
  574. mkdir -p download/latest
  575. mv artifacts/* download/latest
  576. ls -al download/latest
  577. - name: Verify that artifacts work with installer
  578. id: verify
  579. if: needs.file-check.outputs.run == 'true'
  580. env:
  581. NETDATA_TARBALL_BASEURL: http://localhost:8080/
  582. run: sh -x packaging/installer/kickstart.sh --static-only --dont-start-it --disable-telemetry
  583. - name: Failure Notification
  584. uses: rtCamp/action-slack-notify@v2
  585. env:
  586. SLACK_COLOR: 'danger'
  587. SLACK_FOOTER: ''
  588. SLACK_ICON_EMOJI: ':github-actions:'
  589. SLACK_TITLE: 'Artifact verification for static build failed.'
  590. SLACK_USERNAME: 'GitHub Actions'
  591. SLACK_MESSAGE: |-
  592. ${{ github.repository }}: Artifact verification for static build failed.
  593. Checkout: ${{ steps.checkout.outcome }}
  594. Fetch artifacts: ${{ steps.fetch-artifacts.outcome }}
  595. Verify artifacts: ${{ steps.verify.outcome }}
  596. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  597. if: >-
  598. ${{
  599. failure()
  600. && startsWith(github.ref, 'refs/heads/master')
  601. && github.event_name != 'pull_request'
  602. && github.repository == 'netdata/netdata'
  603. && needs.file-check.outputs.run == 'true'
  604. }}
  605. artifact-verification-updater: # Test the generated dist archive using the updater code.
  606. name: Test Consolidated Artifacts (Updater)
  607. runs-on: ubuntu-latest
  608. needs:
  609. - prepare-upload
  610. - file-check
  611. services:
  612. apache: # This gets used to serve the dist tarball for the updater script.
  613. image: httpd:2.4
  614. ports:
  615. - 8080:80
  616. volumes:
  617. - ${{ github.workspace }}:/usr/local/apache2/htdocs/
  618. steps:
  619. - name: Skip Check
  620. id: skip
  621. if: needs.file-check.outputs.run != 'true'
  622. run: echo "SKIPPED"
  623. - name: Checkout
  624. id: checkout
  625. if: needs.file-check.outputs.run == 'true'
  626. uses: actions/checkout@v4
  627. - name: Fetch artifacts
  628. id: fetch-artifacts
  629. if: needs.file-check.outputs.run == 'true'
  630. uses: Wandalen/wretry.action@v3
  631. with:
  632. action: actions/download-artifact@v4
  633. with: |
  634. name: final-artifacts
  635. path: artifacts
  636. attempt_limit: 3
  637. attempt_delay: 2000
  638. - name: Prepare artifacts directory
  639. id: prepare
  640. if: needs.file-check.outputs.run == 'true'
  641. run: |
  642. mkdir -p download/latest
  643. mv artifacts/* download/latest
  644. ls -al download/latest
  645. - name: Run Updater Check
  646. id: check
  647. if: needs.file-check.outputs.run == 'true'
  648. run: |
  649. docker run --security-opt seccomp=unconfined -e DISABLE_TELEMETRY=1 --network host \
  650. -v $PWD:/netdata -w /netdata \
  651. ubuntu:latest /bin/sh -x /netdata/.github/scripts/run-updater-check.sh
  652. - name: Failure Notification
  653. uses: rtCamp/action-slack-notify@v2
  654. env:
  655. SLACK_COLOR: 'danger'
  656. SLACK_FOOTER: ''
  657. SLACK_ICON_EMOJI: ':github-actions:'
  658. SLACK_TITLE: 'Updater checks for ${{ matrix.distro }} failed:'
  659. SLACK_USERNAME: 'GitHub Actions'
  660. SLACK_MESSAGE: |-
  661. ${{ github.repository }}: Updater checks for ${{ matrix.distro }} failed.
  662. Checkout: ${{ steps.checkout.outcome }}
  663. Fetch artifacts: ${{ steps.fetch-artifacts.outcome }}
  664. Prepare artifact directory: ${{ steps.prepare.outcome }}
  665. Updater check: ${{ steps.check.outcome }}
  666. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  667. if: >-
  668. ${{
  669. failure()
  670. && startsWith(github.ref, 'refs/heads/master')
  671. && github.event_name != 'pull_request'
  672. && github.repository == 'netdata/netdata'
  673. && needs.file-check.outputs.run == 'true'
  674. }}
  675. create-nightly: # Create a nightly build release in netdata/netdata-nightlies
  676. name: Create Nightly Release
  677. runs-on: ubuntu-latest
  678. if: github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'nightly' && github.repository == 'netdata/netdata'
  679. needs:
  680. - prepare-upload
  681. - artifact-verification-dist
  682. - artifact-verification-static
  683. steps:
  684. - name: Checkout Main Repo
  685. id: checkout-main
  686. uses: actions/checkout@v4
  687. with:
  688. path: main
  689. - name: Checkout Nightly Repo
  690. id: checkout-nightly
  691. uses: actions/checkout@v4
  692. with:
  693. repository: netdata/netdata-nightlies
  694. path: nightlies
  695. token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
  696. - name: Retrieve Artifacts
  697. id: fetch
  698. uses: Wandalen/wretry.action@v3
  699. with:
  700. action: actions/download-artifact@v4
  701. with: |
  702. name: final-artifacts
  703. path: final-artifacts
  704. attempt_limit: 3
  705. attempt_delay: 2000
  706. - name: Prepare version info
  707. id: version
  708. run: |
  709. # shellcheck disable=SC2129
  710. echo "version=$(cat main/packaging/version)" >> "${GITHUB_OUTPUT}"
  711. echo "commit=$(cd nightlies && git rev-parse HEAD)" >> "${GITHUB_OUTPUT}"
  712. echo "date=$(date +%F)" >> "${GITHUB_OUTPUT}"
  713. - name: Create Release
  714. id: create-release
  715. uses: ncipollo/release-action@v1
  716. with:
  717. allowUpdates: false
  718. artifactErrorsFailBuild: true
  719. artifacts: 'final-artifacts/sha256sums.txt,final-artifacts/netdata-*.tar.gz,final-artifacts/netdata-*.gz.run,final-artifacts/netdata-*.msi,final-artifacts/integrations.js'
  720. owner: netdata
  721. repo: netdata-nightlies
  722. body: Netdata nightly build for ${{ steps.version.outputs.date }}.
  723. commit: ${{ steps.version.outputs.commit }}
  724. makeLatest: true
  725. tag: ${{ steps.version.outputs.version }}
  726. token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
  727. - name: Checkout netdata main Repo # Checkout back to netdata/netdata repo to the update latest packaged versions
  728. id: checkout-netdata
  729. uses: actions/checkout@v4
  730. with:
  731. token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
  732. - name: Init python environment for publish release metadata
  733. uses: actions/setup-python@v5
  734. id: init-python
  735. with:
  736. python-version: "3.12"
  737. - name: Setup python environment
  738. id: setup-python
  739. run: |
  740. pip install -r .github/scripts/modules/requirements.txt
  741. - name: Check if the version is latest and published
  742. id: check-latest-version
  743. run: |
  744. python .github/scripts/check_latest_versions.py ${{ steps.version.outputs.version }}
  745. - name: SSH setup
  746. id: ssh-setup
  747. if: github.event_name == 'workflow_dispatch' && github.repository == 'netdata/netdata' && steps.check-latest-version.outputs.versions_needs_update == 'true'
  748. uses: shimataro/ssh-key-action@v2
  749. with:
  750. key: ${{ secrets.NETDATABOT_PACKAGES_SSH_KEY }}
  751. name: id_ecdsa
  752. known_hosts: ${{ secrets.PACKAGES_KNOWN_HOSTS }}
  753. - name: Sync release info to packages.netdata.cloud
  754. id: sync-releases
  755. continue-on-error: true
  756. if: github.event_name == 'workflow_dispatch' && github.repository == 'netdata/netdata' && steps.check-latest-version.outputs.versions_needs_update == 'true'
  757. run: |
  758. .github/scripts/upload-new-version-tags.sh packages.netdata.cloud
  759. - name: Sync release info to packages2.netdata.cloud
  760. id: sync-releases2
  761. if: github.event_name == 'workflow_dispatch' && github.repository == 'netdata/netdata' && steps.check-latest-version.outputs.versions_needs_update == 'true'
  762. run: |
  763. .github/scripts/upload-new-version-tags.sh packages.netdata.cloud
  764. - name: Failure Notification
  765. uses: rtCamp/action-slack-notify@v2
  766. env:
  767. SLACK_COLOR: 'danger'
  768. SLACK_FOOTER: ''
  769. SLACK_ICON_EMOJI: ':github-actions:'
  770. SLACK_TITLE: 'Failed to draft release:'
  771. SLACK_USERNAME: 'GitHub Actions'
  772. SLACK_MESSAGE: |-
  773. ${{ github.repository }}: Failed to create nightly release or attach artifacts.
  774. Checkout netdata/netdata: ${{ steps.checkout-main.outcome }}
  775. Checkout netdata/netdata-nightlies: ${{ steps.checkout-nightly.outcome }}
  776. Fetch artifacts: ${{ steps.fetch.outcome }}
  777. Prepare version info: ${{ steps.version.outcome }}
  778. Create release: ${{ steps.create-release.outcome }}
  779. Checkout back netdata/netdata: ${{ steps.checkout-netdata.outcome }}
  780. Init python environment: ${{ steps.init-python.outcome }}
  781. Setup python environment: ${{ steps.setup-python.outcome }}
  782. Check the nearly published release against the advertised: ${{ steps.check-latest-version.outcome }}
  783. Setup ssh: ${{ steps.ssh-setup.outcome }}
  784. Sync release info to packages.netdata.cloud: ${{ steps.sync-releases.outcome }}
  785. Sync release info to packages2.netdata.cloud: ${{ steps.sync-releases2.outcome }}
  786. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  787. if: >-
  788. ${{
  789. failure()
  790. && github.event_name == 'workflow_dispatch'
  791. }}
  792. normalize-tag: # Fix the release tag if needed
  793. name: Normalize Release Tag
  794. runs-on: ubuntu-latest
  795. if: github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'release'
  796. outputs:
  797. tag: ${{ steps.tag.outputs.tag }}
  798. steps:
  799. - name: Normalize Tag
  800. id: tag
  801. run: |
  802. if echo ${{ github.event.inputs.version }} | grep -qE '^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+$'; then
  803. echo "tag=v${{ github.event.inputs.version }}" >> "${GITHUB_OUTPUT}"
  804. else
  805. echo "tag=${{ github.event.inputs.version }}" >> "${GITHUB_OUTPUT}"
  806. fi
  807. upload-release: # Create the draft release and upload the build artifacts.
  808. name: Create Release Draft
  809. runs-on: ubuntu-latest
  810. if: github.event_name == 'workflow_dispatch' && github.event.inputs.type == 'release' && github.repository == 'netdata/netdata'
  811. needs:
  812. - artifact-verification-dist
  813. - artifact-verification-static
  814. - normalize-tag
  815. steps:
  816. - name: Checkout
  817. id: checkout
  818. uses: actions/checkout@v4
  819. - name: Retrieve Artifacts
  820. id: fetch
  821. uses: Wandalen/wretry.action@v3
  822. with:
  823. action: actions/download-artifact@v4
  824. with: |
  825. name: final-artifacts
  826. path: final-artifacts
  827. attempt_limit: 3
  828. attempt_delay: 2000
  829. - name: Create Release
  830. id: create-release
  831. uses: ncipollo/release-action@v1
  832. with:
  833. allowUpdates: false
  834. artifactErrorsFailBuild: true
  835. artifacts: 'final-artifacts/sha256sums.txt,final-artifacts/netdata-*.tar.gz,final-artifacts/netdata-*.gz.run,final-artifacts/netdata-*.msi,final-artifacts/integrations.js'
  836. draft: true
  837. tag: ${{ needs.normalize-tag.outputs.tag }}
  838. token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
  839. - name: Failure Notification
  840. uses: rtCamp/action-slack-notify@v2
  841. env:
  842. SLACK_COLOR: 'danger'
  843. SLACK_FOOTER: ''
  844. SLACK_ICON_EMOJI: ':github-actions:'
  845. SLACK_TITLE: 'Failed to draft release:'
  846. SLACK_USERNAME: 'GitHub Actions'
  847. SLACK_MESSAGE: |-
  848. ${{ github.repository }}: Failed to create draft release or attach artifacts.
  849. Checkout: ${{ steps.checkout.outcome }}
  850. Fetch artifacts: ${{ steps.fetch.outcome }}
  851. Create draft release: ${{ steps.create-release.outcome }}
  852. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  853. if: >-
  854. ${{
  855. failure()
  856. && github.event_name == 'workflow_dispatch'
  857. }}
  858. - name: Success Notification
  859. uses: rtCamp/action-slack-notify@v2
  860. env:
  861. SLACK_COLOR: 'good'
  862. SLACK_FOOTER: ''
  863. SLACK_ICON_EMOJI: ':github-actions:'
  864. SLACK_TITLE: 'Created agent draft release:'
  865. SLACK_USERNAME: 'GitHub Actions'
  866. SLACK_MESSAGE: "${{ github.repository }}: ${{ steps.create-release.outputs.html_url }}"
  867. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  868. if: >-
  869. ${{
  870. success()
  871. && github.event_name == 'workflow_dispatch'
  872. }}
  873. # Remaining jobs are only used for CI checks, and not as part of the release process
  874. matrix: # Generate the shared build matrix for our Linux build tests.
  875. name: Prepare Build Matrix
  876. runs-on: ubuntu-latest
  877. if: github.event_name != 'workflow_dispatch'
  878. outputs:
  879. matrix: ${{ steps.set-matrix.outputs.matrix }}
  880. steps:
  881. - name: Checkout
  882. id: checkout
  883. uses: actions/checkout@v4
  884. - name: Prepare tools
  885. id: prepare
  886. run: |
  887. sudo apt-get update || true
  888. sudo apt-get install -y python3-ruamel.yaml
  889. - name: Read build matrix
  890. id: set-matrix
  891. run: |
  892. matrix="$(.github/scripts/gen-matrix-build.py)"
  893. echo "Generated matrix: ${matrix}"
  894. echo "matrix=${matrix}" >> "${GITHUB_OUTPUT}"
  895. - name: Failure Notification
  896. uses: rtCamp/action-slack-notify@v2
  897. env:
  898. SLACK_COLOR: 'danger'
  899. SLACK_FOOTER: ''
  900. SLACK_ICON_EMOJI: ':github-actions:'
  901. SLACK_TITLE: 'Build matrix preparation failed:'
  902. SLACK_USERNAME: 'GitHub Actions'
  903. SLACK_MESSAGE: |-
  904. ${{ github.repository }}: Failed to prepare build matrix for build checks.
  905. Checkout: ${{ steps.checkout.outcome }}
  906. Prepare tools: ${{ steps.prepare.outcome }}
  907. Read build matrix: ${{ steps.set-matrix.outcome }}
  908. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  909. if: >-
  910. ${{
  911. failure()
  912. && startsWith(github.ref, 'refs/heads/master')
  913. && github.event_name != 'pull_request'
  914. && github.repository == 'netdata/netdata'
  915. }}
  916. source-build: # Test various source build arrangements.
  917. name: Test Source Build
  918. runs-on: ubuntu-latest
  919. if: github.event_name != 'workflow_dispatch'
  920. needs:
  921. - matrix
  922. - file-check
  923. strategy:
  924. fail-fast: false
  925. max-parallel: 8
  926. matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
  927. steps:
  928. - name: Skip Check
  929. id: skip
  930. if: needs.file-check.outputs.run != 'true'
  931. run: echo "SKIPPED"
  932. - name: Checkout
  933. id: checkout
  934. if: needs.file-check.outputs.run == 'true'
  935. uses: actions/checkout@v4
  936. with:
  937. submodules: recursive
  938. - name: Setup Buildx
  939. id: buildx
  940. uses: docker/setup-buildx-action@v3
  941. - name: Build test environment
  942. id: build
  943. uses: Wandalen/wretry.action@v3
  944. with:
  945. action: docker/build-push-action@v6
  946. with: |
  947. push: false
  948. load: true
  949. file: .github/dockerfiles/Dockerfile.build_test
  950. build-args: |
  951. BASE=${{ matrix.distro }}
  952. PRE=${{ matrix.env_prep }}
  953. RMJSONC=${{ matrix.jsonc_removal }}
  954. tags: test:${{ matrix.artifact_key }}
  955. attempt_limit: 3
  956. attempt_delay: 15000
  957. - name: netdata-installer on ${{ matrix.distro }}
  958. id: build-cloud
  959. if: needs.file-check.outputs.run == 'true'
  960. run: |
  961. docker run --security-opt seccomp=unconfined -w /netdata test:${{ matrix.artifact_key }} \
  962. /bin/sh -c './netdata-installer.sh --dont-wait --dont-start-it --one-time-build ${{ needs.file-check.outputs.skip-go }}'
  963. - name: Failure Notification
  964. uses: rtCamp/action-slack-notify@v2
  965. env:
  966. SLACK_COLOR: 'danger'
  967. SLACK_FOOTER: ''
  968. SLACK_ICON_EMOJI: ':github-actions:'
  969. SLACK_TITLE: 'Build tests for ${{ matrix.distro }} failed:'
  970. SLACK_USERNAME: 'GitHub Actions'
  971. SLACK_MESSAGE: |-
  972. ${{ github.repository }}: Build tests for ${{ matrix.distro }} failed.
  973. Checkout: ${{ steps.checkout.outcome }}
  974. Set up Buildx: ${{ steps.buildx.outcome }}
  975. Build test environment: ${{ steps.build1.outcome }}
  976. netdata-installer: ${{ steps.build-cloud.outcome }}
  977. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  978. if: >-
  979. ${{
  980. failure()
  981. && startsWith(github.ref, 'refs/heads/master')
  982. && github.event_name != 'pull_request'
  983. && github.repository == 'netdata/netdata'
  984. && needs.file-check.outputs.run == 'true'
  985. }}
  986. macos-build: # Test building on macOS
  987. name: Test building on macOS
  988. runs-on: ${{ matrix.runner }}
  989. if: github.event_name != 'workflow_dispatch'
  990. needs:
  991. - file-check
  992. strategy:
  993. fail-fast: false
  994. max-parallel: 8
  995. matrix:
  996. include:
  997. - name: macos-13
  998. runner: macos-13
  999. - name: macos-14-M1
  1000. runner: macos-14
  1001. - name: macos-15-M1
  1002. runner: macos-15
  1003. steps:
  1004. - name: Skip Check
  1005. id: skip
  1006. if: needs.file-check.outputs.run != 'true'
  1007. run: echo "SKIPPED"
  1008. - uses: actions/checkout@v4
  1009. id: checkout
  1010. if: needs.file-check.outputs.run == 'true'
  1011. with:
  1012. submodules: recursive
  1013. - name: Install latest bash
  1014. id: install-bash
  1015. if: needs.file-check.outputs.run == 'true'
  1016. run: |
  1017. brew install bash
  1018. - name: Install netdata dependencies
  1019. id: install-nd-dep
  1020. if: needs.file-check.outputs.run == 'true'
  1021. run: |
  1022. bash ./packaging/installer/install-required-packages.sh --dont-wait --non-interactive netdata-all
  1023. - name: Build from source
  1024. id: build-source
  1025. if: needs.file-check.outputs.run == 'true'
  1026. run: |
  1027. sudo bash ./netdata-installer.sh --install-no-prefix /usr/local/netdata --dont-wait --dont-start-it --one-time-build
  1028. - name: Test Agent start up
  1029. id: test-agent
  1030. if: needs.file-check.outputs.run == 'true'
  1031. run: |
  1032. /usr/local/netdata/usr/sbin/netdata -D > ./netdata.log 2>&1 &
  1033. ./packaging/runtime-check.sh
  1034. - name: Failure Notification
  1035. uses: rtCamp/action-slack-notify@v2
  1036. env:
  1037. SLACK_COLOR: 'danger'
  1038. SLACK_FOOTER: ''
  1039. SLACK_ICON_EMOJI: ':github-actions:'
  1040. SLACK_TITLE: 'Build & test from source macOS failed:'
  1041. SLACK_USERNAME: 'GitHub Actions'
  1042. SLACK_MESSAGE: |-
  1043. ${{ github.repository }}: macOS Build and test.
  1044. Checkout: ${{ steps.checkout.outcome }}
  1045. Setup runner: ${{ steps.install-bash.outcome }}
  1046. Install netdata required packages: ${{ steps.install-nd-dep.outcome }}
  1047. Build from source: ${{ steps.build-source.outcome }}
  1048. Test Agent runtime: ${{ steps.test-agent.outcome }}
  1049. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  1050. if: >-
  1051. ${{
  1052. failure()
  1053. && startsWith(github.ref, 'refs/heads/master')
  1054. && github.event_name != 'pull_request'
  1055. && github.repository == 'netdata/netdata'
  1056. }}