-
Notifications
You must be signed in to change notification settings - Fork 192
229 lines (202 loc) · 8.75 KB
/
release-version.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
226
227
228
229
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.21"
jobs:
release-message:
uses: apecloud/apecloud-cd/.github/workflows/[email protected]
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.55.2
- 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-branch:
needs: release-test
uses: apecloud/apecloud-cd/.github/workflows/[email protected]
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/[email protected]
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/[email protected]
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-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 "[email protected]"
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 kubeblocks-addons ${{ github.ref_name }}
uses: actions/checkout@v4
with:
repository: apecloud/kubeblocks-addons
path: kubeblocks-addons
ref: ${{ github.ref_name }}
- name: checkout kbcli code
uses: actions/checkout@v4
with:
repository: apecloud/kbcli
path: kbcli
ref: ${{ github.ref_name }}
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/
FILE_CHANGES=`git diff --name-only ${{ github.sha }}`
git add ${{ github.workspace }}/docs/user_docs/cli/*
if [[ -n "$FILE_CHANGES" ]]; then
echo $FILE_CHANGES
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "[email protected]"
git commit -a -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: 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 "[email protected]"
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/[email protected]
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/[email protected]
with:
TYPE: "2"
CONTENT: "release ${{ inputs.release_version }} error"
APECD_REF: "v0.1.38"
secrets: inherit