repoconfig-packages.yml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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 && sudo apt-get install -y python3-ruamel.yaml
  35. - name: Read build matrix
  36. id: set-matrix
  37. run: |
  38. matrix="$(.github/scripts/gen-matrix-repoconfig.py)"
  39. echo "Generated matrix: ${matrix}"
  40. echo "matrix=${matrix}" >> "${GITHUB_OUTPUT}"
  41. - name: Failure Notification
  42. uses: rtCamp/action-slack-notify@v2
  43. env:
  44. SLACK_COLOR: 'danger'
  45. SLACK_ICON_EMOJI: ':github-actions:'
  46. SLACK_TITLE: 'Repository Package Build matrix generation failed:'
  47. SLACK_USERNAME: 'GitHub Actions'
  48. SLACK_MESSAGE: |-
  49. ${{ github.repository }}: Failed to generate build matrix for repository package build.
  50. Checkout: ${{ steps.checkout.outcome }}
  51. Prepare Tools: ${{ steps.prepare.outcome }}
  52. Read Build Matrix: ${{ steps.set-matrix.outcome }}
  53. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  54. if: >-
  55. ${{
  56. failure()
  57. && github.event_name != 'pull_request'
  58. && startsWith(github.ref, 'refs/heads/master')
  59. && github.repository == 'netdata/netdata'
  60. }}
  61. build:
  62. name: Build
  63. runs-on: ubuntu-latest
  64. env:
  65. DISABLE_TELEMETRY: 1
  66. DOCKER_CLI_EXPERIMENTAL: enabled
  67. needs:
  68. - matrix
  69. strategy:
  70. matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
  71. # We intentiaonally disable the fail-fast behavior so that a
  72. # build failure for one version doesn't prevent us from publishing
  73. # successfully built and tested packages for another version.
  74. fail-fast: false
  75. max-parallel: 8
  76. steps:
  77. - name: Checkout
  78. id: checkout
  79. uses: actions/checkout@v4
  80. # Unlike normally, we do not need a deep clone or submodules for this.
  81. - name: Fetch base image
  82. id: fetch-images
  83. uses: nick-invision/retry@v2
  84. with:
  85. max_attempts: 3
  86. retry_wait_seconds: 30
  87. timeout_seconds: 900
  88. command: docker pull --platform ${{ matrix.platform }} ${{ matrix.base_image }}
  89. - name: Build Packages
  90. id: build
  91. shell: bash
  92. run: |
  93. docker run --security-opt seccomp=unconfined -e DISABLE_TELEMETRY=1 --platform ${{ matrix.platform }} \
  94. -v "$PWD":/netdata ${{ matrix.base_image }} \
  95. /netdata/packaging/repoconfig/build-${{ matrix.format }}.sh
  96. - name: Upload Packages
  97. id: publish
  98. if: github.event_name != 'pull_request' && github.repository == 'netdata/netdata'
  99. continue-on-error: true
  100. shell: bash
  101. env:
  102. PKG_CLOUD_TOKEN: ${{ secrets.PACKAGE_CLOUD_API_KEY }}
  103. run: |
  104. printf "Packages to upload:\n%s" "$(ls artifacts/*.${{ matrix.format }})"
  105. for pkgfile in artifacts/*.${{ matrix.format }} ; do
  106. .github/scripts/package_cloud_wrapper.sh yank "${REPO_PREFIX}/${{ matrix.pkgclouddistro }}" \
  107. "$(basename "${pkgfile}")" || true
  108. .github/scripts/package_cloud_wrapper.sh push "${REPO_PREFIX}/${{ matrix.pkgclouddistro }}" "${pkgfile}"
  109. .github/scripts/package_cloud_wrapper.sh yank "${REPO_PREFIX}-edge/${{ matrix.pkgclouddistro }}" \
  110. "$(basename "${pkgfile}")" || true
  111. .github/scripts/package_cloud_wrapper.sh push "${REPO_PREFIX}-edge/${{ matrix.pkgclouddistro }}" "${pkgfile}"
  112. .github/scripts/package_cloud_wrapper.sh yank "${REPO_PREFIX}-repoconfig/${{ matrix.pkgclouddistro }}" \
  113. "$(basename "${pkgfile}")" || true
  114. .github/scripts/package_cloud_wrapper.sh push "${REPO_PREFIX}-repoconfig/${{ matrix.pkgclouddistro }}" "${pkgfile}"
  115. done
  116. - name: SSH setup
  117. id: ssh-setup
  118. if: github.event_name != 'pull_request' && github.repository == 'netdata/netdata'
  119. uses: shimataro/ssh-key-action@v2
  120. with:
  121. key: ${{ secrets.NETDATABOT_PACKAGES_SSH_KEY }}
  122. name: id_ecdsa
  123. known_hosts: ${{ secrets.PACKAGES_KNOWN_HOSTS }}
  124. - name: Upload to packages.netdata.cloud
  125. id: package-upload
  126. if: github.event_name != 'pull_request' && github.repository == 'netdata/netdata'
  127. run: |
  128. for arch in ${{ matrix.arches }}; do
  129. for suffix in '' -edge -repoconfig ; do
  130. .github/scripts/package-upload.sh \
  131. ${{ matrix.pkgclouddistro }} \
  132. ${arch} \
  133. ${{ matrix.format }} \
  134. netdata/netdata${suffix}
  135. done
  136. done
  137. - name: Failure Notification
  138. if: ${{ failure() && github.repository == 'netdata/netdata' }}
  139. uses: rtCamp/action-slack-notify@v2
  140. env:
  141. SLACK_COLOR: 'danger'
  142. SLACK_FOOTER: ''
  143. SLACK_ICON_EMOJI: ':github-actions:'
  144. SLACK_TITLE: 'Repository Package Build failed:'
  145. SLACK_USERNAME: 'GitHub Actions'
  146. SLACK_MESSAGE: |-
  147. ${{ github.repository }}: ${{ matrix.pkgclouddistro }} ${{ matrix.version }} repository package build failed.
  148. Checkout: ${{ steps.checkout.outcome }}
  149. Fetch images: ${{ steps.fetch-images.outcome }}
  150. Build: ${{ steps.build.outcome }}
  151. Publish to PackageCloud: ${{ steps.publish.outcome }}
  152. Import SSH Key: ${{ steps.ssh-setup.outcome }}
  153. Publish to packages.netdata.cloud: ${{ steps.package-upload.outcome }}
  154. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}