-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgh-do
executable file
·48 lines (40 loc) · 1.15 KB
/
gh-do
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
#!/bin/bash
set -e
repo="github.com/k1LoW/gh-do"
tag="$(gh release list -R "$repo" --limit 1 | cut -f 1)"
extensionPath="$(dirname "$0")"
arch="$(uname -m)"
exe=""
if uname -a | grep Msys > /dev/null; then
if [ $arch = "x86_64" ]; then
exe="gh-do_${tag}_windows_amd64.exe"
fi
elif uname -a | grep Darwin > /dev/null; then
if [ $arch = "x86_64" ]; then
exe="gh-do_${tag}_darwin_amd64"
elif [ $arch = "arm64" ]; then
exe="gh-do_${tag}_darwin_arm64"
fi
elif uname -a | grep Linux > /dev/null; then
if [ $arch = "x86_64" ]; then
exe="gh-do_${tag}_linux_amd64"
fi
fi
if [ "${exe}" == "" ]; then
if [ "$(which go)" = "" ]; then
echo "go must be installed to use this gh extension on this platform"
exit 1
fi
exe="cmd.out"
cd "${extensionPath}" > /dev/null
go build -o "${exe}" cmd/gh-do/main.go
cd - > /dev/null
else
if [[ ! -x "${extensionPath}/bin/${exe}" ]]; then
mkdir -p "${extensionPath}/bin"
rm -f ${extensionPath}/bin/gh-do*
gh release -R "${repo}" download "${tag}" -p "${exe}" --dir="${extensionPath}/bin"
chmod +x "${extensionPath}/bin/${exe}"
fi
fi
exec "${extensionPath}/bin/${exe}" "$@"