build.yml 33 KB

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