-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.sh
executable file
·36 lines (36 loc) · 975 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
#!/bin/sh
# always run from local dir
cd `dirname $0`
CGO_ENABLED="0"
export CGO_ENABLED
unset GOPATH # we are using go modules!
case "$1" in
"build.linux")
go build -a -ldflags "--s -extldflags '-static' -X main.Version=git:$CI_BUILD_REF" -o "printer-scanner$SUFFIX" ./...
;;
"build.mac")
GOOS="darwin"
GOARCH="amd64"
SUFFIX=".$GOOS-$GOARCH"
export GOOS GOARCH SUFFIX
$0 build.linux
;;
"build.win")
GOOS="windows"
GOARCH="amd64"
SUFFIX=".$GOOS-$GOARCH.exe"
export GOOS GOARCH SUFFIX
$0 build.linux
;;
"build")
$0 build.linux
$0 build.mac
$0 build.win
;;
"shell")
shift
docker run -it --rm --name printer-scanner-builder -v `pwd`:/go golang:1.14 /bin/bash
;;
*)
docker run -it --rm --name printer-scanner-builder -v `pwd`:/go golang:1.14 /bin/sh -c "/go/build.sh build"
esac