-
Notifications
You must be signed in to change notification settings - Fork 6
218 lines (185 loc) · 6.04 KB
/
publish-helm-charts-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
---
name: "Publish Helm Charts: Release"
on:
release:
types:
- published
env:
CHARTS_DIR: 'charts/ploigos-workflow'
jobs:
# NOTE:
# * currently no way to filter on release actions
# * don't want to react to every releasee since the Helm Chart release creates releases
# * don't want to do do on tags with that filter since this workflow will update the release
# tag and would cause infinte actions to kick off
check-if-valid-publish-event:
runs-on: ubuntu-latest
outputs:
execute-workflow: ${{ steps.execute-workflow.outputs.execute-workflow }}
steps:
- name: Check if release should trigger this workflow ✅
id: execute-workflow
run: |
if [[ ${GITHUB_REF} =~ v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
CONTINUE="true"
else
CONTINUE="false"
fi
echo "::set-output name=execute-workflow::${CONTINUE}"
setup:
runs-on: ubuntu-latest
needs:
- check-if-valid-publish-event
if: needs.check-if-valid-publish-event.outputs.execute-workflow == 'true'
outputs:
helm-charts: ${{ steps.helm-charts.outputs.helm-charts }}
helm-charts-new-semver: ${{ steps.helm-chart-semver.outputs.fullversion }}
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2
- name: Determine Helm Charts to release ⚙️
id: helm-charts
run: ${GITHUB_WORKSPACE}/.github/scripts/determine-helm-charts-to-release.py
- name: Helm Charts to Release 📌
run: echo ${{ steps.helm-charts.outputs.helm-charts }}
- name: Determine Helm Chart Version ⚙️
id: helm-chart-semver
uses: booxmedialtd/ws-action-parse-semver@v1
with:
input_string: "${{ github.ref }}"
version_extractor_regex: '\/v(.*)$'
lint:
runs-on: ubuntu-latest
needs:
- setup
strategy:
fail-fast: false
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Helm 🧰
uses: azure/setup-helm@v1
with:
version: v3.6.1
- name: Setup Python 🧰🐍
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Setup chart-testing 🧰
uses: helm/[email protected]
- name: Lint with chart-testing 🧪🖋
run: ${GITHUB_WORKSPACE}/.github/scripts/lint.sh
install-test:
runs-on: ubuntu-latest
needs:
- setup
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Helm 🧰
uses: azure/setup-helm@v1
with:
version: v3.6.1
- name: Setup Python 🐍
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Setup chart-testing 🧰
uses: helm/[email protected]
- name: Setup kind cluster 🧰
uses: helm/[email protected]
- name: Configure Kubernetes 🧰
run: ${GITHUB_WORKSPACE}/.github/scripts/configure-kube.sh
- name: Test install with chart-testing 🧪
run: ${GITHUB_WORKSPACE}/.github/scripts/test.sh
prepare-for-release:
runs-on: ubuntu-latest
needs:
- setup
- lint
- install-test
strategy:
matrix:
helm-chart: ${{ fromJson(needs.setup.outputs.helm-charts) }}
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2
- name: Set up Python 🐍
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Update Helm Chart version 🖋
uses: docker://mikefarah/yq:3
with:
args:
yq write --inplace ${{ env.CHARTS_DIR }}/${{ matrix.helm-chart }}/Chart.yaml version ${{ needs.setup.outputs.helm-charts-new-semver }}
# NOTE: workaround for https://github.com/helm/chart-releaser/issues/95
- name: Create Chart.lock ⚙️
run: |
helm dependency update ${{ env.CHARTS_DIR }}/${{ matrix.helm-chart }}
# NOTE:
# Chart.lock uploaded as workaround for https://github.com/helm/chart-releaser/issues/95
- name: Upload Helm Chart prepared for release 🔺
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.helm-chart }}
path: |
${{ env.CHARTS_DIR }}/${{ matrix.helm-chart }}/Chart.yaml
${{ env.CHARTS_DIR }}/${{ matrix.helm-chart }}/Chart.lock
release:
runs-on: ubuntu-latest
needs:
- setup
- prepare-for-release
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Download Helm Charts prepared to release 🔻
id: download-helm-charts
uses: actions/download-artifact@v2
with:
path: ${{ env.CHARTS_DIR }}
- name: Push Updated Helm Chart Verions 💾
uses: EndBug/add-and-commit@v7
with:
default_author: github_actions
message: "Updated Helm Chart versions for latest merge to: ${{ github.ref }}"
push: true
branch: main
- name: Setup Helm 🧰
uses: azure/setup-helm@v1
with:
version: v3.6.1
- name: Run chart-releaser 🚀
uses: helm/[email protected]
with:
charts_dir: "${{ env.CHARTS_DIR }}"
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
# NOTE:
# it is important this happens after the run of the chart-releaser so that
# the cr tool can detect changes from the last tag (the tag that triggered this run)
# and this release.
- name: Update triggering release git tag to included updated Helm Chart versions 🖋
run: |
git tag -d v${{ needs.setup.outputs.helm-charts-new-semver }}
git tag v${{ needs.setup.outputs.helm-charts-new-semver }}
git push origin v${{ needs.setup.outputs.helm-charts-new-semver }} --force
update-release-tags:
runs-on: ubuntu-latest
needs:
- release
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2
with:
fetch-depth: 0
ref: main
- name: Update release tags for latest major and minor releases 🖋
uses: bewuethr/release-tracker-action@v1