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