Add a job to delete old releases and tags

This commit is contained in:
itm4n
2026-03-29 16:59:41 +02:00
parent f4cf414305
commit 2a7b5d4e91
2 changed files with 35 additions and 0 deletions
+17
View File
@@ -193,3 +193,20 @@ jobs:
else
echo "[*] No release to create"
fi
clean-up-release-history:
name: Clean up release history
needs: [create-release]
runs-on: ubuntu-latest
steps:
- name: Check out master branch
uses: actions/checkout@v5
with:
ref: master
- name: Clean up release and tag history (keep last 10 entries)
id: clean-up-release-history
env:
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
bash ./.github/workflows/clean_up_release_and_tag_history.sh
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
#
# 1. List all releases and tags
# 2. Select the ones older than the last 10 entries
# 3. Iterate the list to delete them sequentially
#
last_error_code=0
for t in $(gh release list --json tagName --jq .[].tagName | tail -n+11); do
echo "[*] Delete release and tag: ${t}";
if ! gh release delete "${t}" --cleanup-tag --yes; then
last_error_code=$?
fi
done
exit $last_error_code