Skip to content

Commit 69f8711

Browse files
feat: add script to clean up alpha releases
1 parent af9c10e commit 69f8711

1 file changed

Lines changed: 106 additions & 0 deletions

File tree

scripts/cleanup_alpha.sh

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#!/bin/bash
2+
set -e
3+
4+
echo "=== Alpha Release Cleanup Script ==="
5+
echo ""
6+
7+
# Fetch all alpha releases
8+
echo "Fetching alpha releases..."
9+
RELEASES=$(gh release list --limit 1000 | grep "alpha" | awk -F'\t' '{print $3}' || true)
10+
11+
# Fetch all alpha tags
12+
echo "Fetching alpha tags..."
13+
git fetch --tags 2>/dev/null || true
14+
TAGS=$(git tag -l "*alpha*" || true)
15+
16+
# Combine and get unique names
17+
ALL_ITEMS=$(echo -e "$RELEASES\n$TAGS" | sort -u | grep -v '^$' || true)
18+
19+
echo ""
20+
echo "========================================="
21+
echo "FOUND ITEMS:"
22+
echo "========================================="
23+
echo ""
24+
25+
if [ -z "$ALL_ITEMS" ]; then
26+
echo "No alpha releases or tags found."
27+
exit 0
28+
fi
29+
30+
# Display each item with its status
31+
for ITEM in $ALL_ITEMS; do
32+
HAS_RELEASE=""
33+
HAS_TAG=""
34+
35+
if echo "$RELEASES" | grep -q "^${ITEM}$"; then
36+
HAS_RELEASE=""
37+
else
38+
HAS_RELEASE=""
39+
fi
40+
41+
if echo "$TAGS" | grep -q "^${ITEM}$"; then
42+
HAS_TAG=""
43+
else
44+
HAS_TAG=""
45+
fi
46+
47+
echo " - $ITEM [Release: $HAS_RELEASE | Tag: $HAS_TAG]"
48+
done
49+
50+
echo ""
51+
echo "========================================="
52+
echo ""
53+
54+
# Process each item
55+
for ITEM in $ALL_ITEMS; do
56+
HAS_RELEASE=false
57+
HAS_TAG=false
58+
59+
if echo "$RELEASES" | grep -q "^${ITEM}$"; then
60+
HAS_RELEASE=true
61+
fi
62+
63+
if echo "$TAGS" | grep -q "^${ITEM}$"; then
64+
HAS_TAG=true
65+
fi
66+
67+
read -p "Delete '$ITEM'? (y/N) " -n 1 -r
68+
echo ""
69+
70+
if [[ $REPLY =~ ^[Yy]$ ]]; then
71+
# Delete release if it exists
72+
if [ "$HAS_RELEASE" = true ]; then
73+
echo -n " Deleting release... "
74+
if gh release delete "$ITEM" --yes 2>/dev/null; then
75+
echo "✓ deleted"
76+
else
77+
echo "✗ failed"
78+
fi
79+
fi
80+
81+
# Delete remote tag if it exists
82+
if [ "$HAS_TAG" = true ]; then
83+
echo -n " Deleting remote tag... "
84+
if git push origin ":refs/tags/$ITEM" 2>/dev/null; then
85+
echo "✓ deleted"
86+
else
87+
echo "✗ failed (may not exist on remote)"
88+
fi
89+
90+
# Delete local tag
91+
echo -n " Deleting local tag... "
92+
if git tag -d "$ITEM" 2>/dev/null; then
93+
echo "✓ deleted"
94+
else
95+
echo "✗ failed"
96+
fi
97+
fi
98+
else
99+
echo " Skipped."
100+
fi
101+
echo ""
102+
done
103+
104+
echo "========================================="
105+
echo "✓ Cleanup complete!"
106+
echo "========================================="

0 commit comments

Comments
 (0)