-
Notifications
You must be signed in to change notification settings - Fork 26
/
build.sh
executable file
·40 lines (31 loc) · 892 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
#! /bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR
if ! command -v git &> /dev/null
then
DEV_VER="development"
else
DEV_VER="dev-$(git rev-parse --short HEAD)"
fi
VERSION=${VERSION:=$DEV_VER}
build() {
EXT=""
[[ $GOOS = "windows" ]] && EXT=".exe"
echo "Building ${GOOS} ${GOARCH}"
CGO_ENABLED=0 go build \
-trimpath \
-ldflags="-s -w -X 'github.com/ferama/rospo/cmd.Version=$VERSION'" \
-o ./bin/rospo-${GOOS}-${GOARCH}${EXT} .
}
### test units
go clean -testcache
go test ./... -v -cover -race || exit 1
### multi arch binary build
GOOS=linux GOARCH=arm build
GOOS=linux GOARCH=arm64 build
GOOS=linux GOARCH=amd64 build
GOOS=linux GOARCH=mips GOMIPS=softfloat build
GOOS=linux GOARCH=mipsle GOMIPS=softfloat build
GOOS=darwin GOARCH=arm64 build
GOOS=darwin GOARCH=amd64 build
GOOS=windows GOARCH=amd64 build