diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b6daaf1..658d63a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 diff --git a/.github/workflows/clean_up_release_and_tag_history.sh b/.github/workflows/clean_up_release_and_tag_history.sh new file mode 100644 index 0000000..3bccb17 --- /dev/null +++ b/.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 \ No newline at end of file