Skip to content

Commit

Permalink
Add unpublish command
Browse files Browse the repository at this point in the history
  • Loading branch information
SamJakob committed Jun 9, 2020
1 parent 328bb41 commit f8f664b
Showing 1 changed file with 46 additions and 3 deletions.
49 changes: 46 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ if [ "$1" = "publish" ]; then
echo "You are preparing the following release:"
echo "========================================"
echo ""
echo "Version Name: $VERSION_NAME"
echo "Version Code: $VERSION_CODE"
printf "Version Name:\t\t%s\n" "$VERSION_NAME"
printf "Version Code:\t\t%s\n" "$VERSION_CODE"
echo ""
echo "Before pushing, please ensure you have:"
echo "- tested your build thoroughly on"
Expand All @@ -109,7 +109,50 @@ if [ "$1" = "publish" ]; then
fi

#
# COMMAND: build
# COMMAND: unpublish
#
if [ "$1" = "unpublish" ]; then
echo "Fetching all releases..."
git fetch

RELEASE_TAG_NAME="v$VERSION_NAME"

CONFIRMED=0
case "$@[@]" in *"-c"*) CONFIRMED=1 ;; esac

echo "Validating..."
if ! GIT_DIR=./.git git rev-parse "$RELEASE_TAG_NAME" >/dev/null 2>&1; then
echo "Version $VERSION_NAME doesn't exist."
exit 1
fi

echo "Validation succeeded."
echo ""


if [ "$CONFIRMED" -ne 1 ]; then
echo "=============================================="
echo "You are about to remove the following release:"
echo "=============================================="
echo ""
printf "Published Tag:\t\t%s\n" "$RELEASE_TAG_NAME"
printf "Version Name:\t\t%s\n" "$VERSION_NAME"
printf "Version Code:\t\t%s\n" "$VERSION_CODE"
echo ""
echo "To confirm you wish to proceed, please run the"
echo "same command again, specifying -c."
exit 0
fi

echo "Unpublishing release."
git tag -d "$RELEASE_TAG_NAME"
git push origin ":refs/tags/$RELEASE_TAG_NAME"

exit 0
fi

#
# COMMAND (implicit): build
#

# Collect parameters.
Expand Down

0 comments on commit f8f664b

Please sign in to comment.