From 950fe9fb10cd26f467973f95a59279e25bbd1bbb Mon Sep 17 00:00:00 2001 From: RDW Date: Tue, 29 Oct 2024 04:24:27 +0100 Subject: [PATCH 1/2] Create a cleanup script to delete old release snapshots They're taking up a lot of space, but I haven't found a setting that would allow deleting them automatically. --- delete-old-snapshots.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 delete-old-snapshots.sh diff --git a/delete-old-snapshots.sh b/delete-old-snapshots.sh new file mode 100755 index 0000000..24c026d --- /dev/null +++ b/delete-old-snapshots.sh @@ -0,0 +1,15 @@ +set -eu + +test $GH_TOKEN # Mandatory +echo "Using GitHub token: $GH_TOKEN" + +# Delete all but the latest snapshot (no point in storing them) +OUTDATED_RELEASE_TAGS=$(git tag --sort=-creatordate | tail -n +2) +TAG_COUNT=$(git tag --sort=-creatordate | tail -n +2 | wc -l) + +echo "Found $TAG_COUNT outdated release tags" + +for TAG in $OUTDATED_RELEASE_TAGS; do + echo "Deleting tagged release $TAG" + gh release delete "$TAG" --yes --cleanup-tag +done From 9a850cba39b3a9ca9b58f4d576c341f8614a5644 Mon Sep 17 00:00:00 2001 From: RDW Date: Tue, 29 Oct 2024 04:29:19 +0100 Subject: [PATCH 2/2] Add a workaround for lingering tags to the cleanup script When deleting releases manually, the tag may still persist locally. --- delete-old-snapshots.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/delete-old-snapshots.sh b/delete-old-snapshots.sh index 24c026d..2a11a87 100755 --- a/delete-old-snapshots.sh +++ b/delete-old-snapshots.sh @@ -3,6 +3,9 @@ set -eu test $GH_TOKEN # Mandatory echo "Using GitHub token: $GH_TOKEN" +# Local tags may be out of sync (just delete any offenders) +git fetch --prune --prune-tags origin + # Delete all but the latest snapshot (no point in storing them) OUTDATED_RELEASE_TAGS=$(git tag --sort=-creatordate | tail -n +2) TAG_COUNT=$(git tag --sort=-creatordate | tail -n +2 | wc -l)