900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > iOS一键打包自动改build并输入更新日志上传发布应用到Fir Pgyer

iOS一键打包自动改build并输入更新日志上传发布应用到Fir Pgyer

时间:2021-01-10 17:43:50

相关推荐

iOS一键打包自动改build并输入更新日志上传发布应用到Fir Pgyer

复制expert.sh到项目根目录

如果打包失败,先用Xcode打一次就正常了

使用方法

$ sh expert.sh输入序号,选择打包方式,按回车继续 1. development 2. ad-hoc3. app-store 4. enterprise 复制代码

expert.sh

## 计时SECONDS=0## 默认值project=`find . -name *.xcodeproj | awk -F "[/.]" '{print $(NF-1)}'`##========================根据实际情况修改(一般不用修改)========================## true or false 默认trueis_workspace="true"## 打包方式对应的TARGETS 默认项目名称target_development=${project}target_adhoc="${project}Beta"target_appstore=${project}target_enterprise="${project}Beta"## TARGETS对应的plist 不需要加后缀 默认Info.plistinfo_development="Info"info_adhoc="Info"info_appstore="Info"info_enterprise="Info"## Release or Debug 默认Releaseconfiguration="Release"## Bitcode开关 默认打开compileBitcode=true## 签名方式 默认自动签名,如果打包失败,先用Xcode打一次就正常了signingStyle="automatic"## 工作目录 build目录在.gitignore添加忽略path_build="build"## 自动修改build方式 不修改:none 跟随时间变化:date 自动加1:numberauto_build="date"## pgyer APIKey /account/apipgyer_api_key=""## fir APIKey https://fir.im/appsfir_api_token=""##=========================================================================##================================选择打包方式================================if [ -n "$1" ]thenmethod="$1"elseecho "\033[41;1m输入序号,选择打包方式,按回车继续 \033[0m"echo "\033[31;1m1. development \033[0m"echo "\033[32;1m2. ad-hoc\033[0m"echo "\033[33;1m3. app-store \033[0m"echo "\033[34;1m4. enterprise \033[0m"read parametermethod=${parameter}fitarget=""info=""methodStyle=""if [ -n ${method} ]thenif [ ${method} = "1" ]thenmethodStyle="development"target=${target_development}info=${info_development}elif [ ${method} = "2" ]thenmethodStyle="ad-hoc"target=${target_adhoc}info=${info_adhoc}elif [ ${method} = "3" ]thenmethodStyle="app-store"target=${target_appstore}info=${info_appstore}elif [ ${method} = "4" ]thenmethodStyle="enterprise"target=${target_enterprise}info=${info_enterprise}elseecho "参数错误"exit 1fifipath_info_plist="${project}/${info}.plist"if [ "${auto_build}" = "date" ]then#跟随时间变化buildDate=$(date +%Y%m%d%H%M%S)/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildDate" "$path_info_plist"elif [ "${auto_build}" = "number" ]then#自动加1buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$path_info_plist")buildNumber=$(($buildNumber + 1))/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$path_info_plist"fibundle_build=`/usr/libexec/PlistBuddy -c "Print CFBundleVersion" ${path_info_plist}`bundle_version=`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" ${path_info_plist}`path_package="${path_build}/${target}_${bundle_build}"path_archive="${path_package}/${target}.xcarchive"path_export_options="${path_package}/ExportOptions.plist"if [ -d "${path_package}" ]thenecho "目录${path_package}已存在"elseecho "创建目录${path_package}"mkdir -pv "${path_package}"fifuncExpertOptionFile() {if [ -f "$path_export_options" ]thenrm -rf "$path_export_options"fi/usr/libexec/PlistBuddy -c "Add :compileBitcode bool $compileBitcode" "$path_export_options"/usr/libexec/PlistBuddy -c "Add :signingStyle string $signingStyle" "$path_export_options"/usr/libexec/PlistBuddy -c "Add :method string $methodStyle" "$path_export_options"}funcExpertOptionFile##==========================================================================##================================填写更新日志================================path_update_log="${path_package}/UpdateLog.txt"funcUpdateLog() {echo "输入更新日志"say "输入更新日志"if [ -n "${pgyer_api_key}" -o -n "${fir_api_token}" ]thenrm -rf "$path_update_log"touch "$path_update_log"vim "$path_update_log"count=1history=""for line in $(cat "$path_update_log")dohistory+="[${count}] ${line}. "count=$[${count}+1]doneupdate_log=${history}echo "更新日志:"echo ${update_log}fi}if [ -d "${path_build}" ]thenfuncUpdateLogelsemkdir -pv "${path_build}"funcUpdateLogfi##==========================================================================##===================================归档====================================if $is_workspacethenxcodebuild clean -workspace ${project}.xcworkspace \-scheme ${target} \-configuration ${configuration}xcodebuild archive -workspace ${project}.xcworkspace \-scheme ${target} \-configuration ${configuration} \-archivePath ${path_archive}elsexcodebuild clean -project ${project}.xcodeproj \-scheme ${target} \-configuration ${configuration}xcodebuild archive -project ${project}.xcodeproj \-scheme ${target} \-configuration ${configuration} \-archivePath ${path_archive}fi##==========================================================================if [ -d "${path_archive}" ]thenecho "** Finished archive. Elapsed time: ${SECONDS}s **"echoelseexit 1fi##==================================导出ipa==================================xcodebuild -exportArchive \-archivePath ${path_archive} \-exportPath ${path_package} \-exportOptionsPlist ${path_export_options}##==========================================================================file_ipa="${path_package}/${target}.ipa"if [ -f "${file_ipa}" ]thenecho "** Finished export. Elapsed time: ${SECONDS}s **"say "打包成功"elseexit 1fiechoif [ -n "${pgyer_api_key}" ]then#上传到pgyerecho "正在上传到pgyer..."echocurl -F "file=@${file_ipa}" -F "_api_key=${pgyer_api_key}" -F "buildUpdateDescription=${update_log}*/OctMon/EasyExpertApp build(${bundle_build})*" /apiv2/app/uploadechosay "上传pgyer成功"echofiif [ -n "${fir_api_token}" ]then#上传到firecho "正在上传到fir..."echofir publish "${file_ipa}" -T "${fir_api_token}" -c "${update_log}*/OctMon/EasyExpertApp build(${bundle_build})*"echosay "上传fir成功"echofiif [ -n "${pgyer_api_key}" -o -n "${fir_api_token}" ]thenecho "** Finished upload. Elapsed time: ${SECONDS}s **"echowhile [ "$confirmed" != "y" -a "$confirmed" != "Y" -a "$confirmed" != "n" -a "$confirmed" != "N" ]doread -p "删除${path_package}? (y/n):" confirmeddoneif [ "$confirmed" == "y" -o "$confirmed" == "Y" ]; thenrm -rf ${path_package}fiunset confirmedfiechoecho "--------------------------------------------------------------------------------"echoecho "[${bundle_build}] ${target} version ${bundle_version}"while [ "$confirmed" != "y" -a "$confirmed" != "Y" -a "$confirmed" != "n" -a "$confirmed" != "N" ]doread -p "提交版本变更到远程仓库? (y/n):" confirmeddoneif [ "$confirmed" == "y" -o "$confirmed" == "Y" ]thenechogit add "${path_info_plist}"git commit -m "[${bundle_build}] ${target} version ${bundle_version}"git pushfiunset confirmedechoecho "--------------------------------------------------------------------------------"echoecho "--------------------------------------------------------------------------------"echo "? Congrats"echo "? ${target} (${bundle_build}) successfully published"echo "? Finished. Elapsed time: ${SECONDS}s"echo "? /OctMon/EasyExpertApp"echo "? Tell your friends!"echo "--------------------------------------------------------------------------------"echoif [ -f "${file_ipa}" ]thenopen ${path_package}fi复制代码

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。