-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublish.sh
executable file
·140 lines (113 loc) · 3.27 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
#!/usr/bin/env bash
#Config Color
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
#const
source1=https://github.com/CocoaPods/Specs.git
commitText=""
tag=""
result=`find ./ -maxdepth 1 -type f -name "*.podspec"`
SpecName=${result}
#pull代码
pull() {
echo -e "${GREEN}\n第一步:准备pull代码${NC}⏰⏰⏰"
#先拉代码
if git pull; then
echo -e "${GREEN}pull代码成功${NC}🚀🚀🚀"
else
echo -e "${RED}pull代码失败,请手动解决冲突${NC}🌧🌧🌧"
exit 1
fi
}
#替换podspec的Tag
updatePodspec() {
echo -e "${GREEN}\n第二步:修改 s.version = ${tag} ${NC}⏰⏰⏰"
sed -i '' s/"s.version[[:space:]]*=[[:space:]]*\'[0-9a-zA-Z.]*\'"/"s.version = \'${tag}\'"/g ${SpecName}
}
#本地验证Lib
localVerifyLib(){
echo -e "${GREEN}\n第三步:开始本地验证:pod lib lint ${NC}⏰⏰⏰"
if ! pod lib lint --skip-import-validation --allow-warnings --use-libraries --sources="${source1}"; then echo -e "${RED}验证失败${NC}🌧🌧🌧"; exit 1; fi
echo -e "${GREEN}验证成功${NC}🚀🚀🚀"
}
#push代码,tag
pushAndTag(){
echo -e "${GREEN}\n第四步:准备提交代码${NC}⏰⏰⏰"
git add .
if ! git commit -m ${commitText}
then
echo -e "${RED}git commit失败${NC}🌧🌧🌧"
exit 1
fi
if ! git push
then
echo -e "${RED}git push失败${NC}🌧🌧🌧"
exit 1
fi
echo -e "${GREEN}提交代码成功${NC}🚀🚀🚀"
echo -e "${GREEN}\n第五步:准备打Tag${NC}⏰⏰⏰"
if git tag ${tag}
then
git push --tags
echo -e "${GREEN}打Tag成功${NC}🚀🚀🚀"
else
echo -e "${RED}打Tag失败${NC}🌧🌧🌧"
exit 1
fi
}
#远程验证
remoteVerifyLib(){
echo -e "${GREEN}\n可省步:开始远程验证:pod spec lint ${NC}⏰⏰⏰"
if ! pod spec lint --skip-import-validation --allow-warnings --use-libraries --sources="${source1}"; then echo -e "${RED}验证失败${NC}🌧🌧🌧"; exit 1; fi
echo -e "${GREEN}验证成功${NC}🚀🚀🚀"
}
#发布库
publishLib(){
echo -e "${GREEN}\n第六步:准备发布${tag}版本${NC}⏰⏰⏰"
if ! pod trunk push ${SpecName} --allow-warnings; then echo -e "${RED}发布${tag}版本失败${NC}🌧🌧🌧"; exit 1; fi
echo -e "${GREEN}发布${tag}版本成功${NC}🚀🚀🚀"
}
#发布二进制
publishBinary(){
echo -e "${GREEN}\n第七步:准备发布${tag}二进制版本${NC}⏰⏰⏰"
echo -e "${GREEN}发布${tag}二进制版本成功${NC}🚀🚀🚀"
}
publish(){
#
echo -e "${GREEN}请输入提交内容:${NC}"
read a
commitText=${a}
#
echo -e "${GREEN}请输入tag:${NC}"
read b
tag=${b}
#
if [ -z "$commitText" ]; then
echo -e "${RED}提交内容不能为空${NC}🌧🌧🌧"
exit 1
fi
if [ -z "$tag" ]; then
echo -e "${RED}提交Tag不能为空${NC}🌧🌧🌧"
exit 1
fi
if [ -z "$SpecName" ]; then
echo -e "${RED}请配置podspec的名称${NC}🌧🌧🌧"
exit 1
fi
#
pull
#
updatePodspec
#
localVerifyLib
#
pushAndTag
#
remoteVerifyLib
#
publishLib
#
publishBinary
}
publish