Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add a temporary installation script for CI #86

Merged
merged 1 commit into from
Mar 11, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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