-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpodpush.sh
More file actions
executable file
·126 lines (119 loc) · 2.42 KB
/
Copy pathpodpush.sh
File metadata and controls
executable file
·126 lines (119 loc) · 2.42 KB
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
#!/bin/bash
set -e
WORKDIR=`pwd`
SPECNAME=
REPONAME=
ISJSON=
VERBOSE=
SPECVERSION=
SPECBASENAME=
LOCAL=
VALIDATION='--skip-import-validation --skip-tests --quick'
STATIC=
FORCE=0
while [ $# -gt 0 ];do
case $1 in
-static)
shift
STATIC='--use-libraries'
;;
-spec)
SPECNAME=$2
SPECBASENAME=${SPECNAME%%\.podspec}
SPECVERSION=`pod ipc spec $SPECNAME | awk -F \" '{ if($2=="version") printf("%s\n",$4); }'`
shift 2
;;
-repo)
REPONAME=$2
shift 2
;;
-check)
shift
VALIDATION=
;;
-json)
shift
ISJSON='--use-json'
;;
-v)
shift
VERBOSE='--verbose'
set -x
;;
-local)
shift
LOCAL='--local-only'
;;
-force)
shift
FORCE=1
;;
*)
echo "ignore -- $1"
shift
;;
esac
done
function usage()
{
echo "usage: podpush
-spec xxx.podspec
-repo push-reponame
-static use-libraries
-check validation library
-json json format spec
-force force push whitout validation
-local only push to local repos
-v verbose"
}
function manual_push_repo()
{
echo "Publish repo, manual"
# 进入Specs的Git目录
cd ~/.cocoapods/repos/$REPONAME
# git pull 拉取最新代码
git pull
set +e
# 创建与spec同名的目录与版本号文件夹
mkdir -p $SPECBASENAME/$SPECVERSION
set -e
# 拷贝spec文件到文件目录下
if [ -z $ISJSON ]; then
cp $WORKDIR/$SPECNAME $SPECBASENAME/$SPECVERSION
git add $SPECBASENAME/$SPECVERSION/$SPECNAME
else
pod ipc spec $WORKDIR/$SPECNAME > $SPECBASENAME/$SPECVERSION/$SPECNAME.json
git add $SPECBASENAME/$SPECVERSION/$SPECNAME.json
fi
# 提交并推送
git commit -m "[Update] $SPECBASENAME ($SPECVERSION)"
# 推送
if [ -z $LOCAL ];then
git push
echo "publish done"
else
echo "no publish"
fi
cd $WORKDIR
}
function pod_push_repo()
{
echo "Publish repo, $REPONAME $SPECNAME $ISJSON $LOCAL --allow-warnings --skip-import-validation --skip-tests $STATIC $VERBOSE"
pod repo push --sources='https://github.com/CocoaPods/Specs.git' $REPONAME $SPECNAME $ISJSON $LOCAL --allow-warnings --skip-import-validation --skip-tests $STATIC $VERBOSE
}
if [ -z $SPECNAME ];then
usage
exit 1
fi
echo "Valid spec, $SPECNAME --allow-warnings --fail-fast $VALIDATION $STATIC $VERBOSE"
pod spec lint --sources='https://github.com/CocoaPods/Specs.git' $SPECNAME --allow-warnings --fail-fast $VALIDATION $STATIC $VERBOSE
if [ -z $REPONAME ];then
usage
pod repo list
exit 2
fi
if [ $FORCE == 1 ];then
manual_push_repo
else
pod_push_repo
fi