-
Notifications
You must be signed in to change notification settings - Fork 2
/
install.sh
executable file
·67 lines (59 loc) · 2.04 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
#!/bin/bash
if $(git config --get remote.origin.url | grep -q 'github.com[:/]aspl-lang/aspl'); then
git pull origin main
else
git clone https://github.com/aspl-lang/aspl.git
cd aspl
fi
if [ -n "$GITHUB_TOKEN" ]; then
AUTH_HEADER="Authorization: token $GITHUB_TOKEN"
else
AUTH_HEADER=""
fi
SHA=$(curl -s -H "$AUTH_HEADER" https://api.github.com/repos/aspl-lang/cd/contents/latest.txt | jq -r '.content' | base64 -d)
if [ "$(uname)" = "Darwin" ]; then
if [ "$(uname -m)" = "x86_64" ]; then
EXECUTABLE=aspl_macos_x86_64
elif [ "$(uname -m)" = "armv7l" ]; then
EXECUTABLE=aspl_macos_arm32
elif [ "$(uname -m)" = "aarch64" ]; then
EXECUTABLE=aspl_macos_arm64
else
echo "Unsupported architecture"
exit 1
fi
elif [ "$(uname)" = "Linux" ]; then
if [ "$(uname -m)" = "x86_64" ]; then
EXECUTABLE=aspl_linux_x86_64
elif [ "$(uname -m)" = "armv7l" ]; then
EXECUTABLE=aspl_linux_arm32
elif [ "$(uname -m)" = "aarch64" ]; then
EXECUTABLE=aspl_linux_arm64
else
echo "Unsupported architecture"
exit 1
fi
else
echo "Unsupported operating system"
exit 1
fi
CURL="curl -s -H '$AUTH_HEADER' https://api.github.com/repos/aspl-lang/cd/releases"
ASSET_ID=$(eval "$CURL/tags/SHA-$SHA" | jq .assets | jq '.[] | select(.name == "'$EXECUTABLE'").id')
echo "Downloading $EXECUTABLE ($ASSET_ID):"
eval "$CURL/assets/$ASSET_ID -LJOH 'Accept: application/octet-stream' --progress-bar"
mv $EXECUTABLE aspl
chmod +x aspl
read -r -n 1 -p "Make the \`aspl\` command available everywhere (by creating a symlink in /usr/local/bin)? (y/n): " choice
printf "\n"
case "$choice" in
'' | y | Y)
echo "Creating link"
sudo ln -fs $PWD/aspl /usr/local/bin/aspl
;;
*) echo "Skiping..." ;;
esac
ASSET_ID=$(eval "$CURL/tags/SHA-$SHA" | jq .assets | jq '.[] | select(.name == "templates.zip").id')
echo "Downloading templates.zip ($ASSET_ID):"
eval "$CURL/assets/$ASSET_ID -LJOH 'Accept: application/octet-stream' --progress-bar"
unzip -o templates.zip
rm templates.zip