-
Notifications
You must be signed in to change notification settings - Fork 1
/
install
executable file
·27 lines (22 loc) · 1001 Bytes
/
install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env bash
INSTALL_PATH=${1:-"/usr/local/bin"}
ORG_NAME="dtomasi"
REPO_NAME="git-ext"
ARCHIVE_NAME_PREFIX=$REPO_NAME
function getLatestVersion() {
curl --silent "https://api.github.com/repos/${ORG_NAME}/${REPO_NAME}/releases/latest" |
grep '"tag_name":' |
sed -E 's/.*"([^"]+)".*/\1/'
}
LATEST_VERSION=$(getLatestVersion)
ARCHIVE_VERSION=$(echo -n "${LATEST_VERSION}" | sed 's/v//')
ARCHIVE_NAME="${ARCHIVE_NAME_PREFIX}_${ARCHIVE_VERSION}_$(uname -s)_$(uname -m).tar.gz"
echo "detected latest extension version is ${LATEST_VERSION}"
echo "downloading extensions"
DOWNLOAD_URL="https://github.com/${ORG_NAME}/${REPO_NAME}/releases/download/${LATEST_VERSION}/${ARCHIVE_NAME}"
curl -L "${DOWNLOAD_URL}" > "/tmp/${ARCHIVE_NAME}"
mkdir -p "/tmp/${REPO_NAME}"
(cd "/tmp/${REPO_NAME}" || exit; tar -xjf "/tmp/${ARCHIVE_NAME}" 'git-*')
echo "installing extension to ${INSTALL_PATH}"
sudo cp -a "/tmp/${REPO_NAME}/." "${INSTALL_PATH}/"
rm -rf "/tmp/${REPO_NAME}" "/tmp/${ARCHIVE_NAME}"