-
Notifications
You must be signed in to change notification settings - Fork 21
/
01-build_server.sh
executable file
·60 lines (58 loc) · 2.28 KB
/
01-build_server.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
#!/usr/bin/env bash
export PATH=$PATH:$GOPATH/bin
#go get -u github.com/swaggo/swag/cmd/swag
swag init -g cmd/server/main.go
# shellcheck disable=SC2181
if [ "$?" != "0" ]; then
echo "!!!!!!Swagger documentation generate error, please check the source code!!!!!!"
exit 1
fi
# build webui
#cd webui && yarn run build && cd ../
#sed -i "s/Vue App/KubeFileBrowser/g" static/index.html
# build server
name="kubefilebrowser"
# shellcheck disable=SC2006
VERSION=`git describe --tags --abbrev=0`
# shellcheck disable=SC2006
GO_VERSION=`go version|awk '{print $3" "$4}'`
# shellcheck disable=SC2006
GIT_URL=`git remote -v|grep push|awk '{print $2}'`
# shellcheck disable=SC2006
GIT_BRANCH=`git rev-parse --abbrev-ref HEAD`
# shellcheck disable=SC2006
GIT_COMMIT=`git rev-parse HEAD`
# shellcheck disable=SC2006
GIT_LATEST_TAG=`git describe --tags --abbrev=0`
# shellcheck disable=SC2006
BUILD_TIME=`date +"%Y-%m-%d %H:%M:%S %Z"`
LDFLAGS="-X 'github.com/xmapst/kubefilebrowser.GoVersion=${GO_VERSION}' -X 'github.com/xmapst/kubefilebrowser.GitUrl=${GIT_URL}' -X 'github.com/xmapst/kubefilebrowser.GitBranch=${GIT_BRANCH}' -X 'github.com/xmapst/kubefilebrowser.GitCommit=${GIT_COMMIT}' -X 'github.com/xmapst/kubefilebrowser.BuildTime=${BUILD_TIME}'"
# shellcheck disable=SC2006
DistList=`go tool dist list`
for i in ${DistList}; do
# shellcheck disable=SC2006
Platforms=`echo "${i}"|awk -F/ '{print $1}'`
if [ "${Platforms}" == "android" ] || [ "${Platforms}" == "ios" ] || [ "${Platforms}" == "js" ];then
continue
fi
# shellcheck disable=SC2006
# shellcheck disable=SC2034
Archs=`echo "${i}"|awk -F/ '{print $2}'`
# shellcheck disable=SC2170
# shellcheck disable=SC2252
if [ "${Archs}" != "386" ] && [ "${Archs}" != "amd64" ] && [ "${Archs}" != "arm" ] && [ "${Archs}" != "arm64" ];then
continue
fi
echo "Building ${Platforms} ${Archs}..."
# shellcheck disable=SC2027
BinaryName="kubefilebrowser_${Platforms}_${Archs}"
if [ "${Platforms}" == "windows" ];then
BinaryName="kubefilebrowser_${Platforms}_${Archs}.exe"
fi
CGO_ENABLED=0 GOOS=${Platforms} GOARCH=${Archs} go build -a -ldflags "${LDFLAGS}" -o "${BinaryName}" cmd/server/main.go
# shellcheck disable=SC2181
if [ "$?" != "0" ]; then
echo "!!!!!!ls compilation error, please check the source code!!!!!!"
exit 1
fi
done