├── AutoPage ├── DaoBao 3.6.py ├── DaoBao.py └── newUpLoadPgy.py └── README.md /AutoPage/DaoBao 3.6.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | #coding=utf-8 3 | import os 4 | import requests 5 | import webbrowser 6 | import subprocess 7 | import shutil 8 | 9 | ''' 10 | 使用注意事项:该脚本基于python3.6 11 | 1、将工程的编译设备选成 Gemeric iOS Device 12 | 2、command + B编译 13 | 3、执行脚本文件 14 | 15 | ''' 16 | 17 | appFileFullPath = '/Users/Qinz/Library/Developer/Xcode/DerivedData/DDDS-exihsnwhearstpfrwwzohuclewrx/Build/Products/Debug-iphoneos/DDDS.app' 18 | PayLoadPath = '/Users/Qinz/Desktop/Payload' 19 | packBagPath = '/Users/Qinz/Desktop/ProgramBag' 20 | openUrlPath = 'https://www.pgyer.com/manager/dashboard/app/40c633aa8dc0ba15191632860558825e' 21 | 22 | 23 | #上传蒲公英 24 | USER_KEY = "61ded40a6**************d278acd2" 25 | API_KEY = "a4fe2724dc**************4eec219e" 26 | 27 | #上传蒲公英 28 | def uploadIPA(IPAPath): 29 | if(IPAPath==''): 30 | print("\n*************** 没有找到对应上传的IPA包 *********************\n") 31 | return 32 | else: 33 | print("\n***************开始上传到蒲公英*********************\n") 34 | url='http://www.pgyer.com/apiv1/app/upload' 35 | data={ 36 | 'uKey':USER_KEY, 37 | '_api_key':API_KEY, 38 | 'installType':'2', 39 | 'password':'', 40 | 'updateDescription':"" 41 | } 42 | files={'file':open(IPAPath,'rb')} 43 | r=requests.post(url,data=data,files=files) 44 | 45 | def openDownloadUrl(): 46 | webbrowser.open(openUrlPath,new=1,autoraise=True) 47 | print ("\n*************** 更新成功 *********************\n") 48 | 49 | #编译打包流程 50 | def bulidIPA(): 51 | 52 | #删除之前打包的ProgramBag文件夹 53 | subprocess.call(["rm","-rf",packBagPath]) 54 | #创建PayLoad文件夹 55 | mkdir(PayLoadPath) 56 | #将app拷贝到PayLoadPath路径下 57 | subprocess.call(["cp","-r",appFileFullPath,PayLoadPath]) 58 | #在桌面上创建packBagPath的文件夹 59 | subprocess.call(["mkdir","-p",packBagPath]) 60 | #将PayLoadPath文件夹拷贝到packBagPath文件夹下 61 | subprocess.call(["cp","-r",PayLoadPath,packBagPath]) 62 | #删除桌面的PayLoadPath文件夹 63 | subprocess.call(["rm","-rf",PayLoadPath]) 64 | #切换到当前目录 65 | os.chdir(packBagPath) 66 | #压缩packBagPath文件夹下的PayLoadPath文件夹夹 67 | subprocess.call(["zip","-r","./Payload.zip","."]) 68 | print ("\n*************** 打包成功 *********************\n") 69 | #将zip文件改名为ipa 70 | subprocess.call(["mv","payload.zip","Payload.ipa"]) 71 | #删除payLoad文件夹 72 | subprocess.call(["rm","-rf","./Payload"]) 73 | 74 | 75 | #创建PayLoad文件夹 76 | def mkdir(PayLoadPath): 77 | isExists = os.path.exists(PayLoadPath) 78 | if not isExists: 79 | os.makedirs(PayLoadPath) 80 | print(PayLoadPath + '创建成功') 81 | return True 82 | else: 83 | print (PayLoadPath + '目录已经存在') 84 | return False 85 | 86 | 87 | if __name__ == '__main__': 88 | des = input("请输入更新的日志描述:") 89 | bulidIPA() 90 | uploadIPA('%s/Payload.ipa'%packBagPath) 91 | openDownloadUrl() 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /AutoPage/DaoBao.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | #coding=utf-8 3 | import os 4 | import commands 5 | import requests 6 | import webbrowser 7 | 8 | ''' 9 | 使用注意事项:该脚本基于python2.7 10 | 1、将工程的编译设备选成 Gemeric iOS Device 11 | 2、command + B编译 12 | 3、执行脚本文件 13 | 14 | ''' 15 | 16 | appFileFullPath = '/Users/Qinz/Library/Developer/Xcode/DerivedData/DDDS-bcghxucdqelptddawpsfmvjtoefm/Build/Products/Debug-iphoneos/DDDS.app' 17 | PayLoadPath = '/Users/Qinz/Desktop/Payload' 18 | packBagPath = '/Users/Qinz/Desktop/ProgramBag' 19 | 20 | #将此处打开的链接改为蒲公英对应app的链接 21 | openUrl = 'https://www.pgyer.com/manager/dashboard/app/40c633aa8dc0ba15191632860558825e' 22 | 23 | #上传蒲公英 24 | USER_KEY = "61ded40a6xxxxxxxxxx2e9fd278acd2" 25 | API_KEY = "a4fe2724dc6xxxxxxxxxf1994eec219e" 26 | 27 | #上传蒲公英 28 | def uploadIPA(IPAPath): 29 | if(IPAPath==''): 30 | print "\n*************** 没有找到对应上传的IPA包 *********************\n" 31 | return 32 | else: 33 | print "\n***************开始上传到蒲公英*********************\n" 34 | url='http://www.pgyer.com/apiv1/app/upload' 35 | data={ 36 | 'uKey':USER_KEY, 37 | '_api_key':API_KEY, 38 | 'installType':'2', 39 | 'password':'', 40 | 'updateDescription':des 41 | } 42 | files={'file':open(IPAPath,'rb')} 43 | r=requests.post(url,data=data,files=files) 44 | 45 | def openDownloadUrl(): 46 | webbrowser.open(openUrl,new=1,autoraise=True) 47 | print "\n*************** 更新成功 *********************\n" 48 | 49 | 50 | #创建PayLoad文件夹 51 | def mkdir(PayLoadPath): 52 | isExists = os.path.exists(PayLoadPath) 53 | if not isExists: 54 | os.makedirs(PayLoadPath) 55 | print PayLoadPath + '创建成功' 56 | return True 57 | else: 58 | print PayLoadPath + '目录已经存在' 59 | return False 60 | 61 | 62 | #编译打包流程 63 | def bulidIPA(): 64 | #打包之前先删除packBagPath下的文件夹 65 | commands.getoutput('rm -rf %s'%packBagPath) 66 | #创建PayLoad文件夹 67 | mkdir(PayLoadPath) 68 | #将app拷贝到PayLoadPath路径下 69 | commands.getoutput('cp -r %s %s'%(appFileFullPath,PayLoadPath)) 70 | #在桌面上创建packBagPath的文件夹 71 | commands.getoutput('mkdir -p %s'%packBagPath) 72 | #将PayLoadPath文件夹拷贝到packBagPath文件夹下 73 | commands.getoutput('cp -r %s %s'%(PayLoadPath,packBagPath)) 74 | #删除桌面的PayLoadPath文件夹 75 | commands.getoutput('rm -rf %s'%(PayLoadPath)) 76 | #切换到当前目录 77 | os.chdir(packBagPath) 78 | #压缩packBagPath文件夹下的PayLoadPath文件夹夹 79 | commands.getoutput('zip -r ./Payload.zip .') 80 | print "\n*************** 打包成功 *********************\n" 81 | #将zip文件改名为ipa 82 | commands.getoutput('mv Payload.zip Payload.ipa') 83 | #删除payLoad文件夹 84 | commands.getoutput('rm -rf ./Payload') 85 | 86 | 87 | 88 | 89 | if __name__ == '__main__': 90 | des = input("请输入更新的日志描述:") 91 | bulidIPA() 92 | uploadIPA('%s/Payload.ipa'%packBagPath) 93 | openDownloadUrl() 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /AutoPage/newUpLoadPgy.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | #coding=utf-8 3 | import os,time 4 | #import commands 5 | import subprocess 6 | import requests 7 | import webbrowser 8 | import time 9 | 10 | #上传蒲公英 11 | USER_KEY = "61ded40a68afxxxxxxxfd278acd2" 12 | API_KEY = "a4fe2724dc6d8xxxxxxxx1994eec219e" 13 | 14 | def searchIpaPath(): 15 | IpaPath="" 16 | for i in os.listdir("."): 17 | if(i.find('.ipa')!=(-1)): 18 | IpaPath=i 19 | print '找到的IPA文件:'+IpaPath 20 | return IpaPath 21 | return IpaPath 22 | 23 | def uploadIPA(IPAPath): 24 | if(IPAPath==''): 25 | print "\n*************** 没有找到对应上传的IPA包 *********************\n" 26 | return 27 | else: 28 | print "\n***************开始上传到蒲公英*********************\n" 29 | url='http://www.pgyer.com/apiv1/app/upload' 30 | data={ 31 | 'uKey':USER_KEY, 32 | '_api_key':API_KEY, 33 | 'installType':'2', 34 | 'password':'', 35 | 'updateDescription':des 36 | } 37 | files={'file':open(IPAPath,'rb')} 38 | r=requests.post(url,data=data,files=files) 39 | 40 | 41 | def openDownloadUrl(): 42 | #此处的地址需要换成蒲公英上自己对应的应用地址 43 | webbrowser.open(r'https://www.pgyer.com/manager/dashboard/app/40c633aa8dc0ba15191632860558825e',new=1,autoraise=True) 44 | print "\n*************** 更新成功 *********************\n" 45 | 46 | def buildIpa(): 47 | start = time.time() 48 | print "\n*************** IPA包生成中 *********************\n" 49 | #commands.getoutput('ipa build') #使用shenzheng打包ipa 50 | p = subprocess.Popen('ipa build', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 51 | for line in p.stdout.readlines(): 52 | print line, 53 | retval = p.wait() 54 | 55 | end = time.time() 56 | print "--------- 打包耗时:%s秒 ---------"%(end-start) 57 | print "\n*************** IPA包生成成功,准备上传蒲公英 *********************\n" 58 | 59 | 60 | if __name__ == '__main__': 61 | #输入日志格式为 "修改bug" 记得加上双引号,如果有多行可以这么写: 62 | # "1 修改首页bug \n 2 修改点击按钮闪退问题 " 63 | des = input("请输入更新的日志描述:") 64 | buildIpa() 65 | IpaPath=searchIpaPath() 66 | uploadIPA(IpaPath) 67 | openDownloadUrl() 68 | 69 | 70 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # iOSAutoPage 2 |
python脚本实现自动化打包,具体使用过程移步简书:
3 | https://www.jianshu.com/p/1f47066da6f7 4 |

5 | http://www.cocoachina.com/ios/20180507/23295.html 6 | --------------------------------------------------------------------------------