This repository has been archived by the owner on Dec 21, 2023. It is now read-only.
325 lines (285 loc) · 11.4 KB
/
release.yml
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
name: Release
on:
push:
branches:
- master
- '[0-9]+.[1-9][0-9]*.x'
workflow_dispatch:
env:
NODE_VERSION: 16
GO_VERSION: "~1.20"
KEPTN_BOT_NAME: "Keptn Bot"
KEPTN_BOT_EMAIL: "keptn-bot <86361500+keptn-bot@users.noreply.github.com>"
RELEASE_NOTES_FILE: "RELEASE-BODY.md"
BUILD_EVERYTHING: 'true'
BRIDGE_ARTIFACT_PREFIX: "BRIDGE"
API_ARTIFACT_PREFIX: "API"
APPROVAL_SVC_ARTIFACT_PREFIX: "APPROVAL_SVC"
DISTRIBUTOR_ARTIFACT_PREFIX: "DISTRIBUTOR"
CLI_ARTIFACT_PREFIX: "CLI"
SHIPYARD_CONTROLLER_ARTIFACT_PREFIX: "SHIPYARD_CONTROLLER"
SECRET_SVC_ARTIFACT_PREFIX: "SECRET_SVC"
RESOURCE_SVC_ARTIFACT_PREFIX: "RESOURCE_SVC"
REMEDIATION_SVC_ARTIFACT_PREFIX: "REMEDIATION_SVC"
LIGHTHOUSE_SVC_ARTIFACT_PREFIX: "LIGHTHOUSE_SVC"
MONGODB_DS_ARTIFACT_PREFIX: "MONGODB_DS"
STATISTICS_SVC_ARTIFACT_PREFIX: "STATISTICS_SVC"
WEBHOOK_SVC_ARTIFACT_PREFIX: "WEBHOOK_SVC"
BRIDGE_ARTIFACT: "bridge2"
BRIDGE_FOLDER: "bridge/"
BRIDGE_DOCKER_TEST_TARGET: "builder-test-unit"
API_ARTIFACT: "api"
API_FOLDER: "api/"
API_DOCKER_TEST_TARGET: "builder-test"
APPROVAL_SVC_ARTIFACT: "approval-service"
APPROVAL_SVC_FOLDER: "approval-service/"
APPROVAL_SVC_DOCKER_TEST_TARGET: "builder-test"
DISTRIBUTOR_ARTIFACT: "distributor"
DISTRIBUTOR_FOLDER: "distributor/"
DISTRIBUTOR_DOCKER_TEST_TARGET: "builder-test"
CLI_ARTIFACT: "cli"
CLI_FOLDER: "cli/"
CLI_DOCKER_TEST_TARGET: "builder-test"
SHIPYARD_CONTROLLER_ARTIFACT: "shipyard-controller"
SHIPYARD_CONTROLLER_FOLDER: "shipyard-controller/"
SHIPYARD_CONTROLLER_DOCKER_TEST_TARGET: "builder-test"
SECRET_SVC_ARTIFACT: "secret-service"
SECRET_SVC_FOLDER: "secret-service/"
SECRET_SVC_DOCKER_TEST_TARGET: "builder-test"
RESOURCE_SVC_ARTIFACT: "resource-service"
RESOURCE_SVC_FOLDER: "resource-service/"
RESOURCE_SVC_DOCKER_TEST_TARGET: "builder-test"
REMEDIATION_SVC_ARTIFACT: "remediation-service"
REMEDIATION_SVC_FOLDER: "remediation-service/"
REMEDIATION_SVC_DOCKER_TEST_TARGET: "builder-test"
LIGHTHOUSE_SVC_ARTIFACT: "lighthouse-service"
LIGHTHOUSE_SVC_FOLDER: "lighthouse-service/"
LIGHTHOUSE_SVC_DOCKER_TEST_TARGET: "builder-test"
MONGODB_DS_ARTIFACT: "mongodb-datastore"
MONGODB_DS_FOLDER: "mongodb-datastore/"
MONGODB_DS_DOCKER_TEST_TARGET: "builder-test"
STATISTICS_SVC_ARTIFACT: "statistics-service"
STATISTICS_SVC_FOLDER: "statistics-service/"
STATISTICS_SVC_DOCKER_TEST_TARGET: "builder-test"
WEBHOOK_SVC_ARTIFACT: "webhook-service"
WEBHOOK_SVC_FOLDER: "webhook-service/"
WEBHOOK_SVC_DOCKER_TEST_TARGET: "builder-test"
defaults:
run:
shell: bash
jobs:
release-please:
runs-on: ubuntu-22.04
concurrency:
group: release
outputs:
tag_name: ${{ steps.release.outputs.tag_name }}
releases_created: ${{ steps.release.outputs.releases_created }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run release please
uses: google-github-actions/release-please-action@v3
id: release
with:
command: manifest
token: ${{ secrets.GITHUB_TOKEN }}
default-branch: ${{ github.ref_name }}
prepare:
name: Prepare release run
runs-on: ubuntu-20.04
concurrency:
group: release
needs: release-please
if: needs.release-please.outputs.releases_created == 'true'
outputs:
branch: ${{ steps.current_branch.outputs.branch }}
keptn-spec-version: ${{ steps.keptn_spec_version.outputs.keptn-spec-version }}
datetime: ${{ steps.get_datetime.outputs.DATETIME }}
git_sha: ${{ steps.extract_branch.outputs.GIT_SHA }}
BUILD_INSTALLER: ${{ steps.check_modified_files.outputs.BUILD_INSTALLER }}
BUILD_CLI: ${{ steps.check_modified_files.outputs.BUILD_CLI }}
BUILD_MATRIX: ${{ steps.check_modified_files.outputs.BUILD_MATRIX }}
BUILD_MATRIX_EMPTY: ${{ steps.check_modified_files.outputs.BUILD_MATRIX_EMPTY }}
GO_VERSION: ${{ steps.get_go_version.outputs.GO_VERSION }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.KEPTN_BOT_TOKEN }}
- name: Extract branch name
id: extract_branch
# see https://github.com/keptn/gh-action-extract-branch-name for details
uses: keptn/gh-action-extract-branch-name@main
- name: Get current date and time
id: get_datetime
run: |
DATETIME=$(date +'%Y%m%d%H%M')
echo "DATETIME=$DATETIME" >> "$GITHUB_OUTPUT"
- name: Find current branch
id: current_branch
run: |
branch=${GITHUB_REF#refs/heads/}
echo "branch=${branch}" >> $GITHUB_OUTPUT
- name: Get keptn spec version
id: keptn_spec_version
run: |
git submodule update --init
cd specification
KEPTN_SPEC_VERSION=$(git describe --tags)
echo "keptn-spec-version=${KEPTN_SPEC_VERSION}" >> $GITHUB_OUTPUT
- name: Prepare artifact build matrix
id: check_modified_files
env:
BUILD_EVERYTHING: ${{ env.BUILD_EVERYTHING }}
RELEASE_BUILD: 'true'
run: |
./gh-actions-scripts/prepare_changed_artifacts.sh ""
############################################################################
# Build Docker Images
############################################################################
docker_build:
name: Unit Tests and Build Image
needs: [release-please, prepare]
strategy:
matrix: ${{ fromJson(needs.prepare.outputs.BUILD_MATRIX) }}
uses: ./.github/workflows/test-and-build-docker-images.yml
secrets: inherit
with:
artifact: ${{ matrix.config.artifact }}
tags: |
quay.io/keptn/${{ matrix.config.artifact }}:${{ needs.release-please.outputs.tag_name }}
ghcr.io/keptn/${{ matrix.config.artifact }}:${{ needs.release-please.outputs.tag_name }}
should-run: ${{ matrix.config.should-run }}
should-push-image: ${{ matrix.config.should-push-image }}
docker-test-target: ${{ matrix.config.docker-test-target }}
working-dir: ${{ matrix.config.working-dir }}
version: ${{ needs.release-please.outputs.tag_name }}
datetime: ${{ needs.prepare.outputs.datetime }}
gitSha: ${{ needs.prepare.outputs.git_sha }}
build-installer: ${{ needs.prepare.outputs.BUILD_INSTALLER }}
build-everything: "true"
release-build: "true"
############################################################################
# Build Helm Charts (only relevant for build_everything)
############################################################################
build-helm-charts:
needs: [release-please, prepare]
name: Build Helm Charts
uses: ./.github/workflows/build-helm-charts.yml
secrets: inherit
with:
branch: ${{ needs.prepare.outputs.branch }}
version: ${{ needs.release-please.outputs.tag_name }}
keptn-spec-version: ${{ needs.prepare.outputs.keptn-spec-version }}
release: true
############################################################################
# Build CLI
############################################################################
build-cli:
needs: [release-please, prepare]
uses: ./.github/workflows/build-cli.yml
with:
branch: ${{ needs.prepare.outputs.branch }}
version: ${{ needs.release-please.outputs.tag_name }}
release: true
############################################################################
# Release
############################################################################
release:
name: "Release"
runs-on: ubuntu-20.04
needs: [release-please, prepare, docker_build, build-helm-charts, build-cli]
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
path: keptn
token: ${{ secrets.KEPTN_BOT_TOKEN }}
- name: Checkout helm-charts repo
uses: actions/checkout@v4
with:
repository: keptn/helm-charts
path: helm-charts
ref: gh-pages
token: ${{ secrets.KEPTN_BOT_TOKEN }}
- name: Set up Node.js
uses: actions/setup-node@v3.8.1
with:
node-version: ${{ env.NODE_VERSION }}
- name: Configure Git
env:
KEPTN_BOT_NAME: ${{ env.KEPTN_BOT_NAME }}
KEPTN_BOT_EMAIL: ${{ env.KEPTN_BOT_EMAIL }}
run: |
git config --global user.name "$KEPTN_BOT_NAME"
git config --global user.email "$KEPTN_BOT_EMAIL"
- name: Download Release Artifacts
uses: actions/download-artifact@v3
with:
path: ./dist
- name: Get k8s resource stats
working-directory: keptn
env:
HELM_TEMPLATE: template.yml
RESOURCE_JSON: resources.json
RESOURCE_MARKDOWN: resources.md
RELEASE_NOTES_FILE: ${{ env.RELEASE_NOTES_FILE }}
run: ./gh-actions-scripts/generate-k8s-resource-stats.sh
- name: Upload Release Assets
working-directory: keptn
env:
GITHUB_TOKEN: ${{ secrets.KEPTN_BOT_TOKEN }}
RELEASE_TAG: ${{ needs.release-please.outputs.tag_name }}
run: |
gh release upload "$RELEASE_TAG" ../dist/keptn-installer/*.tgz
gh release upload "$RELEASE_TAG" ../dist/keptn-installer/*.tgz.prov
gh release upload "$RELEASE_TAG" ../dist/keptn-cli/*.tar.gz
- name: Upload helm charts
env:
GITHUB_TOKEN: ${{ secrets.KEPTN_BOT_TOKEN }}
RELEASE_TAG: ${{ needs.release-please.outputs.tag_name }}
run: |
mv ./dist/keptn-installer/*.tgz ./helm-charts/packages
mv ./dist/keptn-installer/*.tgz.prov ./helm-charts/packages
cd ./helm-charts
helm repo index ./ --url https://charts.keptn.sh/ --merge ./index.yaml
git add *.tgz
git add index.yaml
git commit --signoff -m "Keptn Release $RELEASE_TAG"
git push
- name: Attach container image digests to release
working-directory: keptn
env:
GITHUB_TOKEN: ${{ secrets.KEPTN_BOT_TOKEN }}
DIGEST_FILE: "digests.csv"
RELEASE_TAG: ${{ needs.release-please.outputs.tag_name }}
run: |
cat ../dist/image-digests/digest-*.txt >> $DIGEST_FILE
gh release upload "$RELEASE_TAG" "$DIGEST_FILE"
- name: Attach Helm provenance public key to release
working-directory: keptn
env:
GITHUB_TOKEN: ${{ secrets.KEPTN_BOT_TOKEN }}
RELEASE_TAG: ${{ needs.release-please.outputs.tag_name }}
run: gh release upload "$RELEASE_TAG" './assets/pubring.gpg'
generate-sboms:
name: Generate SBOMs
runs-on: ubuntu-22.04
needs: [release-please, prepare, docker_build]
strategy:
matrix: ${{ fromJson(needs.prepare.outputs.BUILD_MATRIX) }}
steps:
- name: Generate SBOM
uses: anchore/sbom-action@v0.14.3
with:
image: ghcr.io/keptn/${{ matrix.config.artifact }}:${{ needs.release-please.outputs.tag_name }}
artifact-name: sbom-${{ matrix.config.artifact }}-${{ needs.release-please.outputs.tag_name }}
output-file: ./sbom-${{ matrix.config.artifact }}-${{ needs.release-please.outputs.tag_name }}.spdx.json
- name: Attach SBOM to release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ needs.release-please.outputs.tag_name }}
files: ./sbom-${{ matrix.config.artifact }}-${{ needs.release-please.outputs.tag_name }}.spdx.json