44set -e
55
66REPO=' MichaelCurrin/auto-commit-msg'
7+ REPO_URL=" https://github.com/$REPO /releases/latest/download"
8+
79BINARIES=(" acm" " gacm" " auto_commit_msg_generate" )
810INSTALL_DIR=" $HOME /.local/bin"
911
@@ -13,39 +15,32 @@ if [[ "$OS_NAME" == "darwin" ]]; then
1315elif [[ " $OS_NAME " == " linux" ]]; then
1416 OS=" linux"
1517else
16- echo " Error: Unsupported OS ( $OS_NAME ) "
18+ echo " Error: Unsupported OS ' $OS_NAME ' "
1719 exit 1
1820fi
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-
2722TEMP_DIR=$( mktemp -d)
2823trap ' rm -rf "$TEMP_DIR"' EXIT
29- mkdir -p " $INSTALL_DIR "
24+
25+ echo " Install directory: '$INSTALL_DIR '."
3026
3127for 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 "
4942done
5043
51- echo " Successfully installed '${BINARIES[*]} ' to '$INSTALL_DIR '"
44+ install -d " ${TEMP_DIR} /*" " $INSTALL_DIR "
45+
46+ echo ' Successfully installed.'
0 commit comments