-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild-release-binaries.sh
executable file
·119 lines (97 loc) · 2.14 KB
/
build-release-binaries.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
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/usr/bin/env bash
export distsdir=dists/
init() {
if ! (command -v go > /dev/null); then
echo "go command not found."
exit 1
fi
if ! (command -v tar > /dev/null); then
echo "tar command not found."
exit 1
fi
if ! (command -v zip > /dev/null); then
echo "zip command not found."
exit 1
fi
if [ -d $distsdir ]; then
read -p "$distsdir directory exists. Remove to continue? [y/N]: " s
case $s in
y|Y)
rm -rf $distsdir
;;
*)
echo "Cannot crossbuild without existing $distsdir deleted."
exit 1
;;
esac
fi
mkdir $distsdir
cd $distsdir
}
preparedist() {
distdir=bostr2-$1-$2
mkdir $distdir
cp ../config.example.yaml $distdir/
cp ../LICENSE $distdir/
cp ../README.md $distdir/
cat > $distdir/INSTRUCTIONS.txt << EOL
Before running, Rename config.example.yaml to config.yaml,
Then edit the config with text editor before starting bouncer.
After editing, Start the bouncer by running:
$ ./bostr2
Or launch bostr2.exe if you're on windows.
NOTE: If there's firewall, you must configure the firewall to allow
incomming port to the bostr2 port.
EOL
}
maketarballs() {
for distdir in bostr2-*; do
if (echo $distdir | grep -q "windows"); then
echo "--- Making zip ${distdir}.zip"
zip -r ${distdir}.zip $distdir
else
echo "--- Making tarball ${distdir}.tar.gz"
tar -czf ${distdir}.tar.gz $distdir
fi
done
}
removedists() {
echo "--- Cleaning up"
for dist in bostr2-*.tar.gz; do
rm -rf ${dist/.tar.gz}
done
for dist in bostr2-*.zip; do
rm -rf ${dist/.zip}
done
}
compile() {
export GOOS=$1
export GOARCH=$2
distdir="bostr2-$1-$2"
echo "--- Compiling for $GOOS/$GOARCH platform"
WINEX=""
if [ "$GOOS" == "windows" ]; then
WINEX=".exe"
fi
go build -o $distdir/bostr2${WINEX} ../;
if [ "$?" != "0" ]; then
echo "--- Compilation failed for $GOOS/$GOARCH. Destroying distdir..."
rm -rf $distdir
fi
}
close() {
echo "--- Result:"
ls
echo "--- Tarballs & zips is available in $(pwd)"
}
crosscompile() {
go tool dist list | sed 's/\// /g' | while read os arch; do
preparedist $os $arch
compile $os $arch
done
}
init
crosscompile
maketarballs
removedists
close