-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·99 lines (86 loc) · 1.69 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
94
95
96
97
98
99
#!/bin/bash
WEB_ONLY=
RUN=
DEBUG="${DEBUG}"
DEV="${DEV}"
NPM_DIR=vue-project
function build_web(){
_old_pwd="${PWD}"
cd "$NPM_DIR"
if [[ "$DEBUG" == true ]]; then
NODE_ENV=development npm run build_dev || return $?
else
npm run build || return $?
fi
cd "${_old_pwd}"
return $?
}
function build_watch(){
_old_pwd="${PWD}"
cd "$NPM_DIR"
NODE_ENV=development exec npm run build_watch || return $?
cd "${_old_pwd}"
return $?
}
function build_app(){
rm -rf "./handlers/web/dist"
cp -a "${NPM_DIR}/dist" "./handlers/web/dist"
CGO_ENABLED=0 go build -o ./output/plugin_web_point ./handlers/web
return $?
}
function build_handle(){
_handle=$1
echo "==> Building handle ${_handle}"
CGO_ENABLED=0 go build -o "./output/pwp_${_handle}" "./handlers/${_handle}"
return $?
}
function run_app(){
go run ./cmds/dev "$@"
return $?
}
while [ -n "$1" ]; do
case $1 in
-w | --web-only)
WEB_ONLY=true
;;
-r | --run)
RUN=true
;;
-d | --debug)
DEBUG=true
;;
-D | --dev)
DEV=true
;;
esac
shift
done
export DEBUG
cd $(dirname $0)
if [[ "$DEV" == true ]]; then
build_watch &
pid=$!
go run ./cmds/dev/
_e=$?
kill -s SIGINT "$pid"
exit $_e
fi
build_web || exit $?
if [[ "$WEB_ONLY" != true ]]; then
if [[ "$RUN" == true ]]; then
if [[ "$DEBUG" == true ]]; then
run_app -debug
else
run_app
fi
exit $?
fi
echo '==> Building app'
cp ./robots.txt ./output/robots.txt
GOARCH=amd64 GOOS=linux build_app || exit $?
echo '==> Building ghupdater'
GOARCH=amd64 GOOS=linux CGO_ENABLED=0 go build -o ./output/ghupdater ./cmds/ghupdater || exit $?
GOARCH=amd64 GOOS=linux build_handle dev || exit $?
GOARCH=amd64 GOOS=linux build_handle v1 || exit $?
echo '==> Done'
fi