-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublish_pod.py
137 lines (110 loc) · 3.46 KB
/
publish_pod.py
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
import os
import sys
def selectOperator():
print("")
print("* 1. 直接push到公共源")
print("* 2. 提交到develop分支")
print("* 3. 提交到main分支")
print("* 4. 提交到main并push到公共源")
print("")
return
def isRepoDirty():
return os.system("git diff --quiet") != 0
def switchBranch(branch):
branchType = int(branch)
if branchType in [1, 2, 3] == False:
print("")
print("* 1. 停留在当前分支")
print("* 2. 切换到develop分支")
print("* 3. 切换到main分支")
print("")
# 输入切换的选项
branchType = int(input("请选择要切换到的分支:"))
else:
print("切换到的类型为:%d", branchType)
# 切换到指定分支
if branchType == 2:
os.system("git checkout develop")
elif branchType == 3:
os.system("git checkout main")
else:
print("停留在当前分支。")
return
def pushToGit(branchName):
pushBranch = branchName
if len(branchName) <= 0:
pushBranch = "main"
else:
pushBranch = branchName
print("开始发布到当前分支 ...")
os.system("git status")
os.system("git add --all")
msg = input("\n请输入提交信息(默认为'日常提交'):")
print("提交信息:%s" % msg)
os.system("git commit -m '%s'" % ("日常提交" if msg.isspace() else msg))
os.system("git pull origin %s" % pushBranch)
os.system("git push origin %s" % pushBranch)
print("已经上传到%s成功了" % pushBranch)
return
def addGitTag(tag):
os.system("git tag %s" % tag)
os.system("git push origin --tags")
return
def pushToMain():
switchBranch(3)
pushToGit("main")
return
# 提交到main,并且打tag,推送到cocopods
def pushToMainAndPushSpecs():
switchBranch(3)
pushToGit("main")
tag = str(input("输入要发布的版本号(跳过设置 Tag 请直接回车):"))
if len(tag) <= 0:
print("输入版本号为空,跳过设置 Tag 步骤")
else:
addGitTag(tag)
pushToPrivateSpecs()
# 直接push到CTSpecs
def pushToPrivateSpecs():
checkCommand = "pod lib lint %s.podspec --allow-warnings"%podName
pushCommand = "pod trunk push %s.podspec --allow-warnings"%podName
updatePirvateRepo = "cd Example&&pod update SwiftyFileBrowser"
checkRet = os.system(checkCommand)
if checkRet != 0:
print("校验出错,请检查spec文件是否配置正确")
exit - 1
else:
pushRet = os.system(pushCommand)
if pushRet != 0:
print("上传失败!")
exit - 1
else:
print("上传完成!!")
os.system(updatePirvateRepo)
return
if __name__ == "__main__":
# 进入到发布路径
#os.chdir(sys.argv[1])
# 输入库名称
# podName = str(input("请输入要发布的pod库名称:"))
podName = "SwiftyFileBrowser"
# 输入操作类型
selectOperator()
# 输入发布类型
option = input("请选择发布的类型(默认为1):")
# option 不输入时默认为1,否则为输入内容
if len(option) <= 0:
option = 1
else:
option = int(option)
# 去发布
if option == 1:
pushToPrivateSpecs()
elif option == 2:
pushToGit("develop")
elif option == 3:
pushToGit("main")
elif option == 4:
pushToMainAndPushSpecs()
else:
print("🤨 -> 请输入正确的选项!!")