master
yml 180 lines 7.04 KB
Raw
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@v6
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
63 build:
64 name: Build
65 runs-on: ubuntu-latest
66 env:
67 DISABLE_TELEMETRY: 1
68 DOCKER_CLI_EXPERIMENTAL: enabled
69 needs:
70 - matrix
71 strategy:
72 matrix: ${{ fromJson(needs.matrix.outputs.matrix) }}
73 # We intentiaonally disable the fail-fast behavior so that a
74 # build failure for one version doesn't prevent us from publishing
75 # successfully built and tested packages for another version.
76 fail-fast: false
77 max-parallel: 8
78 steps:
79 - name: Checkout
80 id: checkout
81 uses: actions/checkout@v6
82 # Unlike normally, we do not need a deep clone or submodules for this.
83 - name: Fetch base image
84 id: fetch-images
85 uses: nick-invision/retry@v4
86 with:
87 max_attempts: 3
88 retry_wait_seconds: 30
89 timeout_seconds: 900
90 command: docker pull --platform ${{ matrix.platform }} ${{ matrix.base_image }}
91 - name: Build Packages
92 id: build
93 shell: bash
94 run: |
95 docker run --security-opt seccomp=unconfined -e DISABLE_TELEMETRY=1 --platform ${{ matrix.platform }} \
96 -v "$PWD":/netdata ${{ matrix.base_image }} \
97 /netdata/packaging/repoconfig/build-${{ matrix.format }}.sh
98 - name: Upload Packages
99 id: publish
100 if: github.event_name != 'pull_request' && github.repository == 'netdata/netdata'
101 continue-on-error: true
102 shell: bash
103 env:
104 PKG_CLOUD_TOKEN: ${{ secrets.PACKAGE_CLOUD_API_KEY }}
105 run: |
106 printf "Packages to upload:\n%s" "$(ls packaging/repoconfig/artifacts/*.${{ matrix.format }})"
107 for pkgfile in artifacts/*.${{ matrix.format }} ; do
108 .github/scripts/package_cloud_wrapper.sh yank "${REPO_PREFIX}-repoconfig/${{ matrix.pkgclouddistro }}" \
109 "$(basename "${pkgfile}")" || true
110 .github/scripts/package_cloud_wrapper.sh push "${REPO_PREFIX}-repoconfig/${{ matrix.pkgclouddistro }}" "${pkgfile}"
111 done
112 - name: SSH setup
113 id: ssh-setup
114 if: github.event_name != 'pull_request' && github.repository == 'netdata/netdata'
115 uses: shimataro/ssh-key-action@v2
116 with:
117 key: ${{ secrets.NETDATABOT_PACKAGES_SSH_KEY }}
118 name: id_ecdsa
119 known_hosts: ${{ secrets.PACKAGES_KNOWN_HOSTS }}
120 - name: Upload to packages.netdata.cloud
121 id: package-upload
122 continue-on-error: true
123 if: github.event_name != 'pull_request' && github.repository == 'netdata/netdata'
124 run: |
125 # shellcheck disable=SC2043
126 for arch in ${{ matrix.arches }}; do
127 .github/scripts/package-upload.sh \
128 packages.netdata.cloud \
129 "${{ matrix.pkgclouddistro }}" \
130 "${arch}" \
131 "${{ matrix.format }}" \
132 netdata/netdata-repoconfig \
133 packaging/repoconfig/artifacts
134 done
135 - name: Import GPG Keys
136 id: import-keys
137 if: matrix.format == 'deb' && github.event_name != 'pull_request'
138 uses: crazy-max/ghaction-import-gpg@v7
139 with:
140 gpg_private_key: ${{ secrets.NETDATABOT_PACKAGE_SIGNING_KEY }}
141 - name: Sign DEB Packages
142 id: sign-deb
143 if: matrix.format == 'deb' && github.event_name != 'pull_request'
144 shell: bash
145 run: .github/scripts/deb-sign.sh packaging/repoconfig/artifacts ${{ steps.import-keys.outputs.fingerprint }}
146 - name: Upload to packages2.netdata.cloud
147 id: package2-upload
148 if: github.event_name != 'pull_request' && github.repository == 'netdata/netdata'
149 run: |
150 # shellcheck disable=SC2043
151 for arch in ${{ matrix.arches }}; do
152 .github/scripts/package-upload.sh \
153 packages2.netdata.cloud \
154 "${{ matrix.pkgclouddistro }}" \
155 "${arch}" \
156 "${{ matrix.format }}" \
157 netdata/netdata-repoconfig \
158 packaging/repoconfig/artifacts
159 done
160 - name: Failure Notification
161 if: ${{ failure() && github.repository == 'netdata/netdata' }}
162 uses: rtCamp/action-slack-notify@v2
163 env:
164 SLACK_COLOR: 'danger'
165 SLACK_FOOTER: ''
166 SLACK_ICON_EMOJI: ':github-actions:'
167 SLACK_TITLE: 'Repository Package Build failed:'
168 SLACK_USERNAME: 'GitHub Actions'
169 SLACK_MESSAGE: |-
170 ${{ github.repository }}: ${{ matrix.pkgclouddistro }} ${{ matrix.version }} repository package build failed.
171 Checkout: ${{ steps.checkout.outcome }}
172 Fetch images: ${{ steps.fetch-images.outcome }}
173 Build: ${{ steps.build.outcome }}
174 Publish to PackageCloud: ${{ steps.publish.outcome }}
175 Import SSH Key: ${{ steps.ssh-setup.outcome }}
176 Publish to packages.netdata.cloud: ${{ steps.package-upload.outcome }}
177 Import GPG Keys: ${{ steps.import-keys.outcome }}
178 Sign DEB Packages: ${{ steps.sign-deb.outcome }}
179 Publish to packages2.netdata.cloud: ${{ steps.package2-upload.outcome }}
180 SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}