Skip to content

Commit b00ade9

Browse files
committed
Add script to get latest binary
1 parent fc1ee8d commit b00ade9

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

get.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
# set -x
3+
set -eo pipefail
4+
5+
BINARY_NAME="hashnode"
6+
HOST_OS=${HOST_OS:-$(uname | tr '[:upper:]' '[:lower:]')}
7+
8+
if [[ $(uname -m) == "x86_64" ]]; then
9+
HOST_ARCH="amd64"
10+
else
11+
HOST_ARCH=${HOST_ARCH:-$(uname -m)}
12+
fi
13+
14+
ARTIFACT_NAME=${BINARY_NAME}-${HOST_OS}-${HOST_ARCH}.tar.gz
15+
16+
LATEST_RELEASE=$(curl -L -s -H 'Accept: application/json' https://github.com/hashnode/hashnode-cli/releases/latest)
17+
LATEST_VERSION=$(echo $LATEST_RELEASE | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/')
18+
ARTIFACT_URL="https://github.com/hashnode/hashnode-cli/releases/download/$LATEST_VERSION/$ARTIFACT_NAME"
19+
20+
curl -L $ARTIFACT_URL | tar xvz
21+
sudo mv hashnode /usr/local/bin/hashnode
22+
23+
GREEN='\033[0;32m'
24+
NC='\033[0m'
25+
26+
echo -e "${GREEN}Installed Successfully${NC}"
27+

0 commit comments

Comments
 (0)