Skip to content

Commit 88fb6e6

Browse files
committed
feat: update install_cli.sh
1 parent a7941d1 commit 88fb6e6

1 file changed

Lines changed: 11 additions & 16 deletions

File tree

bin/install_cli.sh

100644100755
Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
set -e
55

66
REPO='MichaelCurrin/auto-commit-msg'
7+
REPO_URL="https://github.com/$REPO/releases/latest/download"
8+
79
BINARIES=("acm" "gacm" "auto_commit_msg_generate")
810
INSTALL_DIR="$HOME/.local/bin"
911

@@ -13,39 +15,32 @@ if [[ "$OS_NAME" == "darwin" ]]; then
1315
elif [[ "$OS_NAME" == "linux" ]]; then
1416
OS="linux"
1517
else
16-
echo "Error: Unsupported OS ($OS_NAME)"
18+
echo "Error: Unsupported OS '$OS_NAME'"
1719
exit 1
1820
fi
1921

20-
TAG=$(
21-
curl -s https://api.github.com/repos/$REPO/releases |
22-
grep '"tag_name":' | head -n 1 | cut -d '"' -f 4
23-
)
24-
echo "Found latest tag: '$TAG'."
25-
REPO_URL="https://github.com/$REPO/releases/download/$TAG"
26-
2722
TEMP_DIR=$(mktemp -d)
2823
trap 'rm -rf "$TEMP_DIR"' EXIT
29-
mkdir -p "$INSTALL_DIR"
24+
25+
echo "Install directory: '$INSTALL_DIR'."
3026

3127
for BIN in "${BINARIES[@]}"; do
3228
FILENAME="${BIN}-${OS}"
33-
DEST_PATH="${INSTALL_DIR}/${BIN}"
3429

35-
echo "Installing $BIN for $OS."
3630
DOWNLOAD_URL="${REPO_URL}/${FILENAME}"
3731

32+
echo "Downloading '$FILENAME' as '$BIN'."
3833
if ! HTTP_STATUS=$(curl -LsS -o "${TEMP_DIR}/${BIN}" -w "%{http_code}" "$DOWNLOAD_URL"); then
3934
echo "Error: Failed to download '$BIN' from '$DOWNLOAD_URL'"
4035
exit 1
4136
fi
4237

43-
if [[ ! "$HTTP_STATUS" =~ ^2 ]]; then
44-
echo "Error: Download failed for '$BIN' from '$DOWNLOAD_URL' (HTTP $HTTP_STATUS)"
38+
if [[ "$HTTP_STATUS" != 200 ]]; then
39+
echo "Error: HTTP $HTTP_STATUS for '$DOWNLOAD_URL'"
4540
exit 1
4641
fi
47-
48-
install "${TEMP_DIR}/${BIN}" "$DEST_PATH"
4942
done
5043

51-
echo "Successfully installed '${BINARIES[*]}' to '$INSTALL_DIR'"
44+
install -d "${TEMP_DIR}/*" "$INSTALL_DIR"
45+
46+
echo 'Successfully installed.'

0 commit comments

Comments
 (0)