@@ -13,19 +13,24 @@ REPO="MRiscoCProUI" # e.g., "my-project"
1313TAG_NAME=" $1 " # Pass the tag name as the first argument
1414# ---------------------
1515
16+ attout () { echo -e " \033[0;30m$1 \033[0m" ; }
17+ errout () { echo -e " \033[0;31m$1 \033[0m" ; }
18+ succout () { echo -e " \033[0;32m$1 \033[0m" ; }
19+ warnout () { echo -e " \033[0;33m$1 \033[0m" ; }
20+
1621# Check for required GitHub CLI and JQ tools
1722if ! command -v gh & > /dev/null; then
18- echo " Error: GitHub CLI (gh) not found. Please install it."
23+ errout " Error: GitHub CLI (gh) not found. Please install it."
1924 exit 1
2025fi
2126if ! command -v jq & > /dev/null; then
22- echo " Error: jq not found. Please install it (e.g., sudo apt install jq)."
27+ errout " Error: jq not found. Please install it (e.g., sudo apt install jq)."
2328 exit 1
2429fi
2530
2631# Ensure a tag name was provided
2732if [ -z " $TAG_NAME " ]; then
28- echo " Usage: $0 [tag_name]"
33+ warnout " Usage: $0 [tag_name]"
2934 exit 1
3035fi
3136
@@ -36,39 +41,39 @@ echo "--- Starting iterative deletion of assets for tag: $TAG_NAME ---"
3641ASSETS_JSON=$( gh api " repos/$OWNER /$REPO /releases/tags/$TAG_NAME " --jq ' .assets[].name' 2> /dev/null)
3742
3843if [ $? -ne 0 ]; then
39- echo " Error: Could not retrieve release information for tag $TAG_NAME "
40- echo " Check if the tag exists and your token/permissions are correct."
44+ errout " Error: Could not retrieve release information for tag $TAG_NAME "
45+ warnout " Check if the tag exists and your token/permissions are correct."
4146 exit 1
4247fi
4348
4449if [ -z " $ASSETS_JSON " ]; then
45- echo " No assets found for tag $TAG_NAME . Exiting."
50+ errout " No assets found for tag $TAG_NAME . Exiting."
4651 exit 0
4752fi
4853
4954# 2. Iterate through each asset name and delete it
5055echo " $ASSETS_JSON " | while read -r ASSET_NAME; do
51- echo " Attempting to delete asset: $ASSET_NAME "
56+ attout " Attempting to delete asset: $ASSET_NAME "
5257
5358 # gh release delete-asset performs the one-by-one deletion
5459 # --yes flag skips the confirmation prompt
5560 gh release delete-asset " $TAG_NAME " " $ASSET_NAME " --repo " $OWNER /$REPO " --yes
5661
5762 if [ $? -ne 0 ]; then
58- echo " ❌ Failed to delete: $ASSET_NAME "
63+ errout " ❌ Failed to delete: $ASSET_NAME "
5964 # The loop will automatically continue to the next asset
6065 fi
6166done
6267
63- echo " --- ✅ Asset deletion process complete! ---"
68+ succout " --- ✅ Asset deletion process complete! ---"
6469
65- echo " Deleting release and tag $TAG_NAME automatically..."
70+ attout " Deleting release and tag $TAG_NAME automatically..."
6671
6772gh release delete " $TAG_NAME " --repo " $OWNER /$REPO " --cleanup-tag --yes
6873
6974if [ $? -eq 0 ]; then
70- echo " 🎉 Release and tag $TAG_NAME successfully deleted."
75+ succout " 🎉 Release and tag $TAG_NAME successfully deleted."
7176else
72- echo " ⚠️ Failed to delete release and tag $TAG_NAME . You may need to delete the tag manually."
77+ errout " ⚠️ Failed to delete release and tag $TAG_NAME . You may need to delete the tag manually."
7378 # The script will now exit, but the prior asset deletion was successful.
7479fi
0 commit comments