iOS - 基于 Xcode8的自动发版脚本

  • 这里的打包是基于 gym 的:
    这里针对发布企业包:
  • autorelease.sh 脚本文件内容,脚本中有许多地方需要针对本地工程进行适配和优化。
#!/bin/bash
#计时
SECONDS=0
#取当前时间字符串添加到文件结尾
now=$(date +"%Y_%m_%d_%H_%M_%S")
#设置文件路径
cd "工程文件地址"
project_path=$(pwd)
#app文件中Info.plist文件路径
app_infoplist_path=${project_path}/工程名称/Info.plist
echo "plist文件路径 = $app_infoplist_path"
#获取版本号
bundleShortVersion=$(/usr/libexec/PlistBuddy -c "print CFBundleShortVersionString" ${app_infoplist_path})
echo "bundleShortVersion : $bundleShortVersion"
#获取build值
bundleVersion=$(/usr/libexec/PlistBuddy -c "print CFBundleVersion" ${app_infoplist_path})
echo "bundleVersion : $bundleVersion"
#更新build号
((bundleVersion++))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $bundleVersion" "${app_infoplist_path}"
#app名称
appname="app名称"
#指定项目的scheme名称
scheme="scheme 名称"
#指定要打包的configuration
configuration="Inhouse"
#指定打包所使用的输出方式,目前支持app-store, package, ad-hoc, enterprise, development, 和developer-id,即xcodebuild的method参数
export_method='enterprise'
#指定项目地址
workspace_path="$project_path/工程名称.xcworkspace"
#指定输出路径
output_path="/Users/william/Desktop/Domgo自动打包脚本/IPA/${appname}_${bundleShortVersion}.${bundleVersion}-${now}"
#指定输出归档文件地址
archive_path="$output_path/${appname}_${now}.xcarchive"
#指定输出ipa地址
ipa_path="$output_path/${appname}_${now}.ipa"
#指定输出ipa名称
ipa_name="${appname}_${now}.ipa"
#获取执行命令时的commit message
commit_msg="$1"
profile_id="xxxxxxxx-xxxx-4ccb-8b83-4b9b3377c69c"
profile_name="xxxxx_Inhouse"
#修改签名信息
sh FixCodeSignInhouse.sh
#输出设定的变量值
echo "===workspace path: ${workspace_path}==="
echo "===archive path: ${archive_path}==="
echo "===ipa path: ${ipa_path}==="
echo "===export method: ${export_method}==="
echo "===commit msg: $1==="
#先清空前一次build
gym --workspace ${workspace_path} --scheme ${scheme} --clean --configuration ${configuration} --archive_path ${archive_path} --export_method ${export_method} --output_directory ${output_path} --output_name ${ipa_name}
##上传蒲公英
#echo "开始上传蒲公英"
#echo "file=@$output_path/$ipaName.ipa"
#curl -F "file=@${ipa_path}" -F "uKey=xxxxxxxxxxxxxxxxxxxx" -F "_api_key=xxxxxxxxxxxxxxxxxxxxxx" http://www.pgyer.com/apiv1/app/upload
#echo "上传蒲公英完成"
#
#
##上传fir
#echo "开始上传fir"
#fir_token=xxxxxxxxxxxxxxxxxxxxxxx
#fir publish ${ipa_path} -T $fir_token -c "${commit_msg}"
#echo "上传fir完成"
#输出总用时
echo "===Finished. Total time: ${SECONDS}s==="
#echo "local == $project_path"
#cd $project_path
#sh FixCodeSignDevelop.sh
#包类型
profile_type="INHOUSE"
build_config=${bundleShortVersion}.${bundleVersion}
echo "发送电子邮件"
sendmail -t <
To:
Cc:
Subject:ios new version Release
ipa version : $build_config
ipa type : $profile_type
download instructions from wiki:
xxxxxxx
download address:
pgyer  : xxxx
fir    : xxxxx
安装密码: xxxxx
更新详情: $commit_msg
EOF
echo "发送电子邮件完成"
  • FixCodeSignInhouse.sh 文件内容
#!/bin/bash
appName="appname"
mobileprovision_uuid_Inhouse="xxxxxxxx-xxxx-4ccb-8b83-4b9b3377c69c"
mobileProvisionOutputName_Inhouse="xxxxx_Inhouse"
mobileCertificationOutputName_Inhouse="iPhone Distribution: xxxxxxxxxxx Co., Ltd"
project_path=$(pwd)
pro_path=${project_path}/$appName.'xcodeproj'
cd $pro_path
sed 's/PRODUCT_BUNDLE_IDENTIFIER.*/PRODUCT_BUNDLE_IDENTIFIER = com.roobo.domgyInhouse;/g' project.pbxproj > tmp
mv tmp project.pbxproj
cd $project_path
sed -i "" s/'ProvisioningStyle = Automatic;'/'ProvisioningStyle = Manual;'/g appname.xcodeproj/project.pbxproj
sed -i ""  s/'PROVISIONING_PROFILE = ".*";'/'PROVISIONING_PROFILE = "xxxxxxxx-xxxx-4ccb-8b83-4b9b3377c69c";'/g appname.xcodeproj/project.pbxproj
sed -i ""  s/'PROVISIONING_PROFILE_SPECIFIER = .*;'/'PROVISIONING_PROFILE_SPECIFIER = xxxxx_Inhouse;'/g appname.xcodeproj/project.pbxproj
sed -i ""  s/'CODE_SIGN_IDENTITY = ".*";'/'CODE_SIGN_IDENTITY = "iPhone Distribution: xxxxxxxxxx Technology Co., Ltd";'/g appname.xcodeproj/project.pbxproj
sed -i ""  s/'"CODE_SIGN_IDENTITY\[sdk=iphoneos\*\]" = ".*";'/'"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution: xxxxxxxxx Co., Ltd";'/g appname.xcodeproj/project.pbxproj

你可能感兴趣的:(iOS - 基于 Xcode8的自动发版脚本)