Repository navigation
307 lines (274 loc) · 11.8 KB
/
Copy pathrelease-version.yml
File metadata and controls
307 lines (274 loc) · 11.8 KB
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
name: Release Version
on:
workflow_dispatch:
inputs:
release_version:
description: 'The version of release'
required: true
default: ''
run-name: ref_name:${{ github.ref_name }} release_version:${{ inputs.release_version }}
env:
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
GO_VERSION: "1.24"
permissions:
contents: read
jobs:
release-message:
uses: apecloud/apecloud-cd/.github/workflows/feishui-message.yml@v0.1.38
with:
TYPE: "1"
VERSION: "${{ inputs.release_version }}"
APECD_REF: "v0.1.38"
secrets: inherit
release-test:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
ops: [ 'manifests', 'mod-vendor', 'generate', 'lint', 'staticcheck', 'test' ]
steps:
- uses: actions/checkout@v4
- name: install lib
run: |
sudo rm /etc/apt/sources.list.d/microsoft-prod.list
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
libbtrfs-dev \
libdevmapper-dev
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "${{ env.GO_VERSION }}"
- name: Install golangci-lint
if: matrix.ops == 'lint'
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.64.5
- name: make ${{ matrix.ops }}
run: |
make ${{ matrix.ops }}
FILE_CHANGES=`git diff --name-only ${{ github.sha }}`
if [[ ("${{ matrix.ops }}" == 'generate' || "${{ matrix.ops }}" == 'manifests') && -n "$FILE_CHANGES" ]]; then
echo $FILE_CHANGES
echo "make "${{ matrix.ops }}" causes inconsistent files"
exit 1
fi
release-addons-version-check:
name: ${{ matrix.repo }}-version-check
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
repo: [ 'kubeblocks-addons', 'apecloud-addons' ]
outputs:
stable-release: ${{ steps.check_stable_version.outputs.stable-release }}
steps:
- name: check stable version
id: check_stable_version
run: |
RELEASE_VERSION="${{ inputs.release_version }}"
STABLE_RELEASE=0
if [[ "${RELEASE_VERSION}" =~ ^v[0-9]+(\.[0-9]+)*$ ]]; then
STABLE_RELEASE=1
fi
echo stable-release="$STABLE_RELEASE" >> $GITHUB_OUTPUT
- name: checkout ${{ matrix.repo }} ${{ github.ref_name }} code
if: ${{ steps.check_stable_version.outputs.stable-release == '1' }}
uses: actions/checkout@v4
with:
token: ${{ env.GITHUB_TOKEN }}
repository: apecloud/${{ matrix.repo }}
path: ./
ref: ${{ github.ref_name }}
- name: check addon stable versions
if: ${{ steps.check_stable_version.outputs.stable-release == '1' }}
run: |
GIT_BRANCH="${{ github.ref_name }}"
RELEASE_VERSION="${{ inputs.release_version }}"
update_release_notes_script=".github/scripts/update_release_notes.py"
if [[ -f "${update_release_notes_script}" ]]; then
check_file_log="check_addon_stable_versions.log"
touch ${check_file_log}
python3 ${update_release_notes_script} \
--git-branch "${GIT_BRANCH}" \
--git-tag "${RELEASE_VERSION}" \
--dry-run | tee -a ${check_file_log}
NO_STABLE_VERSION=$(cat "${check_file_log}" | (egrep "No stable addon versions found|Pre-release Versions" || true))
if [[ -n "${NO_STABLE_VERSION}" ]]; then
echo "$(tput -T xterm setaf 1)ERROR: No stable addon versions found!$(tput -T xterm sgr0)"
exit 1
fi
fi
send-message-version-check:
needs: [ release-addons-version-check ]
if: ${{ (failure() || cancelled()) && needs.release-addons-version-check.outputs.stable-release == '1' }}
uses: apecloud/apecloud-cd/.github/workflows/feishui-message.yml@v0.1.96
with:
TYPE: "2"
CONTENT: "No stable addon versions found, release error"
APECD_REF: "v0.1.96"
secrets: inherit
release-branch:
needs: [ release-test, release-addons-version-check ]
uses: apecloud/apecloud-cd/.github/workflows/release-branch.yml@v0.1.38
with:
RELEASE_VERSION: "${{ inputs.release_version }}"
RELEASE_BRANCH: "${{ github.ref_name }}"
APECD_REF: "v0.1.38"
secrets: inherit
release-addons-version:
needs: release-branch
uses: apecloud/apecloud-cd/.github/workflows/trigger-workflow.yml@v0.1.38
with:
GITHUB_REPO: "apecloud/kubeblocks-addons"
VERSION: "${{ inputs.release_version }}"
BRANCH_NAME: "${{ needs.release-branch.outputs.release-branch }}"
WORKFLOW_ID: "release-version.yml"
APECD_REF: "v0.1.38"
secrets: inherit
release-addons-version-ent:
needs: release-branch
uses: apecloud/apecloud-cd/.github/workflows/trigger-workflow.yml@v0.1.38
with:
GITHUB_REPO: "apecloud/apecloud-addons"
VERSION: "${{ inputs.release_version }}"
BRANCH_NAME: "${{ needs.release-branch.outputs.release-branch }}"
WORKFLOW_ID: "release-version.yml"
APECD_REF: "v0.1.38"
secrets: inherit
release-storage-providers-version:
needs: release-branch
uses: apecloud/apecloud-cd/.github/workflows/trigger-workflow.yml@v0.1.38
with:
GITHUB_REPO: "apecloud/kubeblocks-storage-providers"
VERSION: "${{ inputs.release_version }}"
BRANCH_NAME: "${{ needs.release-branch.outputs.release-branch }}"
WORKFLOW_ID: "release-version.yml"
APECD_REF: "v0.1.38"
secrets: inherit
release-version:
needs: [ release-addons-version ]
runs-on: ubuntu-latest
steps:
- name: checkout branch ${{ github.ref_name }}
uses: actions/checkout@v4
with:
token: ${{ env.GITHUB_TOKEN }}
ref: ${{ github.ref_name }}
- name: install lib
run: |
sudo rm /etc/apt/sources.list.d/microsoft-prod.list
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
libbtrfs-dev \
libdevmapper-dev
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "${{ env.GO_VERSION }}"
- name: Update apis doc
id: update_apis_doc
run: |
make doc
FILE_CHANGES=`git diff --name-only ${{ github.sha }}`
if [[ -n "$FILE_CHANGES" ]]; then
echo $FILE_CHANGES
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com"
git commit -a -m "chore: auto update apis docs"
fi
echo file_changes=$FILE_CHANGES >> $GITHUB_OUTPUT
RELEASE_COMMIT="$(git rev-parse HEAD)"
echo 'RELEASE_COMMIT='${RELEASE_COMMIT} >> $GITHUB_ENV
- name: checkout kbcli code
uses: actions/checkout@v4
with:
repository: apecloud/kbcli
path: kbcli
ref: "release-1.0"
token: ${{ env.GITHUB_TOKEN }}
- name: Update kbcli doc
id: update_kbcli_doc
run: |
echo "copy kbcli user docs to kubeblocks docs"
rm -rf ${{ github.workspace }}/docs/user_docs/cli/*
cp -r ${{ github.workspace }}/kbcli/docs/user_docs/cli/* ${{ github.workspace }}/docs/user_docs/cli/
rm -rf ${{ github.workspace }}/kbcli
RELEASE_COMMIT_TMP="${{ github.sha }}"
if [[ -n "${RELEASE_COMMIT}" ]]; then
RELEASE_COMMIT_TMP="${RELEASE_COMMIT}"
fi
FILE_CHANGES=`git diff --name-only ${RELEASE_COMMIT_TMP}`
if [[ -n "$FILE_CHANGES" ]]; then
echo $FILE_CHANGES
git add ${{ github.workspace }}/docs/user_docs/cli/*
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com"
git commit -m "chore: auto update kbcli user docs"
fi
echo file_changes=$FILE_CHANGES >> $GITHUB_OUTPUT
RELEASE_COMMIT="$(git rev-parse HEAD)"
echo 'RELEASE_COMMIT='${RELEASE_COMMIT} >> $GITHUB_ENV
- name: Checkout kubeblocks-addons ${{ github.ref_name }}
uses: actions/checkout@v4
with:
repository: apecloud/kubeblocks-addons
path: kubeblocks-addons
ref: ${{ github.ref_name }}
- name: upgrade addons version
id: upgrade_addon_version
run: |
addon_dir="${{ github.workspace }}/deploy/helm/templates/addons"
kb_addon_dir="${{ github.workspace }}/kubeblocks-addons/addons"
for addon_file in $(ls $addon_dir); do
addon_name=$(cat $addon_dir/$addon_file | (grep "\"name\"" || true) | awk '{print $2}'| sed 's/"//g')
addon_version=$(cat $addon_dir/$addon_file | (grep "\"version\"" || true) | awk '{print $2}'| sed 's/"//g')
if [[ -f $kb_addon_dir/$addon_name/Chart.yaml ]]; then
kb_addon_version=$(cat $kb_addon_dir/$addon_name/Chart.yaml | yq eval '.version')
if [[ "$addon_version" != "$kb_addon_version" ]]; then
echo "upgrade $addon_name version to $kb_addon_version"
sed -i "s/^ \"version\".*/ \"version\" \"$kb_addon_version\"/" $addon_dir/$addon_file
fi
fi
done
FILE_CHANGES=`git diff --name-only ${{ env.RELEASE_COMMIT }}`
if [[ -n "$FILE_CHANGES" ]]; then
echo $FILE_CHANGES
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com"
git commit -a -m "chore: auto upgrade kubeblocks addons version"
fi
echo file_changes=$FILE_CHANGES >> $GITHUB_OUTPUT
RELEASE_COMMIT="$(git rev-parse HEAD)"
echo 'RELEASE_COMMIT='${RELEASE_COMMIT} >> $GITHUB_ENV
- name: push changes to new branch
if: ${{ (steps.update_kbcli_doc.outputs.file_changes || steps.update_apis_doc.outputs.file_changes || steps.upgrade_addon_version.outputs.file_changes) && github.ref_name == 'main' }}
uses: ad-m/github-push-action@master
with:
github_token: ${{ env.GITHUB_TOKEN }}
branch: support/auto-update-${{ env.RELEASE_COMMIT }}
- name: auto create pr head new branch
if: ${{ (steps.update_kbcli_doc.outputs.file_changes || steps.update_apis_doc.outputs.file_changes || steps.upgrade_addon_version.outputs.file_changes) && github.ref_name == 'main' }}
run: |
gh pr create --base "${{ github.ref }}" --head "support/auto-update-${{ env.RELEASE_COMMIT }}" --title "chore: auto upgrade addons version or update apis docs or update kbcli user docs" --body ""
- name: push changes to ${{ github.ref_name }}
uses: ad-m/github-push-action@master
if: ${{ (steps.update_kbcli_doc.outputs.file_changes || steps.update_apis_doc.outputs.file_changes || steps.upgrade_addon_version.outputs.file_changes) && github.ref_name != 'main' }}
with:
github_token: ${{ env.GITHUB_TOKEN }}
branch: ${{ github.ref_name }}
- name: push tag ${{ inputs.release_version }}
uses: mathieudutour/github-tag-action@v6.1
with:
custom_tag: ${{ inputs.release_version }}
github_token: ${{ env.GITHUB_TOKEN }}
commit_sha: ${{ env.RELEASE_COMMIT }}
tag_prefix: ""
send-message:
needs: [ release-version, release-addons-version ]
if: ${{ failure() || cancelled() }}
uses: apecloud/apecloud-cd/.github/workflows/feishui-message.yml@v0.1.38
with:
TYPE: "2"
CONTENT: "release ${{ inputs.release_version }} error"
APECD_REF: "v0.1.38"
secrets: inherit