-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.sh
executable file
·44 lines (34 loc) · 1013 Bytes
/
build.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
#!/bin/bash
PLATFORMS=""
PLATFORMS_ARM="linux"
type setopt >/dev/null 2>&1
SCRIPT_NAME=`basename "$0"`
FAILURES=""
SOURCE_FILE="dist/numParser"
CURRENT_DIRECTORY=${PWD##*/}
OUTPUT=${SOURCE_FILE:-$CURRENT_DIRECTORY} # if no src file given, use current dir name
LDFLAGS="-s -w"
#Clean
go clean -i -r -cache
GOARCH="arm64"
GOOS="darwin"
BIN_FILENAME="${OUTPUT}-${GOOS}-${GOARCH}${GOARM}"
CMD="GOOS=${GOOS} GOARCH=${GOARCH} go build -ldflags='${LDFLAGS}' -o ${OUTPUT}_${GOOS}_${GOARCH} ./cmd"
echo "${CMD}"
eval "${CMD}" || FAILURES="${FAILURES} ${GOOS}/${GOARCH}${GOARM}"
GOARCH="amd64"
GOOS="linux"
BIN_FILENAME="${OUTPUT}-${GOOS}-${GOARCH}${GOARM}"
CMD="GOOS=${GOOS} GOARCH=${GOARCH} go build -ldflags='${LDFLAGS}' -o ${OUTPUT}_${GOOS}_${GOARCH} ./cmd"
echo "${CMD}"
eval "${CMD}" || FAILURES="${FAILURES} ${GOOS}/${GOARCH}${GOARM}"
# eval errors
if [[ "${FAILURES}" != "" ]]; then
echo ""
echo "${SCRIPT_NAME} failed on: ${FAILURES}"
exit 1
fi
rm -rf tmp
mkdir tmp
cp dist/* tmp/
cp -r public tmp/