-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathget.sh
executable file
·50 lines (41 loc) · 1.06 KB
/
get.sh
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
set -e
export OWNER=codeperfio
export REPO=codeperf
TAR_FILE="/tmp/$REPO.tar.gz"
RELEASES_URL="https://github.com/$OWNER/$REPO/releases"
test -z "$TMPDIR" && TMPDIR="$(mktemp -d)"
hasCli() {
hasCurl=$(which curl)
if [ "$?" = "1" ]; then
echo "You need curl to use this script."
exit 1
fi
}
last_version() {
curl -sL -o /dev/null -w %{url_effective} "$RELEASES_URL/latest" |
rev |
cut -f1 -d'/'|
rev
}
download() {
echo "getting latest release from $RELEASES_URL/latest..."
echo "detected latest version=$(last_version)"
test -z "$VERSION" && VERSION="$(last_version)"
test -z "$VERSION" && {
echo "Unable to get codeperf version." >&2
exit 1
}
rm -f "$TAR_FILE"
RELEASE_ARTIFACT="$RELEASES_URL/download/$VERSION/${REPO}_$(uname -s)_$(uname -m).tar.gz"
echo "getting $RELEASE_ARTIFACT into $TAR_FILE"
curl -s -L -o "$TAR_FILE" \
$RELEASE_ARTIFACT
}
hasCli
download
tar -xf "$TAR_FILE" -C "$TMPDIR"
rm $TAR_FILE
mv $TMPDIR/$REPO .
echo "Checking we can call the codeperf tool"
./codeperf --help