Skip to content

Commit 5c5998d

Browse files
authored
chore: fix delete cloud release (#747)
1 parent cc9f162 commit 5c5998d

3 files changed

Lines changed: 70 additions & 41 deletions

File tree

.github/utils/utils.sh

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -223,18 +223,28 @@ delete_tag() {
223223
gh_curl -s -X DELETE $GITHUB_API/repos/$GITHUB_REPO/git/refs/tags/$TAG_NAME
224224
}
225225

226+
delete_release_versions_all() {
227+
local versions_str="$TAG_NAME"
228+
if [[ "$versions_str" != *"|"* ]]; then
229+
delete_release_version
230+
return
231+
fi
232+
local -a versions
233+
IFS='|' read -r -a versions <<< "$versions_str"
234+
for version in "${versions[@]}"; do
235+
TAG_NAME="$version"
236+
delete_release_version
237+
done
238+
}
239+
226240
delete_release_version() {
227241
release_id=$( gh_curl -s $GITHUB_API/repos/$GITHUB_REPO/releases/tags/$TAG_NAME | jq -r '.id' )
228242
if [[ -n "$release_id" && "$release_id" != "null" ]]; then
229243
echo "delete $GITHUB_REPO release $TAG_NAME"
230-
if ! gh_curl -s -X DELETE "$GITHUB_API/repos/$GITHUB_REPO/releases/$release_id"; then
231-
echo "error: failed to delete release $TAG_NAME" >&2
232-
fi
244+
gh_curl -s -X DELETE $GITHUB_API/repos/$GITHUB_REPO/releases/$release_id
233245
else
234246
echo "delete $GITHUB_REPO release $TAG_NAME via gh cli"
235-
if ! gh release delete "$TAG_NAME" --repo "$GITHUB_REPO" --yes; then
236-
echo "error: failed to delete release $TAG_NAME via gh cli" >&2
237-
fi
247+
gh release delete "$TAG_NAME" --repo $GITHUB_REPO --yes
238248
fi
239249
delete_tag
240250
}
@@ -270,6 +280,21 @@ delete_release_charts() {
270280
done
271281
}
272282

283+
delete_kubeblocks_release_charts_all() {
284+
local versions_str="$TAG_NAME"
285+
if [[ "$versions_str" != *"|"* ]]; then
286+
delete_kubeblocks_release_chart
287+
return
288+
fi
289+
local -a versions
290+
IFS='|' read -r -a versions <<< "$versions_str"
291+
for version in "${versions[@]}"; do
292+
local clean_v="${version/v/}"
293+
TAG_NAME_TMP="$clean_v"
294+
delete_kubeblocks_release_chart
295+
done
296+
}
297+
273298
delete_kubeblocks_release_chart() {
274299
chart_file="deploy/helm/Chart.yaml"
275300
if [[ -f "$chart_file" ]]; then
@@ -280,6 +305,21 @@ delete_kubeblocks_release_chart() {
280305
fi
281306
}
282307

308+
delete_release_charts_all() {
309+
local versions_str="$TAG_NAME"
310+
if [[ "$versions_str" != *"|"* ]]; then
311+
delete_release_chart
312+
return
313+
fi
314+
local -a versions
315+
IFS='|' read -r -a versions <<< "$versions_str"
316+
for version in "${versions[@]}"; do
317+
local clean_v="${version/v/}"
318+
TAG_NAME_TMP="$clean_v"
319+
delete_release_chart
320+
done
321+
}
322+
283323
delete_release_chart() {
284324
if [[ -n "$CHART_PATH" ]]; then
285325
for chart_name in $(echo "$CHART_PATH" | sed 's/|/ /g'); do
@@ -2142,11 +2182,10 @@ main() {
21422182
trigger_repo_workflow
21432183
;;
21442184
8)
2145-
delete_release_version
2185+
delete_release_versions_all
21462186
;;
21472187
9)
2148-
#delete_release_charts
2149-
delete_kubeblocks_release_chart
2188+
delete_kubeblocks_release_charts_all
21502189
;;
21512190
10)
21522191
delete_docker_images
@@ -2266,7 +2305,7 @@ main() {
22662305
get_cloud_delete_release
22672306
;;
22682307
49)
2269-
delete_release_chart
2308+
delete_release_charts_all
22702309
;;
22712310
50)
22722311
delete_docker_images_cloud

