build.yml 29 KB

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