-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtravis-build-better-dns.sh
106 lines (83 loc) · 2.09 KB
/
travis-build-better-dns.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
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/env bash
OSES="darwin linux windows"
# In future maybe: dragonfly freebsd netbsd openbsd solaris
declare -A ARCHITECTURES
ARCHITECTURES["darwin"]="amd64"
ARCHITECTURES["linux"]="amd64 386 arm arm64"
ARCHITECTURES["windows"]="amd64 386"
# ----- END CONFIGURATION ----- #
function capitalize() {
local text="$1"
echo -n "${text:0:1}" | tr a-z A-Z; echo -n ${text:1:999}
}
function big_label() {
local len
local zero
local fill
local text=$(capitalize "$1")
len=$(echo -n "$text" | wc -c)
zero=$(printf %${len}s)
fill=$(echo -n "$zero" | tr " " "-")
echo
echo
echo
echo "/----$fill----\\"
echo "| $zero |"
echo "| $text |"
echo "| $zero |"
echo "\\----$fill----/"
echo
}
function label() {
local len
local zero
local fill
local text="$1"
len=$(echo -n "$text" | wc -c)
zero=$(printf %${len}s)
fill=$(echo -n "$zero" | tr " " "-")
echo
echo "/-$fill-\\"
echo "| $text |"
echo "\\-$fill-/"
echo
}
# Poor man's set -x (less spammy)
function cmd() {
local cmd="$@"
echo "$cmd"
eval "$cmd"
}
# ----- END FUNCTIONS ----- #
set -e
GO111MODULE=on
CGO_ENABLED=0
GOFLAGS=-mod=vendor
ARTIFACTS="$PWD/artifacts"
mkdir -p "$ARTIFACTS"
for os in $OSES; do
big_label "$os Better DNS"
first=1
for arch in ${ARCHITECTURES[${os}]}; do
export GOOS="$os"
export GOARCH="$arch"
if [[ "$first" == "1" ]]; then
cmd go vet ./client ./server ./shared ./cmd/better-dns
cmd staticcheck ./client ./server ./shared ./cmd/better-dns
cmd errcheck ./client ./server ./shared ./cmd/better-dns
cmd golangci-lint run ./client ./server ./shared ./cmd/better-dns
first=0
fi
cd cmd/better-dns
target="better-dns-$os-$arch"
if [[ "$os" == "windows" ]] && [[ ! -f "better-dns_windows.syso" ]]; then
target="$target.exe"
cmd rsrc -manifest better-dns.exe.manifest -o better-dns_windows.syso
fi
label "Building $target for $os $arch"
cmd go build -o "$target" better-dns.go
cmd mv "$target" "$ARTIFACTS"
cd -
done
done
cp cmd/better-dns/*.manifest "$ARTIFACTS"