-
Notifications
You must be signed in to change notification settings - Fork 0
/
old.sh
executable file
·167 lines (151 loc) · 5.09 KB
/
old.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#!/bin/sh
set -e
# 获取当前路径, 用于返回
p0=`pwd`
# 获取脚本所在路径, 防止后续操作在非项目路径
p1=$(cd $(dirname $0);pwd)
platform=("windows" "mac" "mac")
OS=("windows" "darwin" "darwin")
arch=("amd64" "amd64" "arm64")
ext=(".exe" "" "")
echo 清理旧版本...
rm -rf ./dl/*
echo 打包数据工具...
repo="gitee.com/quant1x/data"
type="data"
if [ -d ${type} ]; then
rm -rf ${type}
fi
dataVersion="0.0.1"
dataBranch="1.10.x"
git clone -b ${dataBranch} --depth 1 https://gitee.com/quant1x/data.git
if [ -d ${type} ]; then
cd ${type}
version=$(git describe --tag)
version=${version%%-*}
version=${version:1}
dataVersion=${version}
echo "${type} version=${version}"
mkdir bin
for (( i = 0 ; i < ${#platform[@]} ; i++ ))
do
rm -f bin/*
echo "正在编译${platform[$i]}的${arch[$i]}应用..."
#apps=("stock" "snapshot")
apps=("stock")
for app in ${apps[@]}
do
echo "正在编译${platform[$i]}的${arch[$i]}应用...$app..."
#env GOOS=${OS[$i]} GOARCH=${arch[$i]} go build -ldflags "-s -w -X 'main.MinVersion=${dataVersion}'" -o bin/${app}${ext[$i]} gitee.com/quant1x/data/update/${app}
env GOOS=${OS[$i]} GOARCH=${arch[$i]} go build -ldflags "-s -w -X 'main.MinVersion=${dataVersion}'" -o bin/${app}${ext[$i]} gitee.com/quant1x/data
echo "正在编译${platform[$i]}的${arch[$i]}应用...$app...OK"
done
echo "正在编译${platform[$i]}的${arch[$i]}应用...OK"
zip ../dl/${type}-$version.${OS[$i]}-${arch[$i]}.zip bin/*
rm bin/*
done
cd ..
rm -rf ./${type}
fi
echo '打包策略工具(Zero-Sum Game)...'
repo="gitee.com/quant1x/zero-sum"
type="zero-sum"
if [ -d ${type} ]; then
rm -rf ${type}
fi
zeroSumVersion="0.0.1"
git clone --depth 1 https://${repo}.git ${type}
if [ -d ${type} ]; then
cd ${type}
mkdir bin
version=$(git describe --tags `git rev-list --tags --max-count=1`)
version=${version:1}
zeroSumVersion=${version}
echo "${type} version=${version}"
text=$(go list -m gitee.com/quant1x/gotdx)
array=($text)
tdxVersion=${array[1]:1}
text=$(go list -m gitee.com/quant1x/stock)
array=($text)
exDataVersion=${array[1]:1}
for (( i = 0 ; i < ${#platform[@]} ; i++ ))
do
rm -f bin/*
echo "正在编译${platform[$i]}的${arch[$i]}应用..."
meths=("")
apps=("zero-sum")
for (( j = 0 ; j < ${#meths[@]} ; j++ ))
do
echo "正在编译${platform[$i]}的${arch[$i]}应用...${meths[$j]}..."
env GOOS=${OS[$i]} GOARCH=${arch[$i]} go build -ldflags "-s -w -X 'main.MinVersion=${zeroSumVersion}' -X 'main.tdxVersion=${tdxVersion}' -X 'main.dataVersion=${exDataVersion}'" -o bin/${apps[$j]}${ext[$i]} ${repo}/${meths[$j]}/${meths[$j]}
echo "正在编译${platform[$i]}的${arch[$i]}应用...${meths[$j]}...OK"
done
echo "正在编译${platform[$i]}的${arch[$i]}应用...OK"
zip ../dl/${type}-$version.${OS[$i]}-${arch[$i]}.zip bin/*
rm bin/*
done
cd ..
rm -rf ./${type}
fi
echo '打包策略工具(t89k)...'
repo="gitee.com/quant1x/t89k"
type="quant"
if [ -d ${type} ]; then
rm -rf ${type}
fi
quantVersion="0.0.1"
quantBranch="1.9.x"
git clone -b ${quantBranch} --depth 1 https://${repo}.git ${type}
if [ -d ${type} ]; then
cd ${type}
mkdir bin
version=$(git describe --tag)
version=${version%%-*}
version=${version:1}
quantVersion=${version}
echo "${type} version=${version}"
text=$(go list -m gitee.com/quant1x/gotdx)
array=($text)
tdxVersion=${array[1]:1}
text=$(go list -m gitee.com/quant1x/data)
array=($text)
exDataVersion=${array[1]:1}
for (( i = 0 ; i < ${#platform[@]} ; i++ ))
do
rm -f bin/*
echo "正在编译${platform[$i]}的${arch[$i]}应用..."
meths=("")
apps=("quant")
for (( j = 0 ; j < ${#meths[@]} ; j++ ))
do
echo "正在编译${platform[$i]}的${arch[$i]}应用...${meths[$j]}..."
env GOOS=${OS[$i]} GOARCH=${arch[$i]} go build -ldflags "-s -w -X 'main.MinVersion=${quantVersion}' -X 'main.dataVersion=${exDataVersion}' -X 'main.tdxVersion=${tdxVersion}'" -o bin/${apps[$j]}${ext[$i]} ${repo}/${meths[$j]}
echo "正在编译${platform[$i]}的${arch[$i]}应用...${meths[$j]}...OK"
done
echo "正在编译${platform[$i]}的${arch[$i]}应用...OK"
zip ../dl/${type}-$version.${OS[$i]}-${arch[$i]}.zip bin/*
rm bin/*
done
cd ..
rm -rf ./${type}
fi
build_time=`date '+%Y-%m-%d %H:%M:%S'`
sed "s/\${quant_version}/${quantVersion}/g" index.tpl | sed "s/\${data_version}/${dataVersion}/g" | sed "s/\${zs_version}/${zeroSumVersion}/g" | sed "s/\${build_time}/${build_time}/g" > index.html
git add .
git commit -m "更新版本 ${quantVersion}"
version=$(git describe --tags `git rev-list --tags --max-count=1`)
version=${version:1}
if [ "$version" == "quantVersion" ]; then
echo "版本相同, 先删除tag"
git tag --delete v${quantVersion}
echo "版本相同, 先删除tag...OK"
fi
git tag -a v${quantVersion} -m "Release version ${quantVersion}" --force
git push
if [ "$version" == "quantVersion" ]; then
echo "版本相同, 先删除远程tag"
git push origin :v${quantVersion}
echo "版本相同, 先删除远程tag...OK"
fi
git push --tags --force
cd $p0