You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

245 lines
10 KiB

1 month ago
#!/bin/bash
# shellcheck disable=SC2154
set -x
for i in "$@"; do
if [[ $i = *"="* ]]; then
eval "$i"
fi
done
cur_dir=$(cd $(dirname $0); pwd)
share_dir=$cur_dir/..
root_dir=/Volumes/ProjectDisk/www/arpg
if [[ "$uploadDir" != "" ]]; then
root_dir=$uploadDir
fi
www_dir=$root_dir/ios
unity_app="/Applications/Unity/Unity.app/Contents/MacOS/Unity"
build_graph="Assets/ZXToolkit/AssetGraph/Graph/BuildGraph.asset"
arpg_cli_dir=$share_dir/../pandora_cli_proj
arpg_pro_dir=$arpg_cli_dir/pandora
if [ "$publishChannel" == "" ]; then
publishChannel="ios_oversea"
fi
if [ "$isUsingNewAB" == "true" ]; then
build_graph="Assets/ZXToolkit/AssetGraph/Graph/BuildGraph_new.asset"
fi
buid_name=arpg_${publishChannel}_${version}_$(date "+%Y%m%d_%H%M%S")
output_dir=$share_dir/../build/ios
log_dir=$output_dir/../log/ios
###################### xcode build setting ##########################
plist_path=$share_dir/MacBuild/InternalExportOptions.plist
sign_profile_identity="bbd88fff-a466-4b9c-8470-bcb343882365"
code_sign_identity_str="Apple Development: 文凯 刘 (989ZP8BU2Z)"
bundle_identifier="com.herogame.ios.redtide2test"
develop_team="D5HXNDDEM4"
build_destination="generic/platform=iOS,name=Any iOS Device"
##################### xcode build setting ###########################
outpath=$output_dir
if [ ! -d "$output_dir" ]; then
mkdir "$output_dir"
else
rm -rf "$output_dir"
mkdir "$output_dir"
fi
if [ ! -d "$log_dir" ]; then
mkdir "$log_dir"
fi
cd "$arpg_cli_dir" || exit
# svn cleanup --remove-unversioned
# svn revert --depth=infinity .
# svn update
python "$arpg_cli_dir/../arpg_share_proj/MacBuild/build_generate_common.py" debug="$debug" version="$version" disableLog="$disableLog" versionIP="${versionIP}" gameIP="$gameIP" lang="$lang" maintenanceIP="$maintenanceIP" mode="$mode" publishChannel=$publishChannel
killall Unity
$unity_app -quit -batchmode -projectPath "$arpg_pro_dir" -logFile "$log_dir/$buid_name".log -executeMethod XAsset.Build.AssetBuildScript.RunBuild version="$version" channel="$channel" outpath="$outpath" development="$development" versionIP="$versionIP" lang="$lang" buildNumber="$buildNumber" rebuildBundle="$rebuildBundle" mode="$mode" target="$target" publishChannel=$publishChannel graph=$build_graph thinkingAnalyticsMode="$thinkingAnalyticsMode"
ret=$?
echo "build xcode project ret:${ret}"
if [ $ret != 0 ]; then
cat "$log_dir/$buid_name.log"
exit $ret
fi
# resources=$arpg_cli_dir/arpg/Assets/RawResources
# svn add $resources/*.meta --force
# svn commit $resources -m "builder commit"
ui="$arpg_cli_dir/arpg/Assets/RawResources/UI"
svn add "$ui"/*.meta --force
svn commit "$ui" -m "builder commit sprite tag"
ui2="$arpg_cli_dir/arpg/Assets/RawResources/UI2"
svn add "$ui2"/*.meta --force
svn commit "$ui2" -m "builder commit sprite tag"
cd "$outpath" || exit
echo "faselane xcode setting"
fastlane run update_code_signing_settings path:"./Unity-iPhone.xcodeproj" team_id:"$develop_team" bundle_identifier:"$bundle_identifier" code_sign_identity:"$code_sign_identity_str" profile_uuid:"$sign_profile_identity" targets:"Unity-iPhone" use_automatic_signing:false
ret=$?
if [ $ret != 0 ]; then
exit $ret
fi
echo "faselane setting success."
if [ "$buildType" == "内部测试包" ]; then
###################### 导出内部包 ##########################
echo "export internal dev ipa."
security unlock-keychain -p "123456" ~/Library/Keychains/login.keychain
echo "xcode build"
xcodebuild archive -project Unity-iPhone.xcodeproj -scheme Unity-iPhone platform=iOS -UseModernBuildSystem=YES -destination "$build_destination" -archivePath bin/Unity-iPhone.xcarchive
ret=$?
if [ $ret != 0 ]; then
exit $ret
fi
echo "xcode build success."
echo "export ipa."
xcodebuild -exportArchive -exportOptionsPlist "$plist_path" -archivePath bin/Unity-iPhone.xcarchive -exportPath bin/
ret=$?
if [ $ret != 0 ]; then
exit $ret
fi
echo "export ipa success."
# rm -rf *.ipa
scp "$outpath/bin/EternalEvolution.ipa" "$www_dir/internal/${buid_name}_internal.ipa"
if [ "$push_message" == "true" ]; then
curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=228f1071-048b-479a-b250-3d22f2b92425' \
-H 'Content-Type: application/json charset=UTF-8"' \
-d "{\"msgtype\":\"markdown\", \"markdown\":{\"content\":\"## iOS新版本\\n[${buid_name}_internal.ipa](http://192.168.1.245/arpg/ios/internal/${buid_name}_internal.ipa)\"}}"
fi
else
################### 导出强制开启Debug的内部包 ###################
debugOutpath="${output_dir}_debug"
env_file_path="$debugOutpath/Data/Raw/Lua/Const/Env.lua"
cp -r "$outpath" "$debugOutpath"
cd "$debugOutpath" || exit
cat>"$env_file_path"<<EOF
local Env={debug=true,disableLog=false}
return Env
EOF
echo "export debug internal dev ipa."
security unlock-keychain -p "123456" ~/Library/Keychains/login.keychain
echo "xcode build"
xcodebuild archive -project Unity-iPhone.xcodeproj -scheme Unity-iPhone platform=iOS -UseModernBuildSystem=YES -destination "$build_destination" -archivePath bin/Unity-iPhone.xcarchive
ret=$?
if [ $ret != 0 ]; then
exit $ret
fi
echo "xcode build success."
echo "export ipa."
xcodebuild -exportArchive -exportOptionsPlist "$plist_path" -archivePath bin/Unity-iPhone.xcarchive -exportPath bin/
ret=$?
if [ $ret != 0 ]; then
exit $ret
fi
echo "export ipa success."
# rm -rf *.ipa
scp "$debugOutpath/bin/EternalEvolution.ipa" "$www_dir/internal/${buid_name}_internal.ipa"
if [ "$push_message" == "true" ]; then
curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=228f1071-048b-479a-b250-3d22f2b92425' \
-H 'Content-Type: application/json charset=UTF-8"' \
-d "{\"msgtype\":\"markdown\", \"markdown\":{\"content\":\"## iOS新版本\\n[${buid_name}_internal.ipa](http://192.168.1.245/arpg/ios/internal/${buid_name}_internal.ipa)\"}}"
fi
fi
if [ "$buildType" == "英雄海外包" ] || [ "$buildType" == "英雄海外包+英雄美国包" ] ; then
###################### 导出海外渠道包 ##########################
echo "copy hero-oversea plist."
cp -f "$cur_dir/u2-oversea/AppKey.plist" "$outpath/AppKey.plist"
cp -f "$cur_dir/u2-oversea/GoogleService-Info.plist" "$outpath/GoogleService-Info.plist"
cp -f "$cur_dir/u2-oversea/HeroInfo.plist" "$outpath/HeroInfo.plist"
hero_config_dev=$cur_dir/u2-oversea/packConfig_dev.json
hero_config_dis=$cur_dir/u2-oversea/packConfig_dis.json
hero_dev_path=$output_dir/../hero_oversea_dev
hero_dis_path=$output_dir/../hero_oversea_dis
buid_name=arpg_ios_oversea_${version}_$(date "+%Y%m%d_%H%M%S")
echo "export hero-oversea dis ipa."
if [ ! -d "$hero_dis_path" ]; then
mkdir "$hero_dis_path"
else
rm -rf "$hero_dis_path"
mkdir "$hero_dis_path"
fi
hero-pack -config "$hero_config_dis"
scp "$hero_dis_path/EternalEvolution.ipa" "$www_dir/hero_dis/${buid_name}_dis.ipa"
if [ "$push_message" == "true" ]; then
curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=228f1071-048b-479a-b250-3d22f2b92425' \
-H 'Content-Type: application/json charset=UTF-8"' \
-d "{\"msgtype\":\"markdown\", \"markdown\":{\"content\":\"## iOS英雄正式包\\n[${buid_name}_dis.ipa](http://192.168.1.245/arpg/ios/hero_dis/${buid_name}_dis.ipa)\"}}"
fi
echo "export hero-oversea dev ipa."
if [ ! -d "$hero_dev_path" ]; then
mkdir "$hero_dev_path"
else
rm -rf "$hero_dev_path"
mkdir "$hero_dev_path"
fi
hero-pack -config "$hero_config_dev"
scp "$hero_dev_path/EternalEvolution.ipa" "$www_dir/hero_dev/${buid_name}_dev.ipa"
if [ "$push_message" == "true" ]; then
curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=228f1071-048b-479a-b250-3d22f2b92425' \
-H 'Content-Type: application/json charset=UTF-8"' \
-d "{\"msgtype\":\"markdown\", \"markdown\":{\"content\":\"## iOS英雄测试包\\n[${buid_name}_dev.ipa](http://192.168.1.245/arpg/ios/hero_dev/${buid_name}_dev.ipa)\"}}"
fi
fi
if [ "$buildType" == "英雄美国包" ] || [ "$buildType" == "英雄海外包+英雄美国包" ] ; then
###################### 导出美国渠道包 ##########################
echo "copy hero-usa plist."
cp -f "$cur_dir/u2-usa/AppKey.plist" "$outpath/AppKey.plist"
cp -f "$cur_dir/u2-usa/GoogleService-Info.plist" "$outpath/GoogleService-Info.plist"
cp -f "$cur_dir/u2-usa/HeroInfo.plist" "$outpath/HeroInfo.plist"
hero_config_dev=$cur_dir/u2-usa/packConfig_dev.json
hero_config_dis=$cur_dir/u2-usa/packConfig_dis.json
hero_dev_path=$output_dir/../hero_usa_dev
hero_dis_path=$output_dir/../hero_usa_dis
buid_name=arpg_ios_usa_${version}_$(date "+%Y%m%d_%H%M%S")
echo "export hero-usa dis ipa."
if [ ! -d "$hero_dis_path" ]; then
mkdir "$hero_dis_path"
else
rm -rf "$hero_dis_path"
mkdir "$hero_dis_path"
fi
hero-pack -config "$hero_config_dis"
scp "$hero_dis_path/EternalEvolution.ipa" "$www_dir/hero_dis/${buid_name}_dis.ipa"
if [ "$push_message" == "true" ]; then
curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=228f1071-048b-479a-b250-3d22f2b92425' \
-H 'Content-Type: application/json charset=UTF-8"' \
-d "{\"msgtype\":\"markdown\", \"markdown\":{\"content\":\"## iOS英雄正式包\\n[${buid_name}_dis.ipa](http://192.168.1.245/arpg/ios/hero_dis/${buid_name}_dis.ipa)\"}}"
fi
echo "export hero-usa dev ipa."
if [ ! -d "$hero_dev_path" ]; then
mkdir "$hero_dev_path"
else
rm -rf "$hero_dev_path"
mkdir "$hero_dev_path"
fi
hero-pack -config "$hero_config_dev"
scp "$hero_dev_path/EternalEvolution.ipa" "$www_dir/hero_dev/${buid_name}_dev.ipa"
if [ "$push_message" == "true" ]; then
curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=228f1071-048b-479a-b250-3d22f2b92425' \
-H 'Content-Type: application/json charset=UTF-8"' \
-d "{\"msgtype\":\"markdown\", \"markdown\":{\"content\":\"## iOS英雄测试包\\n[${buid_name}_dev.ipa](http://192.168.1.245/arpg/ios/hero_dev/${buid_name}_dev.ipa)\"}}"
fi
fi
echo "build finish success."