-
Notifications
You must be signed in to change notification settings - Fork 38
/
build.vsh
executable file
·45 lines (38 loc) · 1.04 KB
/
build.vsh
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
import term
import time
start := time.now()
term.clear()
publish_dir := "publish"
if is_dir("${publish_dir}") {
rmdir_all("${publish_dir}")!
}
mkdir("${publish_dir}")!
mut exe := "pinecms"
println(term.bold(term.ok_message("开始构建执行文件")))
system('CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o ${exe}')
if !is_file(exe) {
panic(exe + "不存在")
}
system("upx -9 ${exe}")
cp(exe, "${publish_dir}/${exe}")!
rm(exe)!
println(term.bold(term.ok_message("构建执行完成")))
println(term.bold(term.ok_message("开始打包前端页面")))
$if windows {
system(".\\build.bat")
} $else {
system("cd admin && yarn build")
}
mkdir("${publish_dir}/admin/")!
cp_all("admin/dist/", "${publish_dir}/admin/dist/", true) or {
println(err)
}
cp_all("resources/", "${publish_dir}/resources/", true) or {
println(err)
}
if is_dir ("build.dSYM") {
rmdir_all("build.dSYM")!
}
system("zip -q -r publish.zip publish")
use_time := time.since(start)
println(term.bold(term.ok_message("构建完成, 目录: ${use_time.seconds()}")))