This repository has been archived by the owner on Aug 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 42
/
publish.sh
executable file
·160 lines (138 loc) · 2.86 KB
/
publish.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
#!/bin/bash
###
# @Author: EagleXiang
# @LastEditors: EagleXiang
# @Email: eagle.xiang@outlook.com
# @Github: https://github.com/eaglexiang
# @Date: 2019-08-24 16:56:37
# @LastEditTime: 2019-08-28 21:41:55
###
defaultOS=linux
defaultArch=amd64
get_os() {
# $1:os
if [ "$1" ]; then
os=$1
else
os=$defaultOS
fi
if [ $os = "mac" ]; then
os="darwin"
fi
if [ X$os == "X" ]; then
echo "no os"
exit 1
fi
}
get_arch() {
# $1:arch
if [ "$1" ]; then
arch=$1
else
arch=$defaultArch
fi
if [ X$arch == "X" ]; then
echo "no arch"
exit 1
fi
}
get_bin_name() {
# suffix
if [ $os == "windows" ]; then
suffix="exe"
else
suffix=$os
fi
bin="et.go.$suffix"
}
get_release_name() {
release="et.go.$os.$arch"
if [ $os == "windows" ]; then
release="${release}.zip"
else
release="${release}.tar.gz"
fi
}
compress() {
# release folder
echo "PREPARE TEMPORARY FOLDER"
release_folder="EagleTunnel"
mkdir -p $release_folder
\cp -f $bin $release_folder
# config
release_config=$release_folder/config
mkdir -p $release_config
\cp -rf ./config/* $release_config
# scripts
\cp -f ./install_linux.sh $release_folder/
\cp -f ./uninstall_linux.sh $release_folder/
echo -e "COMPRESS:\t$release"
if [ $os == "windows" ];then
zip -r $release $release_folder
else
tar -czvf $release $release_folder
fi
if [ -f $release ]; then
echo "COMPRESS DONE"
echo "============================================================"
else
echo "COMPRESS ERROR"
echo "============================================================"
exit 1
fi
}
clean() {
if [ -f $bin ]; then
rm -f $bin
if [ ! -f $bin ]; then
echo -e "REMOVED:\t$bin"
fi
rm -rf $release_folder
if [ ! -d $release_folder ]; then
echo -e "REMOVED:\t$release_folder"
fi
echo "============================================================"
fi
}
publish() {
get_os "$1"
get_arch "$2"
get_bin_name
get_release_name
./build.sh "$1" "$2"
compress
clean
mkdir -p ./zip
mv $release ./zip/
}
if [ "$1" ] && [ "$1" == "clean" ]
then
rm -rf ./zip
echo ""
exit 0
fi
# update clear domains
./update_clear_domains.sh
echo ""
if [ "$1" ] && [ "$1" == "all" ]
then
publish linux amd64
echo ""
publish linux 386
echo ""
publish linux arm
echo ""
publish linux arm64
echo ""
publish windows amd64
echo ""
publish windows 386
echo ""
publish darwin amd64
echo ""
publish darwin 386
echo ""
echo "RELEASES PUBLISH FINISHED"
else
publish "$1" "$2"
fi