repoconfig-packages.yml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. ---
  2. # Handles building of binary packages for the agent.
  3. name: Repository Packages
  4. on:
  5. workflow_dispatch: null
  6. pull_request:
  7. paths:
  8. - packaging/repoconfig/**
  9. - .github/workflows/repoconfig-packages.yml
  10. - .github/data/distros.yml
  11. push:
  12. branches:
  13. - master
  14. paths:
  15. - packaging/repoconfig/**
  16. - .github/workflows/repoconfig-packages.yml
  17. - .github/data/distros.yml
  18. env:
  19. DISABLE_TELEMETRY: 1
  20. REPO_PREFIX: netdata/netdata
  21. jobs:
  22. matrix:
  23. name: Prepare Build Matrix
  24. runs-on: ubuntu-latest
  25. outputs:
  26. matrix: ${{ steps.set-matrix.outputs.matrix }}
  27. steps:
  28. - name: Checkout
  29. id: checkout
  30. uses: actions/checkout@v4
  31. - name: Prepare tools
  32. id: prepare
  33. run: |
  34. sudo apt-get update || true
  35. sudo apt-get install -y python3-ruamel.yaml
  36. - name: Read build matrix
  37. id: set-matrix
  38. run: |
  39. matrix="$(.github/scripts/gen-matrix-repoconfig.py)"
  40. echo "Generated matrix: ${matrix}"
  41. echo "matrix=${matrix}" >> "${GITHUB_OUTPUT}"
  42. - name: Failure Notification
  43. uses: rtCamp/action-slack-notify@v2
  44. env:
  45. SLACK_COLOR: 'danger'
  46. SLACK_ICON_EMOJI: ':github-actions:'
  47. SLACK_TITLE: 'Repository Package Build matrix generation failed:'
  48. SLACK_USERNAME: 'GitHub Actions'
  49. SLACK_MESSAGE: |-
  50. ${{ github.repository }}: Failed to generate build matrix for repository package build.
  51. Checkout: ${{ steps.checkout.outcome }}
  52. Prepare Tools: ${{ steps.prepare.outcome }}
  53. Read Build Matrix: ${{ steps.set-matrix.outcome }}
  54. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  55. if: >-
  56. ${{
  57. failure()
  58. && github.event_name != 'pull_request'
  59. && startsWith(github.ref, 'refs/heads/master')
  60. && github.repository == 'netdata/netdata'
  61. }}
  62. build:
  63. name: Build
  64. runs-on: ubuntu-latest
  65. env:
  66. DISABLE_TELEMETRY: 1
  67. DOCKER_CLI_EXPERIMENTAL: enabled
  68. needs:
  69. - matrix
  70. strategy:
  71. matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
  72. # We intentiaonally disable the fail-fast behavior so that a
  73. # build failure for one version doesn't prevent us from publishing
  74. # successfully built and tested packages for another version.
  75. fail-fast: false
  76. max-parallel: 8
  77. steps:
  78. - name: Checkout
  79. id: checkout
  80. uses: actions/checkout@v4
  81. # Unlike normally, we do not need a deep clone or submodules for this.
  82. - name: Fetch base image
  83. id: fetch-images
  84. uses: nick-invision/retry@v3
  85. with:
  86. max_attempts: 3
  87. retry_wait_seconds: 30
  88. timeout_seconds: 900
  89. command: docker pull --platform ${{ matrix.platform }} ${{ matrix.base_image }}
  90. - name: Build Packages
  91. id: build
  92. shell: bash
  93. run: |
  94. docker run --security-opt seccomp=unconfined -e DISABLE_TELEMETRY=1 --platform ${{ matrix.platform }} \
  95. -v "$PWD":/netdata ${{ matrix.base_image }} \
  96. /netdata/packaging/repoconfig/build-${{ matrix.format }}.sh
  97. - name: Upload Packages
  98. id: publish
  99. if: github.event_name != 'pull_request' && github.repository == 'netdata/netdata'
  100. continue-on-error: true
  101. shell: bash
  102. env:
  103. PKG_CLOUD_TOKEN: ${{ secrets.PACKAGE_CLOUD_API_KEY }}
  104. run: |
  105. printf "Packages to upload:\n%s" "$(ls packaging/repoconfig/artifacts/*.${{ matrix.format }})"
  106. for pkgfile in artifacts/*.${{ matrix.format }} ; do
  107. .github/scripts/package_cloud_wrapper.sh yank "${REPO_PREFIX}-repoconfig/${{ matrix.pkgclouddistro }}" \
  108. "$(basename "${pkgfile}")" || true
  109. .github/scripts/package_cloud_wrapper.sh push "${REPO_PREFIX}-repoconfig/${{ matrix.pkgclouddistro }}" "${pkgfile}"
  110. done
  111. - name: SSH setup
  112. id: ssh-setup
  113. if: github.event_name != 'pull_request' && github.repository == 'netdata/netdata'
  114. uses: shimataro/ssh-key-action@v2
  115. with:
  116. key: ${{ secrets.NETDATABOT_PACKAGES_SSH_KEY }}
  117. name: id_ecdsa
  118. known_hosts: ${{ secrets.PACKAGES_KNOWN_HOSTS }}
  119. - name: Upload to packages.netdata.cloud
  120. id: package-upload
  121. continue-on-error: true
  122. if: github.event_name != 'pull_request' && github.repository == 'netdata/netdata'
  123. run: |
  124. # shellcheck disable=SC2043
  125. for arch in ${{ matrix.arches }}; do
  126. .github/scripts/package-upload.sh \
  127. packages.netdata.cloud \
  128. "${{ matrix.pkgclouddistro }}" \
  129. "${arch}" \
  130. "${{ matrix.format }}" \
  131. netdata/netdata-repoconfig \
  132. packaging/repoconfig/artifacts
  133. done
  134. - name: Import GPG Keys
  135. id: import-keys
  136. if: matrix.format == 'deb' && github.event_name != 'pull_request'
  137. uses: crazy-max/ghaction-import-gpg@v6
  138. with:
  139. gpg_private_key: ${{ secrets.NETDATABOT_PACKAGE_SIGNING_KEY }}
  140. - name: Sign DEB Packages
  141. id: sign-deb
  142. if: matrix.format == 'deb' && github.event_name != 'pull_request'
  143. shell: bash
  144. run: .github/scripts/deb-sign.sh packaging/repoconfig/artifacts ${{ steps.import-keys.outputs.fingerprint }}
  145. - name: Upload to packages2.netdata.cloud
  146. id: package2-upload
  147. if: github.event_name != 'pull_request' && github.repository == 'netdata/netdata'
  148. run: |
  149. # shellcheck disable=SC2043
  150. for arch in ${{ matrix.arches }}; do
  151. .github/scripts/package-upload.sh \
  152. packages2.netdata.cloud \
  153. "${{ matrix.pkgclouddistro }}" \
  154. "${arch}" \
  155. "${{ matrix.format }}" \
  156. netdata/netdata-repoconfig \
  157. packaging/repoconfig/artifacts
  158. done
  159. - name: Failure Notification
  160. if: ${{ failure() && github.repository == 'netdata/netdata' }}
  161. uses: rtCamp/action-slack-notify@v2
  162. env:
  163. SLACK_COLOR: 'danger'
  164. SLACK_FOOTER: ''
  165. SLACK_ICON_EMOJI: ':github-actions:'
  166. SLACK_TITLE: 'Repository Package Build failed:'
  167. SLACK_USERNAME: 'GitHub Actions'
  168. SLACK_MESSAGE: |-
  169. ${{ github.repository }}: ${{ matrix.pkgclouddistro }} ${{ matrix.version }} repository package build failed.
  170. Checkout: ${{ steps.checkout.outcome }}
  171. Fetch images: ${{ steps.fetch-images.outcome }}
  172. Build: ${{ steps.build.outcome }}
  173. Publish to PackageCloud: ${{ steps.publish.outcome }}
  174. Import SSH Key: ${{ steps.ssh-setup.outcome }}
  175. Publish to packages.netdata.cloud: ${{ steps.package-upload.outcome }}
  176. Import GPG Keys: ${{ steps.import-keys.outcome }}
  177. Sign DEB Packages: ${{ steps.sign-deb.outcome }}
  178. Publish to packages2.netdata.cloud: ${{ steps.package2-upload.outcome }}
  179. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}