-
Notifications
You must be signed in to change notification settings - Fork 22
274 lines (238 loc) · 9.33 KB
/
create-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
name: "Create release"
run-name: Create release ${{ inputs.name }}
env:
IMAGE_REPO: europe-docker.pkg.dev/kyma-project/prod/kyma-environment-broker
KYMA_ENVIRONMENT_BROKER_REPO: ${{ github.repository_owner }}/kyma-environment-broker
GIT_EMAIL: team-gopher+1@sap.com
GIT_NAME: kyma-gopher-bot
BUMP_CHART_AND_IMAGES: bump-chart-and-images-${{ inputs.name }}
on:
workflow_dispatch:
inputs:
name:
description: 'Create release'
default: ""
required: true
dry-run:
type: boolean
description: 'Do not publish'
default: false
jobs:
validate-release:
name: Validate release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check if tag already exists
run: |
if [ $(git tag -l ${{ inputs.name }}) ]; then
echo "::error ::Tag ${{ inputs.name }} already exists"
exit 1
fi
- name: Check for existing artifacts from previous release runs
run: "./scripts/check_artifacts_existence.sh ${{ inputs.name }}"
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'
- name: Install requirements
run: pip install -r scripts/python/requirements.txt
- name: Validate labels
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPOSITORY: ${{ env.KYMA_ENVIRONMENT_BROKER_REPO }}
NAME: ${{ inputs.name }}
run: python3 scripts/python/release_label_validator.py
run-unit-tests:
name: Unit tests, go mod tidy
uses: "./.github/workflows/run-unit-tests-reusable.yaml"
with:
release: "true"
run-keb-chart-tests:
name: Validate KEB chart
uses: "./.github/workflows/run-keb-chart-tests-reusable.yaml"
secrets: inherit
with:
last-k3s-versions: ${{ vars.LAST_K3S_VERSIONS }}
release: "true"
version: ${{ inputs.name }}
bumps:
name: Bump sec-scanners-config, KEB chart
needs: [validate-release, run-unit-tests, run-keb-chart-tests]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- run: git pull
- name: Update sec-scanners-config.yaml
run: scripts/create_scan_config.sh "sec-scanners-config.yaml" ${{ inputs.name }}
- name: Bump KEB chart
run: scripts/bump_keb_chart.sh ${{ inputs.name }}
- name: Create PR if anything changed
env:
GH_TOKEN: ${{ secrets.BOT_TOKEN }}
run: |
prs=$(gh pr list -A ${{ env.GIT_NAME }} --state open --json headRefName | jq -r '.[] | .headRefName')
if echo $prs | tr " " '\n' | grep -F -q -x ${{ env.BUMP_CHART_AND_IMAGES }}; then
echo "PR already exists, no need to create a new one"
echo "PR_NUMBER=$(gh pr list --search "base:main head:${{ env.BUMP_CHART_AND_IMAGES }}" --json number | jq -r '.[] | .number')" >> $GITHUB_ENV
elif [ -z "$(git status --porcelain)" ]; then
echo "Nothing changed, no need to create PR"
echo "PR_NUMBER=-1" >> $GITHUB_ENV
else
PR_STATUS=$(scripts/create_bump_pr.sh ${{ inputs.name }})
echo "PR_NUMBER=$(echo "$PR_STATUS" | tail -n 1)" >> $GITHUB_ENV
fi
- name: Await PR merge
timeout-minutes: 45
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [ "$PR_NUMBER" -gt 0 ]; then
scripts/await_pr_merge.sh
git push origin -d ${{ env.BUMP_CHART_AND_IMAGES }}
else
echo "Step skipped"
fi
- name: Save latest commit ref
id: pull-ref
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git checkout main
git stash
git pull
LATEST_COMMIT=$(git rev-parse HEAD)
echo "latest_commit=$LATEST_COMMIT" >> $GITHUB_OUTPUT
echo "Latest commit ref $LATEST_COMMIT"
outputs:
latest_commit: ${{ steps.pull-ref.outputs.latest_commit }}
create-draft:
name: Create draft release
needs: bumps
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ needs.bumps.outputs.latest_commit}}
- name: Create draft release
id: create-draft
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPOSITORY: ${{ github.repository_owner }}/kyma-environment-broker
run: |
RELEASE_ID=$(./scripts/create_draft_release.sh ${{ github.event.inputs.name }})
echo "release_id=$RELEASE_ID" >> $GITHUB_OUTPUT
- name: Create lightweight tag
run: |
git tag ${{ github.event.inputs.name }}
git push origin ${{ github.event.inputs.name }}
outputs:
release_id: ${{ steps.create-draft.outputs.release_id }}
wait-for-commit-statuses:
name: Wait for commit statuses
needs: [create-draft, bumps]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ needs.bumps.outputs.latest_commit}}
- name: Check post-keb-release-build status
uses: ./.github/workflows/check-commit-status
with:
statusName: "post-keb-release-build"
githubToken: ${{ secrets.GITHUB_TOKEN }}
commitRef: ${{ needs.bumps.outputs.latest_commit }}
- name: Check post-keb-runtime-reconciler-job-release-build status
uses: ./.github/workflows/check-commit-status
with:
statusName: "post-keb-runtime-reconciler-job-release-build"
githubToken: ${{ secrets.GITHUB_TOKEN }}
commitRef: ${{ needs.bumps.outputs.latest_commit }}
- name: Check post-keb-subaccount-cleanup-job-release-build status
uses: ./.github/workflows/check-commit-status
with:
statusName: "post-keb-subaccount-cleanup-job-release-build"
githubToken: ${{ secrets.GITHUB_TOKEN }}
commitRef: ${{ needs.bumps.outputs.latest_commit }}
- name: Check post-keb-cleanup-job-release-build status
uses: ./.github/workflows/check-commit-status
with:
statusName: "post-keb-cleanup-job-release-build"
githubToken: ${{ secrets.GITHUB_TOKEN }}
commitRef: ${{ needs.bumps.outputs.latest_commit }}
- name: Check post-keb-deprovision-retrigger-job-release-build status
uses: ./.github/workflows/check-commit-status
with:
statusName: "post-keb-deprovision-retrigger-job-release-build"
githubToken: ${{ secrets.GITHUB_TOKEN }}
commitRef: ${{ needs.bumps.outputs.latest_commit }}
- name: Check post-keb-archiver-job-release-build status
uses: ./.github/workflows/check-commit-status
with:
statusName: "post-keb-archiver-job-release-build"
githubToken: ${{ secrets.GITHUB_TOKEN }}
commitRef: ${{ needs.bumps.outputs.latest_commit }}
- name: Check post-keb-expirator-release-build status
uses: ./.github/workflows/check-commit-status
with:
statusName: "post-keb-expirator-release-build"
githubToken: ${{ secrets.GITHUB_TOKEN }}
commitRef: ${{ needs.bumps.outputs.latest_commit }}
- name: Check post-keb-subaccount-sync-release-build status
uses: ./.github/workflows/check-commit-status
with:
statusName: "post-keb-subaccount-sync-release-build"
githubToken: ${{ secrets.GITHUB_TOKEN }}
commitRef: ${{ needs.bumps.outputs.latest_commit }}
publish-release:
name: Publish release
needs: [wait-for-commit-statuses, bumps, create-draft]
if: ${{ !inputs.dry-run }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ needs.bumps.outputs.latest_commit}}
- run: |
git checkout main
git pull
- name: Package KEB chart
run: |
OUTPUT=$(helm package ./resources/keb -d ./)
FILENAME=$(echo $OUTPUT | grep -o '[^ ]*.tgz')
echo "KEB_CHART=$FILENAME" >> $GITHUB_ENV
- name: Upload packaged KEB chart to release
env:
BOT_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./scripts/upload_assets.sh ${{ needs.create-draft.outputs.release_id }} $KEB_CHART
- name: Update KEB chart metadata
run: |
git checkout gh-pages
helm repo index --url https://github.com/${{ env.KYMA_ENVIRONMENT_BROKER_REPO }}/releases/download/${{ inputs.name }} --merge ./index.yaml ./
- name: Commit KEB chart metadata to gh-pages branch
run: |
git config --global user.email ${{ env.GIT_EMAIL }}
git config --global user.name ${{ env.GIT_NAME }}
git add index.yaml
git commit -m "Update KEB chart metadata with version ${{ inputs.name }}"
git push origin gh-pages
- name: Publish release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPOSITORY: ${{ github.repository_owner }}/kyma-environment-broker
run: |
git checkout main
./scripts/publish_release.sh ${{ needs.create-draft.outputs.release_id }}