Skip to content

Commit

Permalink
fix: push install script
Browse files Browse the repository at this point in the history
  • Loading branch information
dtomasi committed Aug 17, 2021
1 parent 61e9a2e commit bf468d3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -171,5 +171,4 @@ fabric.properties
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

dist/
install
dist/
26 changes: 26 additions & 0 deletions install
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

ORG_NAME=${1:-"dtomasi"}
REPO_NAME=${2:-"git-ext"}
ARCHIVE_NAME_PREFIX=${2:-"${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 -sL "${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 /usr/local/bin"
sudo cp -a "/tmp/${REPO_NAME}/." "/usr/local/bin/"
rm -rf "/tmp/${REPO_NAME}" "/tmp/${ARCHIVE_NAME}"

0 comments on commit bf468d3

Please sign in to comment.