Skip to content

Commit f8f664b

Browse files
committed
Add unpublish command
1 parent 328bb41 commit f8f664b

File tree

1 file changed

+46
-3
lines changed

1 file changed

+46
-3
lines changed

build.sh

+46-3
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ if [ "$1" = "publish" ]; then
8383
echo "You are preparing the following release:"
8484
echo "========================================"
8585
echo ""
86-
echo "Version Name: $VERSION_NAME"
87-
echo "Version Code: $VERSION_CODE"
86+
printf "Version Name:\t\t%s\n" "$VERSION_NAME"
87+
printf "Version Code:\t\t%s\n" "$VERSION_CODE"
8888
echo ""
8989
echo "Before pushing, please ensure you have:"
9090
echo "- tested your build thoroughly on"
@@ -109,7 +109,50 @@ if [ "$1" = "publish" ]; then
109109
fi
110110

111111
#
112-
# COMMAND: build
112+
# COMMAND: unpublish
113+
#
114+
if [ "$1" = "unpublish" ]; then
115+
echo "Fetching all releases..."
116+
git fetch
117+
118+
RELEASE_TAG_NAME="v$VERSION_NAME"
119+
120+
CONFIRMED=0
121+
case "$@[@]" in *"-c"*) CONFIRMED=1 ;; esac
122+
123+
echo "Validating..."
124+
if ! GIT_DIR=./.git git rev-parse "$RELEASE_TAG_NAME" >/dev/null 2>&1; then
125+
echo "Version $VERSION_NAME doesn't exist."
126+
exit 1
127+
fi
128+
129+
echo "Validation succeeded."
130+
echo ""
131+
132+
133+
if [ "$CONFIRMED" -ne 1 ]; then
134+
echo "=============================================="
135+
echo "You are about to remove the following release:"
136+
echo "=============================================="
137+
echo ""
138+
printf "Published Tag:\t\t%s\n" "$RELEASE_TAG_NAME"
139+
printf "Version Name:\t\t%s\n" "$VERSION_NAME"
140+
printf "Version Code:\t\t%s\n" "$VERSION_CODE"
141+
echo ""
142+
echo "To confirm you wish to proceed, please run the"
143+
echo "same command again, specifying -c."
144+
exit 0
145+
fi
146+
147+
echo "Unpublishing release."
148+
git tag -d "$RELEASE_TAG_NAME"
149+
git push origin ":refs/tags/$RELEASE_TAG_NAME"
150+
151+
exit 0
152+
fi
153+
154+
#
155+
# COMMAND (implicit): build
113156
#
114157

115158
# Collect parameters.

0 commit comments

Comments
 (0)