-
Notifications
You must be signed in to change notification settings - Fork 3
225 lines (202 loc) · 8.22 KB
/
helm-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
name: Release Charts
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
release_tag:
type: string
description: "release tag that should be used for this release"
required: true
default: "1.0.5-nightly"
overwrite_existing_release_assets_if_applicable:
type: boolean
description: "Should Overwrite Existing Release Assets, if applicable"
required: false
default: false
helm_merge_with_existing_indexes:
type: boolean
description: "Should Merge Helm Index with Existing Indexes from index.yaml, if applicable"
required: false
default: true
prerelease:
type: boolean
description: "should this release be marked as pre-release"
required: false
default: true
permissions:
contents: write
id-token: write
pages: write
jobs:
release:
# depending on default permission settings for your org (contents being read-only or read-write for workloads), you will have to add permissions
# see: https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Install Helm
uses: azure/setup-helm@v3
- name: Setup Pages
uses: actions/configure-pages@v3
- uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Installing yq (with pip)
run: |+
pip install yq
- name: Add repositories
run: |
for dir in $(ls -d charts/*); do
pushd $dir
helm dependency list 2> /dev/null | tail +2 | head -n -1 | awk '{ print "helm repo add " $1 " " $3 }' | while read cmd; do $cmd; done
helm dependency update
popd
done
- name: Setting up Chart Releaser
run: |+
curl -L0 https://github.com/helm/chart-releaser/releases/download/v1.5.0/chart-releaser_1.5.0_linux_amd64.tar.gz > /tmp/chart-releaser.tar.gz && tar xf /tmp/chart-releaser.tar.gz -C /tmp && mv /tmp/cr /usr/local/bin/cr
- name: Installing Github Cli
run: |+
curl -L0 https://github.com/cli/cli/releases/download/v2.29.0/gh_2.29.0_linux_amd64.tar.gz > /tmp/gh_2.29.0_linux_amd64.tar.gz && tar xf /tmp/gh_2.29.0_linux_amd64.tar.gz -C /tmp && mv /tmp/gh_2.29.0_linux_amd64/bin/gh /usr/local/bin/gh
- name: update version and appVersion in charts' Chart.yaml
run: |+
RELEASE_TAG=${{ github.event.inputs.release_tag }}
for dir in $(ls -d charts/*); do
pushd $dir
sed -i "s/^version:.*/version: $RELEASE_TAG/g" Chart.yaml
sed -i "s/^appVersion:.*/appVersion: $RELEASE_TAG/g" Chart.yaml
popd
done
- name: Releasing Helm Charts
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
RELEASE_TAG: ${{github.event.inputs.release_tag}}
PRE_RELEASE: ${{ github.event.inputs.prerelease }}
OVERWRITE_RELEASE_ASSETS: ${{ github.event.inputs.overwrite_existing_release_assets_if_applicable }}
HELM_MERGE_WITH_EXISTING_RELEASES: ${{ github.event.inputs.helm_merge_with_existing_indexes }}
RELEASE_TITLE: "kloudlite-helm-charts"
GITHUB_REPO_OWNER: ${{github.repository_owner}}
GITHUB_REPO_NAME: ${{github.event.repository.name}}
shell: bash
run: |+
bash scripts/release-script.sh
# - name: Releasing Helm Charts
# env:
# GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
# shell: bash
# run: |+
# set -o allexport
#
# RELEASE_TAG=${{ github.event.inputs.release_tag }}
# PRE_RELEASE=${{ github.event.inputs.prerelease }}
# OVERWRITE_RELEASE_ASSETS=${{ github.event.inputs.overwrite_existing_release_assets_if_applicable }}
#
# HELM_MERGE_WITH_EXISTING_RELEASES=${{ github.event.inputs.helm_merge_with_existing_indexes }}
#
# RELEASE_TITLE="kloudlite-helm-charts"
#
# opts=("-R" "$GITHUB_REPOSITORY")
#
# release=$(gh release list ${opts[@]} | tail -n +1 | (grep -iE "\s+$RELEASE_TAG\s+" || echo -n "") | awk '{print $3}')
# if [[ -z $release ]]; then
# echo "going to create release, as RELEASE ($RELEASE_TAG) does not exist"
# createOpts=${opts[@]}
# if $PRE_RELEASE; then
# createOpts+=("--prerelease")
# fi
# if ! [[ -z $RELEASE_TITLE ]]; then
# createOpts+=("--title" "$RELEASE_TITLE")
# fi
# createOpts+=("--notes" "'$RELEASE_NOTES'")
#
# echo "creating github release with cmd: \`gh release create $RELEASE_TAG ${createOpts[@]}\` "
# eval gh release create $RELEASE_TAG ${createOpts[@]} --generate-notes
# else
# echo "release $release exists, going to build charts, now"
# fi
#
# tar_dir=".chart-releases"
#
# for dir in $(ls -d charts/*); do
# echo cr package $dir --package-path $tar_dir
# cr package $dir --package-path $tar_dir
# done
#
# uploadOpts=${opts[@]}
# if $OVERWRITE_RELEASE_ASSETS; then
# uploadOpts+=("--clobber")
# fi
#
# echo "uploading packaged helm-charts with cmd: \`gh release upload $RELEASE_TAG ${uploadOpts[@]} $tar_dir/*.tgz\`"
# eval gh release upload $RELEASE_TAG ${uploadOpts[@]} $tar_dir/*.tgz
#
# ## updating CRDs
# for file in $(ls crds/*); do
# cat $file >> crds/crds-all.yml
# echo "---" >> crds/crds-all.yml
# done
#
# gh release upload $RELEASE_TAG ${uploadOpts[@]} crds/*.yml
#
# if $HELM_MERGE_WITH_EXISTING_RELEASES; then
# # remove entries related to the current release_tag, for all the charts
# index_file_url="https://${{github.repository_owner}}.github.io/${{github.event.repository.name}}/index.yaml"
# curl -f -L0 $index_file_url | yq -y > $tar_dir/index.yaml
# echo "+++++++ current: index.yaml"
# cat $tar_dir/index.yaml
#
# for dir in $(ls -d charts/*); do
# export CHART_NAME=$(basename $dir)
#
# cat $tar_dir/index.yaml | yq '. | .entries[env.CHART_NAME] = (.entries[env.CHART_NAME] | map_values(select( (. != null) and (.appVersion != env.RELEASE_TAG) )))' -y > /tmp/index2.yaml
#
# mv /tmp/index2.yaml $tar_dir/index.yaml
# done
# fi
#
# echo "++++++ modified index.yaml"
# cat $tar_dir/index.yaml
#
# helm repo index $tar_dir --url https://github.com/$GITHUB_REPOSITORY/releases/download/$RELEASE_TAG --merge $tar_dir/index.yaml
#
# echo "+++++++ new: index.yaml"
# cat $tar_dir/index.yaml
#
# mkdir -p .static-pages
# cp $tar_dir/index.yaml .static-pages/index.yaml
# gh release upload $RELEASE_TAG ${uploadOpts[@]} .static-pages/index.yaml
#
# cat > .static-pages/index.html <<EOF
# <html>
# <head>
# <title>Kloudlite Helm Charts</title>
# </head>
#
# <body>
# <p>Hi, the file you are looking for is located <a href="${index_file_url}">here</a>.</p>
# </body>
# </html>
# EOF
# gh release upload $RELEASE_TAG ${uploadOpts[@]} .static-pages/index.html
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
name: github-pages
path: .static-pages
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: release
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2