-
Notifications
You must be signed in to change notification settings - Fork 134
/
build.sh
executable file
·50 lines (39 loc) · 2.17 KB
/
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
45
46
47
48
49
50
#!/bin/bash
GIT_COMMIT=$(git rev-parse --short HEAD)
TAG=$(git describe --exact-match --abbrev=0 --tags ${COMMIT} 2> /dev/null || true)
DATE=$(date +'%Y-%m-%d')
echo "Building binaries"
echo Git commit: $GIT_COMMIT Version: $TAG Build date: $DATE
go generate
# MAC
export GOARCH="amd64"
export GOOS="darwin"
export CGO_ENABLED=0
go build -ldflags "-X github.com/thedevsaddam/docgen/cmd.GitCommit=$GIT_COMMIT -X github.com/thedevsaddam/docgen/cmd.Version=$TAG -X github.com/thedevsaddam/docgen/cmd.BuildDate=$DATE" -o bin/darwin_amd64 -v .
export GOARCH="arm64"
export GOOS="darwin"
export CGO_ENABLED=0
go build -ldflags "-X github.com/thedevsaddam/docgen/cmd.GitCommit=$GIT_COMMIT -X github.com/thedevsaddam/docgen/cmd.Version=$TAG -X github.com/thedevsaddam/docgen/cmd.BuildDate=$DATE" -o bin/darwin_arm64 -v .
#LINUX
export GOARCH="amd64"
export GOOS="linux"
export CGO_ENABLED=0
go build -ldflags "-X github.com/thedevsaddam/docgen/cmd.GitCommit=$GIT_COMMIT -X github.com/thedevsaddam/docgen/cmd.Version=$TAG -X github.com/thedevsaddam/docgen/cmd.BuildDate=$DATE" -o bin/linux_amd64 -v
export GOARCH="arm64"
export GOOS="linux"
export CGO_ENABLED=0
go build -ldflags "-X github.com/thedevsaddam/docgen/cmd.GitCommit=$GIT_COMMIT -X github.com/thedevsaddam/docgen/cmd.Version=$TAG -X github.com/thedevsaddam/docgen/cmd.BuildDate=$DATE" -o bin/linux_arm64 -v
export GOARCH="386"
export GOOS="linux"
export CGO_ENABLED=0
go build -ldflags "-X github.com/thedevsaddam/docgen/cmd.GitCommit=$GIT_COMMIT -X github.com/thedevsaddam/docgen/cmd.Version=$TAG -X github.com/thedevsaddam/docgen/cmd.BuildDate=$DATE" -o bin/linux_386 -v
#WINDOWS
export GOARCH="386"
export GOOS="windows"
export CGO_ENABLED=0
go build -ldflags "-X github.com/thedevsaddam/docgen/cmd.GitCommit=$GIT_COMMIT -X github.com/thedevsaddam/docgen/cmd.Version=$TAG -X github.com/thedevsaddam/docgen/cmd.BuildDate=$DATE" -o bin/windows_386.exe -v
export GOARCH="amd64"
export GOOS="windows"
export CGO_ENABLED=0
go build -ldflags "-X github.com/thedevsaddam/docgen/cmd.GitCommit=$GIT_COMMIT -X github.com/thedevsaddam/docgen/cmd.Version=$TAG -X github.com/thedevsaddam/docgen/cmd.BuildDate=$DATE" -o bin/windows_amd64.exe -v
echo "Build complete"