-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
58 lines (52 loc) · 1.56 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
# OSとアーキテクチャを取得
get_os_arch() {
local os=$(uname -s | tr '[:upper:]' '[:lower:]')
local arch=$(uname -m)
# OSの名前を標準化
case "$os" in
linux) os="linux" ;;
darwin) os="macos" ;;
msys*|mingw*) os="windows" ;;
esac
# アーキテクチャを標準化
case "$arch" in
x86_64) arch="x64" ;;
aarch64|arm64) arch="arm64" ;;
armv7*) arch="arm" ;;
esac
echo "${os}-${arch}"
}
os_arch=$(get_os_arch)
echo Your OS and Archtechture: $os_arch
# 最新のバージョンのzipをダウンロードするURLを取得
latest_url=$(curl -s https://api.github.com/repos/u1and0/gpt-cli/releases/latest \
| grep "browser_download_url.*gpt-cli-${os_arch}.zip" \
| cut -d '"' -f 4)
echo Download gpt-cli zip file from $latest_url...
# Validate and set variables
if [ -z "$latest_url" ] || [ -z "$os_arch" ]; then
echo "Error: Required variables not set."
exit 1
fi
# Consolidated installation steps with error checking
install_gpt() {
# Download with progress and error handling
curl -L -o "gpt-cli-${os_arch}.zip" "$latest_url" || {
echo "Download failed."
return 1
}
# Unzip with error checking
unzip -q "gpt-cli-${os_arch}.zip" || {
echo "Extraction failed."
return 1
}
# Remove zip file if successful
rm "gpt-cli-${os_arch}.zip"
}
# Execute installation and handle status
if install_gpt; then
echo "GPT command installation completed successfully."
else
echo "GPT command installation failed."
exit 1
fi