build.yml 41 KB

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