-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·49 lines (42 loc) · 893 Bytes
/
build.sh
File metadata and controls
executable file
·49 lines (42 loc) · 893 Bytes
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
#!/bin/bash
declare -a arr=(
"linux/386"
"linux/amd64"
"linux/arm"
"linux/arm64"
"freebsd/386"
"freebsd/amd64"
"freebsd/arm"
"freebsd/arm64"
"darwin/amd64"
)
if [ "$OUT" == "" ]
then
OUT="bin/"
fi
PACKAGE=`go list`
PACKAGE=${PACKAGE##*\-}
echo "Build package: $PACKAGE"
output="\"main\": {"
for i in ${!arr[@]}; do
IFS="/" read -ra osarch <<< "${arr[i]}"
fn="${PACKAGE}_${osarch[0]}_${osarch[1]}"
if [ $i -gt 0 ]
then
output="$output,"
fi
if [ "${osarch[0]}" == "windows" ]
then
fn="$fn.exe"
else
fn="$fn.bin"
fi
CGO_ENABLED=0 GOOS="${osarch[0]}" GOARCH="${osarch[1]}" go build -o "${OUT}$fn"
output="$output\n \"${arr[i]}\": \"${OUT}$fn\""
done
output="$output\n}"
echo "DONE!"
echo
echo "Add the following as \"main\" to your module.json file:"
echo "..."
echo -e "$output"