xcodebuild自动打包上传到蒲公英的shell脚本

 

 注意: ExportOptions.plist (包含了证书相关信息)

   该plist 文件可以通过xcode手动导出ipa之后获取到, 区分appstore 和 development的情况

#! /bin/sh


scheme_name="Test"
workspace_path="/Users/xueshan1/Desktop/test/Test.xcworkspace"
configuration="Release"
archive_path="/Users/xueshan1/Desktop/archive/Test.xcarchive"
ipa_path="/Users/xueshan1/Desktop/archive/ipa"
plist_path="/Users/xueshan1/Desktop/test/ExportOptions.plist"


# clean
echo '=============正在清理工程============='
xcodebuild clean -configuration ${configuration} -quiet || exit


echo '清理完成-->>>--正在编译工程:'${configuration}


#archive
if [ -d $archive_path ]
then
echo "已有archive -> 删除已有的"
mv /Users/xueshan1/Desktop/archive ~/.Trash

fi


echo '重新archive'

xcodebuild archive -workspace ${workspace_path} -scheme ${scheme_name} \
-configuration ${configuration} \
-archivePath ${archive_path} -quiet || exit


#ipa
if [ -d $ipa_path ]
then
echo "已经ipa"
else
xcodebuild -exportArchive -archivePath ${archive_path} \
-configuration ${configuration} \
-exportPath ${ipa_path} \
-exportOptionsPlist ${plist_path} \
-quiet || exit
fi


if [ -d $ipa_path ]
then
echo "已经有了ipa"
# open $ipa_path
fi
#upload

# curl -F "file=@${ipa_path}/Test.ipa" -F "uKey=fee85d13ecc10a5ec9ada3970980effe" -F "_api_key=eb4171585a2f2df5674db48745520bc0" -F "password=maxueshan123" https://www.pgyer.com/apiv2/app/upload
curl -F "file=@${ipa_path}/Test.ipa" -F "_api_key=eb4171585a2f2df5674db48745520bc0" -F "password=maxueshan123" -F "buildInstallType=2" -F "buildPassword=2" https://www.pgyer.com/apiv2/app/upload


if [ $? = 0 ]
then
echo 'success 😀'
else
echo '😯 NO'
fi


 

posted @ 2019-07-01 20:14  Da雪山  阅读(284)  评论(0)    收藏  举报