-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-rel
executable file
·37 lines (30 loc) · 1.5 KB
/
build-rel
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
#!/usr/local/bin/zsh
GIT_SHA=$(git rev-parse --short HEAD)
B=./bin
D=./dist
R=${1}
[[ -z ${R} ]] && R=${GIT_SHA}
bindir=${B}/${R}
dists=${D}/${R}
binary=${bindir}/mbdns-${R}
[[ -d ${bindir} ]] && rm -rf ${bindir} && mkdir -p ${bindir}
[[ -d ${dists} ]] && rm -rf ${dists} && mkdir -p ${dists}
LDFLAGS="-X main.BuildVersion=${R} -X main.BuildDate=`date -u '+%Y%m%d'` -X main.GitRev=${GIT_SHA} -X main.BuildUser=${USER}"
GOOS=linux GOARCH=arm GOARM=6 go build -ldflags ${LDFLAGS} -o ${binary}-linux-armv6 mbdns.go
GOOS=linux GOARCH=arm GOARM=7 go build -ldflags ${LDFLAGS} -o ${binary}-linux-armv7 mbdns.go
GOOS=linux GOARCH=mipsle go build -ldflags ${LDFLAGS} -o ${binary}-linux-mipsle mbdns.go
GOOS=darwin GOARCH=amd64 go build -ldflags ${LDFLAGS} -o ${binary}-darwin-amd64 mbdns.go
GOOS=freebsd GOARCH=amd64 go build -ldflags ${LDFLAGS} -o ${binary}-freebsd-amd64 mbdns.go
GOOS=linux GOARCH=amd64 go build -ldflags ${LDFLAGS} -o ${binary}-linux-amd64 mbdns.go
GOOS=linux GOARCH=arm64 go build -ldflags ${LDFLAGS} -o ${binary}-linux-arm64 mbdns.go
for i (linux-armv6 linux-armv7 linux-mipsle darwin-amd64 freebsd-amd64 linux-amd64 linux-arm64) do
rel=mbdns-${R}-${i}
out=${dists}/${rel}
mkdir -p ${out}
cp ./doc/mbdns.conf.sample ${out}
cp ./README.md ${out}
cp ./LICENSE ${out}
cp ${binary}-${i} ${out}
tar czf ${out}.tar.gz -C ${dists} ${rel}
rm -rf ${out}
done