Skip to content

Commit

Permalink
Merge pull request #86 from k1LoW/tmpinstaller
Browse files Browse the repository at this point in the history
Add a temporary installation script for CI
  • Loading branch information
k1LoW authored Mar 11, 2019
2 parents e412fe8 + b75f216 commit 207a2e9
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions use
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/sh
# Usege:
#
# source <(curl https://raw.githubusercontent.com/k1LoW/tbls/master/use)
#
# Reference:
# https://github.com/goreleaser/get
set -e

GOOS=linux
EXT=tar.gz
ARCH=amd64
if test $(uname -s) = "Darwin"
then
GOOS=darwin
EXT=zip
fi
ARCHIVE="/tmp/tbls.${EXT}"

RELEASES_URL="https://github.com/k1LoW/tbls/releases"
test -z "$TMPDIR" && TMPDIR="$(mktemp -d)"

last_version() {
curl -sL -o /dev/null -w %{url_effective} "$RELEASES_URL/latest" |
rev |
cut -f1 -d'/'|
rev
}

download() {
test -z "$VERSION" && VERSION="$(last_version)"
test -z "$VERSION" && {
echo "Unable to get tbls version." >&2
exit 1
}
rm -f "$ARCHIVE"
curl -s -L -o "$ARCHIVE" \
"${RELEASES_URL}/download/${VERSION}/tbls_${VERSION}_${GOOS}_${ARCH}.${EXT}"
}

download
if test ${EXT} = "tar.gz"
then
tar -xf "$ARCHIVE" -C "$TMPDIR"
elif test ${EXT} = "zip"
then
unzip -foq -d "$TMPDIR" "$ARCHIVE"
fi
export PATH=${TMPDIR}:$PATH

0 comments on commit 207a2e9

Please # to comment.