Skip to content

Commit

Permalink
feat: Delete obsolete tags in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaurin committed Aug 31, 2024
1 parent 632fbd5 commit 3b8da28
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions scripts/delete_gh_release_assets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
set -e
set -o pipefail

# You can run this script as-is. It will delete all assets in all tags except the assets in the latest tag.

# Delete all 7z files from a GitHub release
# Usage: delete_gh_release_assets <release>
# Example: delete_gh_release_assets "v0.9.13+2023-06-18-001"
function delete_gh_release_assets() {
gh release view "$1" --json assets -q '.assets[].name' | grep '\.7z$' | xargs -n1 gh release delete-asset "$1"
}

export -f delete_gh_release_assets

# Deletes all assets from all releases except from the latest release
# Deletes all assets in parallel from all releases except from the latest release
# Documentation: Call bash function via xargs: https://unix.stackexchange.com/questions/158564/how-to-use-defined-function-with-xargs
gh release list --json tagName -q '.[1:].[].tagName' | xargs -n1 bash -c 'delete_gh_release_assets "$@"' _
export -f delete_gh_release_assets
gh release list --json tagName -q '.[1:].[].tagName' | xargs -P0 -n1 bash -c 'delete_gh_release_assets "$@"' _

0 comments on commit 3b8da28

Please sign in to comment.