-
Notifications
You must be signed in to change notification settings - Fork 2
/
release_pkg.sh
141 lines (123 loc) · 3.26 KB
/
release_pkg.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
#! /bin/bash
set -e
RESPOSITORY="https://github.com/hootrhino"
#
create_pkg() {
local target=$1
local version=$(git describe --tags --always --abbrev=0)
local release_dir="_release"
local pkg_name="rulexc-$target-$version.zip"
local files_to_include="./rulexc"
local files_to_include_exe="./rulexc.exe"
if [[ "$target" != "windows" ]]; then
files_to_include="$files_to_include ./script/*.sh"
mv ./rulexc-$target ./rulexc
chmod +x ./rulexc
else
files_to_include="$files_to_include_exe"
mv ./rulexc-$target.exe ./rulexc.exe
fi
echo "Create package: $pkg_name"
zip -j "$release_dir/$pkg_name" $files_to_include
}
#
make_zip() {
if [ -n $1 ]; then
create_pkg $1
else
echo "Should have release target."
exit 1
fi
}
build_windows() {
make windows
}
build_x64linux() {
make x64linux
}
build_arm64linux() {
make arm64
}
build_arm32linux() {
make arm32
}
build_mips64linux() {
make mips64
}
build_mips32linux() {
make mips32
}
#------------------------------------------
cross_compile() {
ARCHS=("windows" "x64linux" "arm64linux" "arm32linux")
if [ ! -d "./_release/" ]; then
mkdir -p ./_release/
else
rm -rf ./_release/
mkdir -p ./_release/
fi
for arch in ${ARCHS[@]}; do
echo -e "\033[34m [★] Compile target =>\033[43;34m ["$arch"]. \033[0m"
if [[ "${arch}" == "windows" ]]; then
build_windows $arch
make_zip $arch
echo -e "\033[33m [√] Compile target => ["$arch"] Ok. \033[0m"
fi
if [[ "${arch}" == "x86linux" ]]; then
build_x86linux $arch
make_zip $arch
echo -e "\033[33m [√] Compile target => ["$arch"] Ok. \033[0m"
fi
if [[ "${arch}" == "x64linux" ]]; then
build_x64linux $arch
make_zip $arch
echo -e "\033[33m [√] Compile target => ["$arch"] Ok. \033[0m"
fi
if [[ "${arch}" == "arm64linux" ]]; then
# sudo apt install gcc-arm-linux-gnueabi -y
build_arm64linux $arch
make_zip $arch
echo -e "\033[33m [√] Compile target => ["$arch"] Ok. \033[0m"
fi
if [[ "${arch}" == "arm32linux" ]]; then
# sudo apt install gcc-arm-linux-gnueabi -y
build_arm32linux $arch
make_zip $arch
echo -e "\033[33m [√] Compile target => ["$arch"] Ok. \033[0m"
fi
done
}
#
#-----------------------------------
#
init_env() {
if [ ! -d "./_build/" ]; then
mkdir -p ./_build/
else
rm -rf ./_build/
mkdir -p ./_build/
fi
}
#
# 检查是否安装了这些软件
#
check_cmd() {
DEPS=("bash" "git" "jq" "gcc" "make" "x86_64-w64-mingw32-gcc")
for dep in ${DEPS[@]}; do
echo -e "\033[34m [*] Check dependcy command: $dep. \033[0m"
if ! [ -x "$(command -v $dep)" ]; then
echo -e "\033[31m |x| Error: $dep is not installed. \033[0m"
exit 1
else
echo -e "\033[32m [√] $dep has been installed. \033[0m"
fi
done
}
#
#-----------------------------------
#
check_cmd
init_env
cp -r $(ls | egrep -v '^_build$') ./_build/
cd ./_build/
cross_compile