Skip to content

Commit

Permalink
ci: update install binary name pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
jahvon committed Sep 29, 2024
1 parent 58467f1 commit 0526931
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,39 +21,40 @@ get_arch() {
}

get_latest_version() {
curl -s "https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/releases/latest" | grep -o '"tag_name": ".*"' | sed 's/"tag_name": "//;s/"//'
curl -s "https://api.github.com/repos/$OWNER/$NAME/releases/latest" | grep -o '"tag_name": ".*"' | sed 's/"tag_name": "//;s/"//'
}

REPO_OWNER="jahvon"
REPO_NAME="flow"
CLI_BINARY="flow"
OWNER="jahvon"
NAME="flow"
BINARY="flow"

OS=$(get_os)
ARCH=$(get_arch)
if [ -z "$VERSION" ]; then
VERSION=$(get_latest_version)
fi

DOWNLOAD_URL="https://github.com/$REPO_OWNER/$REPO_NAME/releases/download/$VERSION/$CLI_BINARY-$VERSION-$OS-$ARCH.tar.gz"
DOWNLOAD_URL="https://github.com/${OWNER}/${NAME}/releases/download/${VERSION}/${BINARY}_${VERSION}_${OS}_${ARCH}.tar.gz"
TMP_DIR=$(mktemp -d)
DOWNLOAD_PATH="${TMP_DIR}/${BINARY}_${VERSION}_${OS}_${ARCH}.tar.gz"

echo "Downloading $CLI_BINARY $VERSION for $OS/$ARCH..."
wget -q "$DOWNLOAD_URL" -O "$TMP_DIR/$CLI_BINARY-$VERSION-$OS-$ARCH.tar.gz"
echo "Downloading $BINARY $VERSION for $OS/$ARCH..."
wget "$DOWNLOAD_URL" -O "$DOWNLOAD_PATH"
if [ $? -ne 0 ]; then
echo "Failed to download $DOWNLOAD_URL"
exit 1
fi

INSTALL_DIR="/usr/local/bin"
echo "Installing $CLI_BINARY $VERSION to $INSTALL_DIR..."
tar -xzf "$TMP_DIR/$CLI_BINARY-$VERSION-$OS-$ARCH.tar.gz" -C "$TMP_DIR"
echo "Installing $BINARY $VERSION to $INSTALL_DIR..."
tar -xzf "$DOWNLOAD_PATH" -C "$TMP_DIR"

chmod +x "$TMP_DIR/$CLI_BINARY"
sudo mv "$TMP_DIR/$CLI_BINARY" "$INSTALL_DIR/$CLI_BINARY"
chmod +x "$TMP_DIR/$BINARY"
sudo mv "$TMP_DIR/$BINARY" "$INSTALL_DIR/$BINARY"

echo "$CLI_BINARY was installed successfully to $INSTALL_DIR/$CLI_BINARY"
if command -v $CLI_BINARY --version >/dev/null; then
echo "Run '$CLI_BINARY --help' to get started"
echo "$BINARY was installed successfully to $INSTALL_DIR/$BINARY"
if command -v $BINARY --version >/dev/null; then
echo "Run '$BINARY --help' to get started"
else
echo "Manually add the directory to your \$HOME/.bash_profile (or similar)"
echo " export PATH=$INSTALL_DIR:\$PATH"
Expand Down

0 comments on commit 0526931

Please sign in to comment.