-
Notifications
You must be signed in to change notification settings - Fork 27
/
build.sh
executable file
·93 lines (61 loc) · 1.81 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/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(){
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 CC=x86_64-linux-musl-gcc CGO_LDFLAGS="-static" go build -a -ldflags "-w -s -X main.BuildVersion=${BuildVersion} -X main.CommitID=${CommitID} -X main.BuildTime=${BuildTime}"
copyFile
cp curl.sh bin/
cp NoticeServices bin/
rm -f NoticeServices
}
function windows(){
CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc go build -ldflags "-w -s -X main.BuildVersion=${BuildVersion} -X main.CommitID=${CommitID} -X main.BuildTime=${BuildTime}"
copyFile
cp NoticeServices.exe bin/
rm -f NoticeServices.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 NoticeServices bin/
rm -f NoticeServices
}
function copyFile() {
echo "主程序编译完成"
rm -rf bin
mkdir bin
cp -r document/. bin/document/
cp -r template/. bin/template/
cp -r public/. bin/public/
cp -r config/. bin/config/
cp -r db/. bin/db/
plugin
}
function plugin() {
cd ./plugins
./build.sh
cd ../
mkdir bin/plugins
mkdir bin/plugins/mail
mkdir bin/plugins/webhook
cp plugins/mail/mail.so bin/plugins/mail
cp plugins/webhook/webhook.so bin/plugins/webhook
cp plugins/mail/config.toml bin/plugins/mail
cp plugins/webhook/config.toml bin/plugins/webhook
rm -f plugins/mail/mail.so
rm -f plugins/webhook/webhook.so
}
if [ "$1" == "" ]; then
help
elif [ "$1" == "linux" ];then
linux
elif [ "$1" == "windows" ];then
windows
elif [ "$1" == "mac" ];then
mac
fi