-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·71 lines (55 loc) · 1.67 KB
/
install.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/sh
set -e
if [ "$(uname)" = "Darwin" ] ; then
OS="darwin"
else
OS="linux"
fi
LOCAL_ARCH=$(uname -m)
case "${LOCAL_ARCH}" in
x86_64|amd64)
ARCH=amd64
;;
armv8*|aarch64*|arm64)
ARCH=arm64
;;
*)
echo "This system's architecture, ${LOCAL_ARCH}, isn't supported"
exit 1
;;
esac
RELEASES_URL="https://github.com/sunggun-yu/gh-app-access-token/releases"
FILE_BASENAME="gh-app-access-token"
test -z "$VERSION" && VERSION="$(curl -sfL -o /dev/null -w %{url_effective} "$RELEASES_URL/latest" |
grep -o 'releases/tag/v[0-9]*.[0-9]*.[0-9]*' |
awk -F '/' '{ print $3}')"
test -z "$VERSION" && {
echo "Unable to get gh-app-access-token version." >&2
exit 1
}
test -z "$INSTALL_PATH" && INSTALL_PATH=/tmp
if ! test -d "$INSTALL_PATH" ; then
echo "Creating INSTALL_PATH directory $INSTALL_PATH..." >&2
mkdir -p $INSTALL_PATH
fi
TEMP_DIR=$(mktemp -d)
TAR_FILE="$TEMP_DIR/${FILE_BASENAME}.tar.gz"
if [ "$(uname -s)" = "Darwin" ] ; then
DOWNLOAD_URL="$RELEASES_URL/download/$VERSION/${FILE_BASENAME}_${OS}_all.tar.gz"
else
DOWNLOAD_URL="$RELEASES_URL/download/$VERSION/${FILE_BASENAME}_${OS}_${ARCH}.tar.gz"
fi
echo "Downloading gh-app-access-token $VERSION..."
curl -sfLo "$TAR_FILE" "$DOWNLOAD_URL"
if ! test -f "$TAR_FILE"; then
echo "Unable to download gh-app-access-token." >&2
exit 1
fi
tar -xzf "$TAR_FILE" -C "$TEMP_DIR" --strip-components=1
if ! test -f "$TEMP_DIR/gh-app-access-token"; then
echo "Unable to extract gh-app-access-token." >&2
exit 1
fi
mv $TEMP_DIR/gh-app-access-token $INSTALL_PATH
rm -r $TEMP_DIR
printf "gh-app-access-token has been successfully downloaded into the %s folder on your system.\n" "$INSTALL_PATH"