.github/workflows/release-delete-cloud.yml

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,11 @@ jobs:
6464

6565
- name: Delete Cloud releases
6666
run: |
67-
DELETE_VERSIONS="${{ needs.get-version.outputs.delete-version }}"
68-
for del_version in $(echo "${DELETE_VERSIONS}" | sed 's/|/ /g'); do
69-
bash .github/utils/utils.sh \
70-
--type 8 \
71-
--github-repo "apecloud/apecloud" \
72-
--tag-name "${del_version}" \
73-
--github-token "${{ env.GH_TOKEN }}"
74-
done
67+
bash .github/utils/utils.sh \
68+
--type 8 \
69+
--github-repo "apecloud/apecloud" \
70+
--tag-name "${{ needs.get-version.outputs.delete-version }}" \
71+
--github-token "${{ env.GH_TOKEN }}"
7572
7673
delete-github-helm-chart:
7774
runs-on: ubuntu-latest
@@ -101,15 +98,12 @@ jobs:
10198
if [[ "${{ matrix.chart-repo }}" == "helm-charts-enterprise" ]]; then
10299
DELETE_CHARTS="kubeblocks-cloud"
103100
fi
104-
DELETE_VERSIONS="${{ needs.get-version.outputs.delete-version }}"
105-
for del_release in $(echo "${DELETE_VERSIONS}" | sed 's/|/ /g'); do
106-
bash apecloud-cd/.github/utils/utils.sh \
107-
--type 49 \
108-
--github-repo "apecloud/${{ matrix.chart-repo }}" \
109-
--tag-name "${del_release}" \
110-
--chart-path "${DELETE_CHARTS}" \
111-
--github-token ${{ env.GH_TOKEN }}
112-
done
101+
bash apecloud-cd/.github/utils/utils.sh \
102+
--type 49 \
103+
--github-repo "apecloud/${{ matrix.chart-repo }}" \
104+
--tag-name "${{ needs.get-version.outputs.delete-version }}" \
105+
--chart-path "${DELETE_CHARTS}" \
106+
--github-token ${{ env.GH_TOKEN }}
113107
114108
delete-jihulab-helm-chart:
115109
runs-on: ubuntu-latest

.github/workflows/release-delete.yml

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,11 @@ jobs:
5353

5454
- name: delete kubeblocks release
5555
run: |
56-
for release in $(echo "${{ inputs.VERSION }}" | sed 's/|/ /g'); do
57-
bash ${{ github.workspace }}/apecloud-cd/.github/utils/utils.sh \
58-
--type 8 \
59-
--github-repo apecloud/kubeblocks \
60-
--tag-name $release \
61-
--github-token ${{ env.GITHUB_TOKEN }}
62-
done
56+
bash ${{ github.workspace }}/apecloud-cd/.github/utils/utils.sh \
57+
--type 8 \
58+
--github-repo apecloud/kubeblocks \
59+
--tag-name "${{ inputs.VERSION }}" \
60+
--github-token ${{ env.GITHUB_TOKEN }}
6361
6462
- name: delete Jihulab kubeblocks release
6563
if: ${{ always() }}
@@ -96,13 +94,11 @@ jobs:
9694

9795
- name: delete github helm chart release
9896
run: |
99-
for release in $(echo "${{ inputs.VERSION }}" | sed 's/|/ /g'); do
100-
bash ${{ github.workspace }}/apecloud-cd/.github/utils/utils.sh \
101-
--type 9 \
102-
--github-repo apecloud/helm-charts \
103-
--tag-name $release \
104-
--github-token ${{ env.GITHUB_TOKEN }}
105-
done
97+
bash ${{ github.workspace }}/apecloud-cd/.github/utils/utils.sh \
98+
--type 9 \
99+
--github-repo apecloud/helm-charts \
100+
--tag-name "${{ inputs.VERSION }}" \
101+
--github-token ${{ env.GITHUB_TOKEN }}
106102
107103
- name: delete Jihulab helm chart release
108104
if: ${{ always() }}

0 commit comments

Comments
 (0)