-
Notifications
You must be signed in to change notification settings - Fork 141
430 lines (421 loc) · 17.3 KB
/
release.yaml
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
name: Release
on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+
- v[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+ # include prerelease tags too
jobs:
prepare:
permissions:
contents: read
id-token: write
name: Prepare properties
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Prepare build parameters
id: prep
run: |
hack/build/ci/prepare-build-variables.sh
- name: Docker metadata
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # v5.6.1
id: meta
with:
images: dynatrace/dynatrace-operator
tags: ${{ steps.prep.outputs.docker_image_tag }}
labels: |
${{ steps.prep.outputs.docker_image_labels }}
vcs-ref=${{ github.sha }}
outputs:
labels: ${{ steps.meta.outputs.labels }}
version: ${{ steps.prep.outputs.docker_image_tag }}
version_without_prefix: ${{ steps.prep.outputs.docker_image_tag_without_prefix }}
build:
name: Build images
runs-on: ubuntu-latest
needs: [prepare]
strategy:
matrix:
platform: [amd64, arm64, ppc64le, s390x]
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Prepare SBOM
id: sbom
run: |
make release/gen-sbom
- name: Build image
uses: ./.github/actions/build-image
with:
platform: ${{ matrix.platform }}
labels: ${{ needs.prepare.outputs.labels }}
image-tag: ${{ needs.prepare.outputs.version }}
push:
name: Push images
environment: Release
needs: [prepare, build]
runs-on: ubuntu-latest
permissions:
id-token: write
strategy:
matrix:
platform: [amd64, arm64, ppc64le, s390x]
registry: [gcr, dockerhub, amazon-ecr, rhcc]
include:
- registry: gcr
url: gcr.io
repository: GCR_REPOSITORY
username: GCR_USERNAME
password: GCR_JSON_KEY
- registry: dockerhub
url: docker.io
repository: DOCKERHUB_REPOSITORY
username: DOCKERHUB_USERNAME
password: DOCKERHUB_PASSWORD
- registry: amazon-ecr
url: public.ecr.aws
repository: ECR_REPOSITORY
- registry: rhcc
url: quay.io
username: RHCC_USERNAME
password: RHCC_PASSWORD
repository: RHCC_REPOSITORY
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Login to Registry
if: ${{ matrix.registry != 'amazon-ecr' }}
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ${{ matrix.url }}
username: ${{ secrets[matrix.username] }}
password: ${{ secrets[matrix.password] }}
- name: Configure aws credentials
if: ${{ matrix.registry == 'amazon-ecr' }}
uses: aws-actions/configure-aws-credentials@ececac1a45f3b08a01d2dd070d28d111c5fe6722 # v4.1.0
with:
role-to-assume: ${{ secrets.ECR_IMAGEPUSH_ROLE }}
aws-region: us-east-1
- name: Login to Amazon ECR
if: ${{ matrix.registry == 'amazon-ecr' }}
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2.0.1
with:
registry-type: public
- name: Push ${{matrix.platform}} to ${{matrix.registry}}
id: push-image
uses: ./.github/actions/upload-image
with:
platform: ${{ matrix.platform }}
labels: ${{ needs.prepare.outputs.labels }}
version: ${{ needs.prepare.outputs.version }}
registry: ${{ matrix.url }}
repository: ${{ secrets[matrix.repository] }}
- name: Sign image for ${{matrix.registry}}
uses: ./.github/actions/sign-image
with:
image: ${{ matrix.url }}/${{ secrets[matrix.repository] }}:${{ needs.prepare.outputs.version }}-${{ matrix.platform }}@${{steps.push-image.outputs.digest}}
signing-key: ${{ secrets.COSIGN_PRIVATE_KEY }}
signing-password: ${{ secrets.COSIGN_PASSWORD }}
manifest:
name: Create Docker manifests
environment: Release
needs: [prepare, push]
runs-on: ubuntu-latest
permissions:
id-token: write
outputs:
digest: ${{ steps.create-manifests.outputs.digest }}
strategy:
matrix:
registry: [gcr, dockerhub, amazon-ecr, rhcc]
include:
- registry: gcr
url: gcr.io
repository: GCR_REPOSITORY
username: GCR_USERNAME
password: GCR_JSON_KEY
- registry: dockerhub
url: docker.io
repository: DOCKERHUB_REPOSITORY
username: DOCKERHUB_USERNAME
password: DOCKERHUB_PASSWORD
- registry: amazon-ecr
url: public.ecr.aws
repository: ECR_REPOSITORY
- registry: rhcc
url: quay.io
username: RHCC_USERNAME
password: RHCC_PASSWORD
repository: RHCC_REPOSITORY
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Login to Registry
if: ${{ matrix.registry != 'amazon-ecr' }}
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ${{ matrix.url }}
username: ${{ secrets[matrix.username] }}
password: ${{ secrets[matrix.password] }}
- name: Configure aws credentials
if: ${{ matrix.registry == 'amazon-ecr' }}
uses: aws-actions/configure-aws-credentials@ececac1a45f3b08a01d2dd070d28d111c5fe6722 # v4.1.0
with:
role-to-assume: ${{ secrets.ECR_IMAGEPUSH_ROLE }}
aws-region: us-east-1
- name: Login to Amazon ECR
if: ${{ matrix.registry == 'amazon-ecr' }}
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2.0.1
with:
registry-type: public
- name: Create manifests for ${{matrix.registry}}
uses: ./.github/actions/create-manifests
id: create-manifests
with:
version: ${{ needs.prepare.outputs.version }}
registry: ${{ matrix.url }}
repository: ${{ secrets[matrix.repository] }}
combined: true
- name: Sign images for ${{matrix.registry}}
uses: ./.github/actions/sign-image
with:
image: ${{ matrix.url }}/${{ secrets[matrix.repository] }}:${{ needs.prepare.outputs.version }}@${{ steps.create-manifests.outputs.digest }}
signing-key: ${{ secrets.COSIGN_PRIVATE_KEY }}
signing-password: ${{ secrets.COSIGN_PASSWORD }}
attach-sbom:
name: Attach sbom
environment: Release
needs: [ prepare, push, manifest ]
runs-on: ubuntu-latest
permissions:
id-token: write
strategy:
matrix:
registry: [gcr, dockerhub, amazon-ecr]
include:
- registry: gcr
url: gcr.io
repository: GCR_REPOSITORY
username: GCR_USERNAME
password: GCR_JSON_KEY
- registry: dockerhub
url: docker.io
repository: DOCKERHUB_REPOSITORY
username: DOCKERHUB_USERNAME
password: DOCKERHUB_PASSWORD
- registry: amazon-ecr
url: public.ecr.aws
repository: ECR_REPOSITORY
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Login to Registry
if: ${{ matrix.registry != 'amazon-ecr' }}
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ${{ matrix.url }}
username: ${{ secrets[matrix.username] }}
password: ${{ secrets[matrix.password] }}
- name: Configure aws credentials
if: ${{ matrix.registry == 'amazon-ecr' }}
uses: aws-actions/configure-aws-credentials@ececac1a45f3b08a01d2dd070d28d111c5fe6722 # v4.1.0
with:
role-to-assume: ${{ secrets.ECR_IMAGEPUSH_ROLE }}
aws-region: us-east-1
- name: Login to Amazon ECR
if: ${{ matrix.registry == 'amazon-ecr' }}
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2.0.1
with:
registry-type: public
- name: Create sbom for ${{matrix.registry}}
id: sbom
uses: aquasecurity/trivy-action@18f2510ee396bbf400402947b394f2dd8c87dbb0 # 0.29.0
with:
image-ref: ${{ matrix.url }}/${{ secrets[matrix.repository] }}:${{ needs.prepare.outputs.version }}@${{ needs.manifest.outputs.digest }}
format: 'cyclonedx'
output: 'result.json'
skip-dirs: '/usr/share/dynatrace-operator/third_party_licenses'
skip-files: '/usr/local/bin/dynatrace-operator'
- name: Upload sbom to ${{matrix.registry}}
uses: ./.github/actions/upload-sbom
with:
image: ${{ matrix.url }}/${{ secrets[matrix.repository] }}:${{ needs.prepare.outputs.version }}@${{ needs.manifest.outputs.digest }}
sbom: 'result.json'
signing-key: ${{ secrets.COSIGN_PRIVATE_KEY }}
signing-password: ${{ secrets.COSIGN_PASSWORD }}
run-preflight-rhcc:
name: Run preflight for rhcc
environment: Release
needs: [ prepare, push, manifest]
runs-on: ubuntu-latest
env:
SCAN_REGISTRY: "quay.io"
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Login to Registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ${{ env.SCAN_REGISTRY }}
username: ${{ secrets.RHCC_USERNAME }}
password: ${{ secrets.RHCC_PASSWORD }}
- name: Run preflight
uses: ./.github/actions/preflight
with:
version: ${{ needs.prepare.outputs.version }}
registry: ${{ env.SCAN_REGISTRY }}
repository: ${{ secrets.RHCC_REPOSITORY }}
report-name: "preflight.json"
redhat-project-id: ${{ secrets.REDHAT_PROJECT_ID }}
pyxis-api-token: ${{ secrets.PYXIS_API_TOKEN }}
release:
name: Create release
needs: [prepare, build, attach-sbom, manifest, run-preflight-rhcc]
environment: Release
permissions:
contents: write
pull-requests: write
id-token: write
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Golang
uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0
with:
go-version-file: "${{ github.workspace }}/go.mod"
- name: Generate release notes
shell: bash
env:
PRE_RELEASE: ${{ contains(github.ref, '-rc.') }}
run: |
hack/build/ci/generate-release-notes.sh
- name: Generate K8s manifests
shell: bash
env:
VERSION_WITHOUT_PREFIX: ${{ needs.prepare.outputs.version_without_prefix }}
VERSION: ${{ needs.prepare.outputs.version }}
run: |
make manifests/crd/release CHART_VERSION="${VERSION_WITHOUT_PREFIX}"
make manifests/kubernetes/olm IMAGE="public.ecr.aws/dynatrace/dynatrace-operator" TAG="${VERSION}@${{needs.manifest.outputs.digest}}"
make manifests/kubernetes IMAGE="public.ecr.aws/dynatrace/dynatrace-operator" TAG="${VERSION}@${{needs.manifest.outputs.digest}}"
make manifests/openshift/olm IMAGE="registry.connect.redhat.com/dynatrace/dynatrace-operator" TAG="${VERSION}@${{needs.manifest.outputs.digest}}"
make manifests/openshift IMAGE="registry.connect.redhat.com/dynatrace/dynatrace-operator" TAG="${VERSION}@${{needs.manifest.outputs.digest}}"
cp config/deploy/kubernetes/kubernetes.yaml config/deploy/kubernetes/gke-autopilot.yaml
- name: Build helm packages
uses: ./.github/actions/build-helm
with:
version_without_prefix: ${{ needs.prepare.outputs.version_without_prefix }}
github-token: ${{ secrets.GITHUB_TOKEN }}
secring: ${{ secrets.HELM_SECRING }}
passphrase: ${{ secrets.HELM_PASSPHRASE }}
output-dir: "./helm-pkg"
- name: Login Helm to dockerhub
shell: bash
run: |
helm registry login -u "${{ secrets.DOCKERHUB_USERNAME }}" -p "${{ secrets.DOCKERHUB_PASSWORD }}" "registry.hub.docker.com"
- name: Login Docker to dockerhub
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Upload and sign helm package to dockerhub
uses: ./.github/actions/upload-helm
with:
version: ${{ needs.prepare.outputs.version }}
version-without-prefix: ${{ needs.prepare.outputs.version_without_prefix }}
cosign-private-key: ${{ secrets.COSIGN_PRIVATE_KEY }}
cosign-password: ${{ secrets.COSIGN_PASSWORD }}
- name: Configure aws credentials
uses: aws-actions/configure-aws-credentials@ececac1a45f3b08a01d2dd070d28d111c5fe6722 # v4.1.0
with:
role-to-assume: ${{ secrets.ECR_IMAGEPUSH_ROLE }}
aws-region: us-east-1
- name: Login to Amazon ECR
uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2.0.1
with:
registry-type: public
- name: Upload and sign helm package to Amazon ECR
uses: ./.github/actions/upload-helm
with:
registry-url: public.ecr.aws
image-base-url: public.ecr.aws
version: ${{ needs.prepare.outputs.version }}
version-without-prefix: ${{ needs.prepare.outputs.version_without_prefix }}
cosign-private-key: ${{ secrets.COSIGN_PRIVATE_KEY }}
cosign-password: ${{ secrets.COSIGN_PASSWORD }}
- name: Prepare cosign.pub artifact
env:
COSIGN_PUBLIC_KEY: ${{ secrets.COSIGN_PUBLIC_KEY }}
run: |
mkdir -p tmp
echo ${COSIGN_PUBLIC_KEY} | base64 -d > tmp/cosign.pub
- name: Create pre-release
uses: softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda # v2.2.1
if: ${{ contains(github.ref, '-rc.') }}
with:
body_path: ./CHANGELOG.md
files: |
tmp/cosign.pub
config/deploy/dynatrace-operator-crd.yaml
config/deploy/kubernetes/kubernetes.yaml
config/deploy/openshift/openshift.yaml
config/deploy/kubernetes/kubernetes-csi.yaml
config/deploy/openshift/openshift-csi.yaml
token: ${{ secrets.GITHUB_TOKEN }}
prerelease: true
draft: true
fail_on_unmatched_files: true
- name: Create release
uses: softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda # v2.2.1
if: ${{ !contains(github.ref, '-rc.') }}
with:
body_path: ./CHANGELOG.md
files: |
tmp/cosign.pub
config/deploy/dynatrace-operator-crd.yaml
config/deploy/kubernetes/kubernetes.yaml
config/deploy/kubernetes/gke-autopilot.yaml
config/deploy/openshift/openshift.yaml
config/deploy/kubernetes/kubernetes-csi.yaml
config/deploy/openshift/openshift-csi.yaml
helm-pkg/dynatrace-operator-${{ needs.prepare.outputs.version_without_prefix }}.tgz
helm-pkg/dynatrace-operator-${{ needs.prepare.outputs.version_without_prefix }}.tgz.prov
token: ${{ secrets.GITHUB_TOKEN }}
prerelease: false
draft: true
fail_on_unmatched_files: true
- name: Update index helm file
if: ${{ !contains(github.ref, '-rc.') }}
env:
VERSION_WITHOUT_PREFIX: ${{ needs.prepare.outputs.version_without_prefix }}
run: |
echo "Getting index.yaml from main branch"
git fetch origin main
git restore --source origin/main -- config/helm/repos/stable/index.yaml
echo "Updating Helm repo index"
hack/build/ci/generate-new-helm-index-yaml.sh "helm-pkg" ${{ needs.prepare.outputs.version_without_prefix }}
- name: Create pull request for adding helm index to main branch
if: ${{ !contains(github.ref, '-rc.') }}
uses: peter-evans/create-pull-request@67ccf781d68cd99b580ae25a5c18a1cc84ffff1f # v7.0.6
with:
base: main
delete-branch: true
branch: create-pull-request/update-helm-index
branch-suffix: short-commit-hash
add-paths: |
./config/helm/repos/stable/index.yaml
./config/helm/repos/stable/index.yaml.previous
title: '[Automatic] Update index for ${{ github.ref }} release'
commit-message: Update index.yaml
committer: GitHub <[email protected]>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
body: |
# Description
Upgrade `index.yaml` to include latest version of the helm chart.
## How can this be tested?
Helm upgrade to and install of `${{ github.ref }}` works.
## Checklist
- [x] PR is labeled accordingly