importos
importsys
importtime
importhashlib
importargparse
importsubprocess
importrequests
fromemailimportencoders
fromemail.headerimportHeader
fromemail.mime.textimportMIMEText
fromemail.utilsimportparseaddr, formataddr
importsmtplib
# configuration for pgyer
PGYER_UPLOAD_URL ="https://qiniu-storage.pgyer.com/apiv1/app/upload"
USER_KEY ="da93ac1c4ae3f9ad0a7ca304de08e211"
API_KEY ="6b505388748ebc3c6d66432fb95cba2c"
# 项目根目录
project_path ="/Users/user/Desktop/cornerstone/TncObj"
# 编译成功后.app所在目录
app_path ="/Users/user/Desktop/cornerstone/TncObj/build/Release-iphoneos/TncObj.app"
# 指定项目下编译目录
build_path ="build"
# 打包后ipa存储目录
targerIPA_parth ="/Users/user/Desktop"
# 清理项目 创建build目录
defclean_project_mkdir_build():
os.system('cd %s;xcodebuild clean'% project_path)# clean 项目
os.system('cd %s;mkdir build'% project_path)
defbuild_project():
print("build release start")
# os.system ('cd %s;xcodebuild -list'%project_path)
print("2")
os.system ('cd %s;xcodebuild -project TncObj.xcodeproj -target TncObj -configuration Release'% (project_path))
print("3")
defbuild_ipa():
globalipa_filename
ipa_filename = time.strftime('TncObj_%Y-%m-%d-%H-%M-%S.ipa',time.localtime(time.time()))
os.system ('xcrun -sdk iphoneos PackageApplication -v %s -o %s/%s'% (app_path,targerIPA_parth,ipa_filename))
defuploadIpaToPgyer():
globalipaPath
ipaPath = ('/Users/user/Desktop/TncObj_2017-09-22-16-59-24.ipa')
# ipaPath = open("ipaPath","r", encoding="utf-8")
print(ipaPath)
os.system('curl -F "file=@%s"\
-F "uKey=%s"\
-F "_api_key=%s"\
-F "appType=1"\
%s'% (ipaPath,USER_KEY,API_KEY,PGYER_UPLOAD_URL))
defmain():
# 清理并创建build目录
clean_project_mkdir_build()
# 编译coocaPods项目文件并 执行编译目录
build_project()
# 打包ipa 并制定到桌面
build_ipa()
uploadIpaToPgyer()
# 执行
main()
具体可参考蒲公英提供的API:飞机票