-
Notifications
You must be signed in to change notification settings - Fork 36
/
build_ubuntu.sh
89 lines (87 loc) · 3.08 KB
/
build_ubuntu.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
#!/usr/bin/env bash
: '
Copyright (c) 2021-present ffactory.org
hotbuild is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
'
lastTag=$(git describe --tags $(git rev-list --tags --max-count=1))
goVersion=$(go version | awk '{print $3'})
versionFile=./version/version.go
release=bin
echo $lastTag
echo $goVersion
rm -f $release/*
# 更新版本号
sed -i "s/const Version = \"*.*.*\"/const Version = \"$lastTag\"/" ${versionFile}
# 更新go版本
sed -i "s/const GoVersion = \"*.*.*\"/const GoVersion = \"$goVersion\"/" ${versionFile}
# Linux amd64
GO_ENABLED=0 GOOS=linux GOARCH=amd64
target="hotbuild_${lastTag}_${GOOS}_${GOARCH}"
GO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-X 'version.Version=$lastTag'" -o ./$release/$target/
cd $release/
zip -mr $target.zip $target
cd ..
# Linux arm
GO_ENABLED=0 GOOS=linux GOARCH=arm
target="hotbuild_${lastTag}_${GOOS}_${GOARCH}"
GO_ENABLED=0 GOOS=linux GOARCH=arm go build -ldflags="-X 'version.Version=$lastTag'" -o ./$release/$target/
cd $release/
zip -mr $target.zip $target
cd ..
# Linux arm64
GO_ENABLED=0 GOOS=linux GOARCH=arm64
target="hotbuild_${lastTag}_${GOOS}_${GOARCH}"
GO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags="-X 'version.Version=$lastTag'" -o ./$release/$target/
cd $release/
zip -mr $target.zip $target
cd ..
# Linux loong64
GO_ENABLED=0 GOOS=linux GOARCH=loong64
target="hotbuild_${lastTag}_${GOOS}_${GOARCH}"
GO_ENABLED=0 GOOS=linux GOARCH=loong64 go build -ldflags="-X 'version.Version=$lastTag'" -o ./$release/$target/
cd $release/
zip -mr $target.zip $target
cd ..
# Linux riscv64
GO_ENABLED=0 GOOS=linux GOARCH=riscv64
target="hotbuild_${lastTag}_${GOOS}_${GOARCH}"
GO_ENABLED=0 GOOS=linux GOARCH=riscv64 go build -ldflags="-X 'version.Version=$lastTag'" -o ./$release/$target/
cd $release/
zip -mr $target.zip $target
cd ..
# macosx amd64
GO_ENABLED=0 GOOS=darwin GOARCH=amd64
target="hotbuild_${lastTag}_${GOOS}_${GOARCH}"
GO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="-X 'version.Version=$lastTag'" -o ./$release/$target/
cd $release/
zip -mr $target.zip $target
cd ..
# macosx arm64
GO_ENABLED=0 GOOS=darwin GOARCH=arm64
target="hotbuild_${lastTag}_${GOOS}_${GOARCH}"
GO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags="-X 'version.Version=$lastTag'" -o ./$release/$target/
cd $release/
zip -mr $target.zip $target
cd ..
# windows
GO_ENABLED=0 GOOS=windows GOARCH=amd64
target="hotbuild_${lastTag}_${GOOS}_${GOARCH}"
GO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="-X 'version.Version=$lastTag'" -o ./$release/$target/
cd $release/
zip -mr $target.zip $target
cd ..
# md5
cd $release/
echo "" >md5checksum.txt
for i in $(ls *.zip); do
md5sum $i >>md5checksum.txt
done
cd ..
cat $release/md5checksum.txt