-
Notifications
You must be signed in to change notification settings - Fork 0
/
installer.sh
93 lines (85 loc) · 2.55 KB
/
installer.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash
USERNAME="promptify-it"
REPO="cli"
REPO_URL="https://github.com/promptify-it/cli"
# Get the latest release tag name
latest_release=$(curl -s "https://api.github.com/repos/$USERNAME/$REPO/releases/latest")
# Function to detect the user's platform
detect_platform() {
case "$(uname -s)" in
Linux*)
if [ "$(uname -m)" = "x86_64" ]; then
PLATFORM="linux_x86_64"
elif [ "$(uname -m)" = "aarch64" ]; then
PLATFORM="linux_aarch64"
else
echo "Unsupported Linux architecture"
exit 1
fi
;;
Darwin*)
if [ "$(uname -m)" = "x86_64" ]; then
PLATFORM="macos_intel"
elif [ "$(uname -m)" = "arm64" ]; then
PLATFORM="macos_apple"
else
echo "Unsupported macOS architecture"
exit 1
fi
;;
CYGWIN*|MINGW32*|MSYS*|MINGW*)
PLATFORM="windows_x64"
;;
*)
echo "Unsupported platform"
exit 1
;;
esac
echo "$PLATFORM"
}
# Function to download the appropriate build based on platform
download_build() {
PLATFORM=$1
DOWNLOAD_URL=$(curl -s "https://api.github.com/repos/$USERNAME/$REPO/releases/latest" | jq -r --arg PLATFORM "$PLATFORM" '.assets[] | select(.name | contains($PLATFORM)) | .browser_download_url')
FILE_NAME=pfy_${PLATFORM}
case "$PLATFORM" in
linux_x86_64)
curl -LOs $DOWNLOAD_URL
chmod +x ${FILE_NAME}
mv ${FILE_NAME} pfy
sudo mv pfy /usr/local/bin/
;;
linux_aarch64)
curl -LOs $DOWNLOAD_URL
chmod +x ${FILE_NAME}
mv ${FILE_NAME} pfy
sudo mv pfy /usr/local/bin/
;;
macos_intel)
curl -LOs $DOWNLOAD_URL
chmod +x ${FILE_NAME}
mv ${FILE_NAME} pfy
sudo mv pfy /usr/local/bin/
;;
macos_apple)
curl -LOs $DOWNLOAD_URL
chmod +x ${FILE_NAME}
mv ${FILE_NAME} pfy
sudo mv pfy /usr/local/bin/
;;
windows_x64)
# Download Windows x64 build
curl -LOs $DOWNLOAD_URL
echo "For Windows, please move the pfy.exe file to a directory in your PATH manually."
;;
*)
echo "Unsupported platform"
exit 1
;;
esac
}
main() {
PLATFORM=$(detect_platform)
download_build "$PLATFORM"
}
main