Skip to content

Commit 90f1f34

Browse files
committed
try to fix release
1 parent 0bb49b8 commit 90f1f34

File tree

3 files changed

+211
-1
lines changed

3 files changed

+211
-1
lines changed

.goreleaser.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
builds:
2+
- main: ./cmd/queryx/main.go
3+
- env:
4+
- CGO_ENABLED=0
5+
- GO111MODULE=on
6+
goos:
7+
- linux
8+
- darwin
9+
- windows
10+
goarch:
11+
- 386
12+
- amd64
13+
- arm
14+
- arm64
15+
archives:
16+
- replacements:
17+
386: i386
18+
checksum:
19+
name_template: "checksums.txt"
20+
snapshot:
21+
name_template: "{{ .Tag }}-next"
22+
changelog:
23+
sort: asc
24+
filters:
25+
exclude:
26+
- "^docs:"
27+
- "^test:"
28+
- Merge pull request
29+
- Merge branch

cmd/queryx/action/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"github.com/spf13/cobra"
77
)
88

9-
var Version = "0.1.1"
9+
var Version = "0.1.2"
1010

1111
var versionCmd = &cobra.Command{
1212
Use: "version",

install.sh

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
# Some utilities from https://github.com/client9/shlib
6+
7+
echoerr() {
8+
printf "$@\n" 1>&2
9+
}
10+
11+
log_info() {
12+
printf "\033[38;5;61m ==>\033[0;00m $@\n"
13+
}
14+
15+
log_crit() {
16+
echoerr
17+
echoerr " \033[38;5;125m$@\033[0;00m"
18+
echoerr
19+
}
20+
21+
is_command() {
22+
command -v "$1" >/dev/null
23+
#type "$1" > /dev/null 2> /dev/null
24+
}
25+
26+
http_download_curl() {
27+
local_file=$1
28+
source_url=$2
29+
header=$3
30+
if [ -z "$header" ]; then
31+
code=$(curl -w '%{http_code}' -sL -o "$local_file" "$source_url")
32+
else
33+
code=$(curl -w '%{http_code}' -sL -H "$header" -o "$local_file" "$source_url")
34+
fi
35+
if [ "$code" != "200" ]; then
36+
log_crit "Error downloading, got $code response from server"
37+
return 1
38+
fi
39+
return 0
40+
}
41+
42+
http_download_wget() {
43+
local_file=$1
44+
source_url=$2
45+
header=$3
46+
if [ -z "$header" ]; then
47+
wget -q -O "$local_file" "$source_url"
48+
else
49+
wget -q --header "$header" -O "$local_file" "$source_url"
50+
fi
51+
}
52+
53+
http_download() {
54+
if is_command curl; then
55+
http_download_curl "$@"
56+
return
57+
elif is_command wget; then
58+
http_download_wget "$@"
59+
return
60+
fi
61+
log_crit "http_download unable to find wget or curl"
62+
return 1
63+
}
64+
65+
http_copy() {
66+
tmp=$(mktemp)
67+
http_download "${tmp}" "$1" "$2" || return 1
68+
body=$(cat "$tmp")
69+
rm -f "${tmp}"
70+
echo "$body"
71+
}
72+
73+
uname_os() {
74+
os=$(uname -s | tr '[:upper:]' '[:lower:]')
75+
76+
# fixed up for https://github.com/client9/shlib/issues/3
77+
case "$os" in
78+
msys_nt*) os="windows" ;;
79+
mingw*) os="windows" ;;
80+
esac
81+
82+
# other fixups here
83+
echo "$os"
84+
}
85+
86+
uname_os_check() {
87+
os=$(uname_os)
88+
case "$os" in
89+
darwin) return 0 ;;
90+
dragonfly) return 0 ;;
91+
freebsd) return 0 ;;
92+
linux) return 0 ;;
93+
android) return 0 ;;
94+
nacl) return 0 ;;
95+
netbsd) return 0 ;;
96+
openbsd) return 0 ;;
97+
plan9) return 0 ;;
98+
solaris) return 0 ;;
99+
windows) return 0 ;;
100+
esac
101+
log_crit "uname_os_check '$(uname -s)' got converted to '$os' which is not a GOOS value. Please file bug at https://github.com/client9/shlib"
102+
return 1
103+
}
104+
105+
uname_arch() {
106+
arch=$(uname -m)
107+
case $arch in
108+
x86_64) arch="amd64" ;;
109+
x86) arch="386" ;;
110+
i686) arch="386" ;;
111+
i386) arch="386" ;;
112+
aarch64) arch="arm64" ;;
113+
armv5*) arch="armv5" ;;
114+
armv6*) arch="armv6" ;;
115+
armv7*) arch="armv7" ;;
116+
esac
117+
echo ${arch}
118+
}
119+
120+
uname_arch_check() {
121+
arch=$(uname_arch)
122+
case "$arch" in
123+
386) return 0 ;;
124+
amd64) return 0 ;;
125+
arm64) return 0 ;;
126+
armv5) return 0 ;;
127+
armv6) return 0 ;;
128+
armv7) return 0 ;;
129+
ppc64) return 0 ;;
130+
ppc64le) return 0 ;;
131+
mips) return 0 ;;
132+
mipsle) return 0 ;;
133+
mips64) return 0 ;;
134+
mips64le) return 0 ;;
135+
s390x) return 0 ;;
136+
amd64p32) return 0 ;;
137+
esac
138+
log_crit "uname_arch_check '$(uname -m)' got converted to '$arch' which is not a GOARCH value. Please file bug report at https://github.com/client9/shlib"
139+
return 1
140+
}
141+
142+
mktmpdir() {
143+
test -z "$TMPDIR" && TMPDIR="$(mktemp -d)"
144+
mkdir -p "${TMPDIR}"
145+
echo "${TMPDIR}"
146+
}
147+
148+
start() {
149+
uname_os_check
150+
uname_arch_check
151+
152+
pkg="github.com/swiftcarrot/queryx"
153+
bin="queryx.tar.gz"
154+
original_version="v0.1.2"
155+
156+
prefix=${PREFIX:-"/usr/local/bin"}
157+
tmp="$(mktmpdir)"
158+
159+
echo
160+
log_info "Downloading $pkg@$original_version"
161+
log_info "Downloading binary for $os $arch"
162+
163+
asset=$(curl -s https://api.github.com/repos/swiftcarrot/queryx/releases/latest | grep -i "browser_download_url.*$os\_$arch" | sed -E 's/.*"([^"]+)".*/\1/')
164+
http_download "$tmp/queryx_$original_version.tar.gz" "$asset"
165+
166+
cd "$tmp"
167+
tar zxf "queryx_$original_version.tar.gz"
168+
169+
if [ -w "$prefix" ]; then
170+
log_info "Installing queryx to $prefix"
171+
install queryx "$prefix"
172+
else
173+
log_info "Permissions required for installation to $prefix — alternatively specify a new directory with:"
174+
sudo install queryx "$prefix"
175+
fi
176+
177+
log_info "Installation complete"
178+
echo
179+
}
180+
181+
start

0 commit comments

Comments
 (0)