You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
build-push-action/remove-tags.sh

52 lines
1.1 KiB
Bash

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#!/usr/bin/env bash
#
# delete-old-tags.sh
#
# USAGE
# chmod +x delete-old-tags.sh
# ./delete-old-tags.sh
#
# NOTES
# • Assumes your forks remote is called “origin”.
# • Safe to re-run; it silently ignores tags that are already gone.
# • Groups remote deletions in batches of ≤50 so the push command line
# never gets too long.
set -euo pipefail
TAGS=$(cat <<'EOF'
v6.15.0
v6.14.0
EOF
)
#######################################
# 1. Delete the tags locally
#######################################
for tag in $TAGS; do
git tag -d "$tag" 2>/dev/null || true
done
#######################################
# 2. Delete them on GitHub (origin)
# push in batches of 50
#######################################
batch=()
count=0
for tag in $TAGS; do
batch+=(":refs/tags/$tag")
((count++))
if (( count == 50 )); then
git push origin "${batch[@]}"
batch=()
count=0
fi
done
# push any remainder
if (( ${#batch[@]} )); then
git push origin "${batch[@]}"
fi
echo "✅ All listed tags have been removed locally and on origin."