-
Notifications
You must be signed in to change notification settings - Fork 11
/
build.sh
executable file
·58 lines (43 loc) · 1.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
51
52
53
54
55
56
57
58
#!/bin/sh
BuildVersion=`git describe --abbrev=0 --tags`
BuildTime=`date +%FT%T%z`
CommitID=`git rev-parse HEAD`
function help() {
echo "$0 linux|windows|mac"
}
function linux(){
GOOS=linux GOARCH=amd64 go build -a -ldflags "-w -s -X main.BuildVersion=${BuildVersion} -X main.CommitID=${CommitID} -X main.BuildTime=${BuildTime}"
copyFile
cp curl.sh bin/
cp NovelServer bin/
rm -f NovelServer
}
function windows(){
GOOS=windows GOARCH=amd64 go build -ldflags "-w -s -X main.BuildVersion=${BuildVersion} -X main.CommitID=${CommitID} -X main.BuildTime=${BuildTime}"
copyFile
cp NovelServer.exe bin/
rm -f NovelServer.exe
}
function mac(){
go build -ldflags "-w -s -X main.BuildVersion=${BuildVersion} -X main.CommitID=${CommitID} -X main.BuildTime=${BuildTime}"
copyFile
cp curl.sh bin/
cp NovelServer bin/
rm -f NovelServer
}
function copyFile() {
rm -rf bin
mkdir bin
cp -r document/. bin/document/
cp -r public/. bin/public/
cp -r config/. bin/config/
}
if [ "$1" == "" ]; then
help
elif [ "$1" == "linux" ];then
linux
elif [ "$1" == "windows" ];then
windows
elif [ "$1" == "mac" ];then
mac
fi