Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

Commit

Permalink
Check if version is already installed
Browse files Browse the repository at this point in the history
  • Loading branch information
florisvdg committed Apr 30, 2020
1 parent a4b68a8 commit b483e82
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/commands/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,20 @@ steps:
echo -e "${OK_COLOR}==> Creating directories${NO_COLOR}"
$SUDO mkdir -p /usr/local/secrethub/bin
# Retrieve latest version
if [ -n "${SECRETHUB_CLI_VERSION}" ]; then
if [ "${SECRETHUB_CLI_VERSION:-latest}" != "latest" ]; then
VERSION=v${SECRETHUB_CLI_VERSION}
else
# Retrieve latest version
echo -e "${OK_COLOR}==> Retrieving latest version${NO_COLOR}"
VERSION=$(curl --silent "https://api.github.com/repos/secrethub/secrethub-cli/releases/latest" | grep tag_name | awk -F\" '{ print $4 }')
fi
# Exit if version is already installed
if command -v secrethub >/dev/null 2>&1 && secrethub --version 2>&1 | cut -d "," -f 1 | grep -q "$(echo $VERSION | cut -c 2-)$"; then
echo -e "${OK_COLOR}==> Version ${VERSION} is already installed${NO_COLOR}"
exit 0
fi
echo -e "${OK_COLOR}==> Downloading version ${VERSION}${NO_COLOR}"
ARCHIVE_NAME=secrethub-$VERSION-$OS-$ARCH
LINK_TAR=https://github.com/secrethub/secrethub-cli/releases/download/$VERSION/$ARCHIVE_NAME.tar.gz
Expand Down

0 comments on commit b483e82

Please sign in to comment.