packaging.yml 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. ---
  2. # Handles building of binary packages for the agent.
  3. name: Packages
  4. on:
  5. pull_request:
  6. branches:
  7. - master
  8. - develop
  9. workflow_dispatch:
  10. inputs:
  11. type:
  12. name: Package build type
  13. default: devel
  14. required: true
  15. version:
  16. name: Package version
  17. required: false
  18. env:
  19. DO_NOT_TRACK: 1
  20. jobs:
  21. build:
  22. name: Build
  23. runs-on: ubuntu-latest
  24. env:
  25. DOCKER_CLI_EXPERIMENTAL: enabled
  26. strategy:
  27. matrix:
  28. include:
  29. - {distro: debian, version: "9", pkgclouddistro: debian/stretch, format: deb, base_image: debian, platform: linux/amd64, arch: amd64}
  30. - {distro: debian, version: "9", pkgclouddistro: debian/stretch, format: deb, base_image: debian, platform: linux/i386, arch: i386}
  31. - {distro: debian, version: "10", pkgclouddistro: debian/buster, format: deb, base_image: debian, platform: linux/amd64, arch: amd64}
  32. - {distro: debian, version: "10", pkgclouddistro: debian/buster, format: deb, base_image: debian, platform: linux/i386, arch: i386}
  33. - {distro: debian, version: "11", pkgclouddistro: debian/bullseye, format: deb, base_image: debian, platform: linux/amd64, arch: amd64, alias: bullseye}
  34. - {distro: debian, version: "11", pkgclouddistro: debian/bullseye, format: deb, base_image: debian, platform: linux/i386, arch: i386, alias: bullseye}
  35. - {distro: ubuntu, version: "16.04", pkgclouddistro: ubuntu/xenial, format: deb, base_image: ubuntu, platform: linux/amd64, arch: amd64}
  36. - {distro: ubuntu, version: "16.04", pkgclouddistro: ubuntu/xenial, format: deb, base_image: ubuntu, platform: linux/i386, arch: i386}
  37. - {distro: ubuntu, version: "18.04", pkgclouddistro: ubuntu/bionic, format: deb, base_image: ubuntu, platform: linux/amd64, arch: amd64}
  38. - {distro: ubuntu, version: "18.04", pkgclouddistro: ubuntu/bionic, format: deb, base_image: ubuntu, platform: linux/i386, arch: i386}
  39. - {distro: ubuntu, version: "20.04", pkgclouddistro: ubuntu/focal, format: deb, base_image: ubuntu, platform: linux/amd64, arch: amd64}
  40. - {distro: ubuntu, version: "21.04", pkgclouddistro: ubuntu/hirsute, format: deb, base_image: ubuntu, platform: linux/amd64, arch: amd64}
  41. - {distro: centos, version: "7", pkgclouddistro: el/7, format: rpm, base_image: centos, platform: linux/amd64, arch: amd64}
  42. - {distro: centos, version: "8", pkgclouddistro: el/8, format: rpm, base_image: centos, platform: linux/amd64, arch: amd64}
  43. - {distro: fedora, version: "33", pkgclouddistro: fedora/33, format: rpm, base_image: fedora, platform: linux/amd64, arch: amd64}
  44. - {distro: fedora, version: "34", pkgclouddistro: fedora/34, format: rpm, base_image: fedora, platform: linux/amd64, arch: amd64}
  45. - {distro: opensuse, version: "15.2", pkgclouddistro: opensuse/15.2, format: rpm, base_image: opensuse/leap, platform: linux/amd64, arch: amd64}
  46. - {distro: opensuse, version: "15.3", pkgclouddistro: opensuse/15.3, format: rpm, base_image: opensuse/leap, platform: linux/amd64, arch: amd64}
  47. # We intentiaonally disable the fail-fast behavior so that a
  48. # build failure for one version doesn't prevent us from publishing
  49. # successfully built and tested packages for another version.
  50. fail-fast: false
  51. max-parallel: 8
  52. steps:
  53. - name: Checkout PR # Checkout the PR if it's a PR.
  54. if: github.event_name == 'pull_request'
  55. uses: actions/checkout@v2
  56. with:
  57. fetch-depth: 0 # We need full history for versioning
  58. submodules: recursive
  59. - name: Checkout Tag # Otherwise check out the tag that triggered this.
  60. if: github.event_name == 'workflow_dispatch'
  61. uses: actions/checkout@v2
  62. with:
  63. ref: ${{ github.event.ref }}
  64. fetch-depth: 0 # We need full history for versioning
  65. submodules: recursive
  66. - name: Check Base Branch
  67. run: |
  68. if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
  69. echo "runtype=${{ github.event.inputs.type }}" >> $GITHUB_ENV
  70. case "${{ github.event.inputs.type }}" in
  71. "release")
  72. echo "repo=${{ secrets.PACKAGE_CLOUD_REPO }}" >> $GITHUB_ENV
  73. echo "pkg_version=${{ github.event.inputs.version }}" >> $GITHUB_ENV
  74. echo "pkg_retention_days=365" >> $GITHUB_ENV
  75. ;;
  76. "nightly")
  77. echo "repo=${{ secrets.PACKAGE_CLOUD_REPO }}-edge" >> $GITHUB_ENV
  78. echo "pkg_version=${{ github.event.inputs.version }}" >> $GITHUB_ENV
  79. echo "pkg_retention_days=30" >> $GITHUB_ENV
  80. ;;
  81. *)
  82. echo "repo=${{ secrets.PACKAGE_CLOUD_REPO }}-devel" >> $GITHUB_ENV
  83. echo "pkg_version=0.${GITHUB_SHA}" >> $GITHUB_ENV
  84. echo "pkg_retention_days=30" >> $GITHUB_ENV
  85. ;;
  86. esac
  87. else
  88. echo "runtype=test" >> $GITHUB_ENV
  89. echo "pkg_version=$(cut -d'-' -f 1 packaging/version | sed -e 's/^v//')" >> $GITHUB_ENV
  90. fi
  91. - name: Setup QEMU
  92. if: matrix.platform != 'linux/amd64'
  93. uses: docker/setup-qemu-action@v1
  94. - name: Prepare Docker Environment
  95. shell: bash
  96. run: |
  97. echo '{"cgroup-parent": "/actions_job", "experimental": true}' | sudo tee /etc/docker/daemon.json 2>/dev/null
  98. sudo service docker restart
  99. - name: Set Base Image Version
  100. shell: bash
  101. run: |
  102. if [ -z "${{ matrix.alias }}" ] ; then
  103. echo "version=${{ matrix.version }}" >> $GITHUB_ENV
  104. else
  105. echo "version=${{ matrix.alias }}" >> $GITHUB_ENV
  106. fi
  107. - name: Build Packages
  108. shell: bash
  109. run: |
  110. docker run -e DO_NOT_TRACK=1 -e VERSION=${{ env.pkg_version }} --platform=${{ matrix.platform }} -v $PWD:/netdata netdata/package-builders:${{ matrix.distro }}${{ matrix.version }}
  111. - name: Test Packages
  112. shell: bash
  113. run: |
  114. docker run -e DO_NOT_TRACK=1 -e DISTRO=${{ matrix.distro }} -e VERSION=${{ env.pkg_version }} -e DISTRO_VERSION=${{ env.version }} --platform=${{ matrix.platform }} -v $PWD:/netdata ${{ matrix.base_image }}:${{ env.version }} /netdata/.github/scripts/pkg-test.sh
  115. - name: Upload
  116. if: github.event_name == 'workflow_dispatch'
  117. shell: bash
  118. env:
  119. PKG_CLOUD_TOKEN: ${{ secrets.PACKAGE_CLOUD_API_KEY }}
  120. run: |
  121. echo "Packages to upload:\n$(ls artifacts/*.${{ matrix.format }})"
  122. for pkgfile in artifacts/*.${{ matrix.format }} ; do
  123. .github/scripts/package_cloud_wrapper.sh yank ${{ env.repo }}/${{ matrix.pkgclouddistro }} $(basename ${pkgfile}) || true
  124. .github/scripts/package_cloud_wrapper.sh push ${{ env.repo }}/${{ matrix.pkgclouddistro }} ${pkgfile}
  125. done
  126. - name: Clean
  127. if: github.event_name == 'workflow_dispatch'
  128. shell: bash
  129. env:
  130. REPO: ${{ env.repo }}
  131. PKG_CLOUD_TOKEN: ${{ secrets.PACKAGE_CLOUD_API_KEY }}
  132. PACKAGE_CLOUD_RETENTION_DAYS: ${{ env.pkg_retention_days }}
  133. run: .github/scripts/old_package_purging.sh
  134. - name: Failure Notification
  135. uses: rtCamp/action-slack-notify@v2
  136. env:
  137. SLACK_COLOR: 'danger'
  138. SLACK_FOOTER:
  139. SLACK_ICON_EMOJI: ':github-actions:'
  140. SLACK_TITLE: 'Package Build failed:'
  141. SLACK_USERNAME: 'GitHub Actions'
  142. SLACK_MESSAGE: "${{ matrix.pkgclouddistro }} ${{ matrix.version }} package build for ${{ matrix.arch }} failed."
  143. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  144. if: >-
  145. ${{
  146. failure()
  147. && github.event_name != 'pull_request'
  148. && startsWith(github.ref, 'refs/heads/master')
  149. }}