-
Notifications
You must be signed in to change notification settings - Fork 6
198 lines (169 loc) · 6.92 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
name: release
on:
workflow_dispatch:
inputs:
releaseTag:
description: releaseTag to set v1.2.3, v1.2.3-beta, etc. or auto version will be set
required: false
draftTag:
description: draftTag with the release notes. Can be found at the release page. E.g. untagged-777fe0c3b1edc8bd78f6
required: true
makeLatestRelease:
type: boolean
description: github:latestRelease
required: true
preRelease:
type: boolean
description: artifacthub:preRelease
required: true
containsSecurityUpdates:
type: boolean
description: artifacthub:containsSecurityUpdates
required: true
swear:
description: I solemnly swear that the inputs are correct and I run the workflow from the correct branch!
type: choice
options:
- "yes"
- "yes, I do"
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: log inputs
run: |
echo releaseTag=${{inputs.draftTag}}
echo draftTag=${{inputs.draftTag}}
echo makeLatestRelease=${{inputs.makeLatestRelease}}
echo preRelease=${{inputs.preRelease}}
echo containsSecurityUpdates=${{inputs.containsSecurityUpdates}}
echo swear=${{inputs.swear}}
- name: validate inputs
run: |
string=${{inputs.releaseTag}}
if [[ ${string:0:1} != "v" ]]; then
echo "The first character is not 'v'"
echo "Make sure that releaseTag has a form of 'v1.2.3'"
exit 2
fi
string=${{inputs.draftTag}}
if [[ $string != untagged-* ]]; then
echo "draftTag does not start with 'untagged-'"
echo "Make sure to copy the id from a draft at https://github.com/weka/csi-wekafs/releases"
echo "It should have a form of 'untagged-286bdd99389b598e48c4'"
exit 2
fi
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
token: ${{ secrets.PAT }} # https://github.com/stefanzweifel/git-auto-commit-action#push-to-protected-branches
fetch-depth: 0
- run: gh release view ${{inputs.draftTag}}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Configure git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Get version
id: version
uses: codacy/git-version@2.8.0
with:
prefix: v
minor-identifier: /feat(ure)*:/
major-identifier: /breaking:/
- name: Set package version
id: set_version
env:
VERSION: ${{ steps.version.outputs.version }}
INPUT_VERSION: ${{ inputs.releaseTag }}
run: |
if [[ $INPUT_VERSION ]]; then
VERSION=$INPUT_VERSION
fi
VERSION=`echo $VERSION | sed "s|SNAPSHOT|$GITHUB_REF_NAME|"`
echo "version=$VERSION" >> $GITHUB_OUTPUT
VERSION_WITHOUT=`echo $VERSION | sed 's/^v//1'`
out="$(echo "${{ steps.auto_version.outputs.version }}" | sed 's/^v//1')"
cd charts/csi-wekafsplugin
yq -i '.version = "'$VERSION_WITHOUT'"' Chart.yaml
yq -i '.appVersion = "'$VERSION'"' Chart.yaml
yq -i '.csiDriverVersion = "'$VERSION_WITHOUT'"' values.yaml
yq -i '.sources[0] = "'https://github.com/weka/csi-wekafs/tree/$VERSION'"' Chart.yaml
yq -i '.annotations."artifacthub.io/prerelease" = "'${{ inputs.preRelease }}'"' Chart.yaml
yq -i '.annotations."artifacthub.io/containsSecurityUpdates" = "'${{ inputs.containsSecurityUpdates }}'"' Chart.yaml
echo ------------------ values ------------------
cat values.yaml
echo --------------------chart ------------------
cat Chart.yaml
- name: Update RELEASE.md
env:
VERSION: ${{ steps.set_version.outputs.version }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release view ${{inputs.draftTag}} --json body | jq -r .body > changelog
sed '$d' changelog > changelog1 # delete last line
# insert release note at the beginning
# sed doesn't work well here
echo "# Release $VERSION" >> CHANGELOG.md
cat changelog1 >> CHANGELOG.md
cat RELEASE.md >> CHANGELOG.md
# release note will taken from here by helm/chart-releaser-action
cat changelog1 > charts/csi-wekafsplugin/CHANGELOG.md
mv CHANGELOG.md RELEASE.md
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
registry: quay.io
- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
pull: true
tags: quay.io/weka.io/csi-wekafs:${{ steps.set_version.outputs.version }}
cache-from: type=gha
cache-to: type=gha,mode=max
labels: |
revision='${{ steps.set_version.outputs.version }}'
build-args: |
VERSION='${{ steps.set_version.outputs.version }}'
- name: helm-docs
uses: addnab/docker-run-action@v3
with:
image: jnorwood/helm-docs:latest
options: -v ${{ github.workspace }}:/data
run: |
cd /data
helm-docs -s file -c charts -o ../../README.md -t ../README.md.gotmpl
helm-docs -s file -c charts
- run: gh release delete ${{inputs.draftTag}} --yes
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# https://github.com/stefanzweifel/git-auto-commit-action#push-to-protected-branches
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Release ${{ steps.set_version.outputs.version }}
# https://colinwilson.uk/2022/01/27/how-to-sign-helm-charts-using-chart-releaser-action/
- name: Prepare GPG key
run: |
gpg_dir=.cr-gpg
mkdir "$gpg_dir"
keyring="$gpg_dir/secring.gpg"
base64 -d <<< "$GPG_KEYRING_BASE64" > "$keyring"
passphrase_file="$gpg_dir/passphrase"
echo "$GPG_PASSPHRASE" > "$passphrase_file"
echo "CR_PASSPHRASE_FILE=$passphrase_file" >> "$GITHUB_ENV"
echo "CR_KEYRING=$keyring" >> "$GITHUB_ENV"
env:
GPG_KEYRING_BASE64: "${{ secrets.GPG_KEYRING_BASE64 }}"
GPG_PASSPHRASE: "${{ secrets.GPG_PASSPHRASE }}"
- uses: helm/chart-releaser-action@v1.5.0
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
CR_RELEASE_NAME_TEMPLATE: "v{{ .Version }}"
CR_GENERATE_RELEASE_NOTES: true
CR_MAKE_RELEASE_LATEST: ${{ inputs.makeLatestRelease }}
CR_RELEASE_NOTES_FILE: CHANGELOG.md
CR_SIGN: true
CR_KEY: "WEKA CSI"