Forest_Client/Tool/BuildTool/build.sh

109 lines
3.0 KiB
Bash
Raw Normal View History

2024-06-12 15:01:54 +08:00
##!/bin/bash
SHELL_DIR=$(dirname $0)
echo "change dir to $SHELL_DIR"
cd "$SHELL_DIR"
# Source the local environment
if [ -f ./local_env.sh ]; then
source ./local_env.sh
echo "found the local_env file"
fi
VERSION="$1"
PROFILE="$2"
ARTIFACT_URL="$3"
ENABLE_HOT_UPDATE="$4"
PLATFORM="$5"
CLEARCACHED="$6"
DEVELPOMENT_BUILD="$7"
CHANNEL="$8"
AAB="$9"
PROJECTNAME="WLGCZ"
echo "version="$VERSION", profile="$PROFILE", ARTIFACT_URL="$ARTIFACT_URL" , ENABLE_HOT_UPDATE="$ENABLE_HOT_UPDATE""
echo "PLATFORM="$PLATFORM", CLEARCACHED="$CLEARCACHED", DEVELPOMENT_BUILD = "$DEVELPOMENT_BUILD""
echo "AAB="$AAB""
# Set the build folder and name
BUILD_FOLDER_FROM_ASSET="../Builds/$PLATFORM/$VERSION" #相对assets路径
BUILD_FOLDER="../../Builds/$PLATFORM/$VERSION" #相对脚本路径
BUILD_NAME="AveryBuild"
APP_NAME="Avery"
EXECUTE_METHOD="BatchBuild.BuildContentAndPlayer"
LOG_FILE="$BUILD_FOLDER/build.log" # 相对脚本路径
EXECUTE_SETTING_METHOD="BatchBuild.ApplyPlayerSetting"
echo "Start apply setting ... ... "
"$UNITY_PATH" -quit -batchmode -projectPath "../../$PROJECTNAME" -executeMethod "$EXECUTE_SETTING_METHOD" \
-platform "$PLATFORM" \
-appVersion "$VERSION" \
-buildName "$BUILD_NAME" \
-profile "$PROFILE" \
-outpath "$BUILD_FOLDER_FROM_ASSET" \
-appName "$APP_NAME" \
-clearCached "$CLEARCACHED" \
-enableHotUpdate "$ENABLE_HOT_UPDATE" \
-developmentBuild "$DEVELPOMENT_BUILD" \
-channel "$CHANNEL" \
-aab "$AAB"
echo "build folder is: "$BUILD_FOLDER" , log is : "$LOG_FILE" , Start building ... ... "
"$UNITY_PATH" -quit -batchmode -projectPath "../../$PROJECTNAME" -executeMethod "$EXECUTE_METHOD" \
-platform "$PLATFORM" \
-appVersion "$VERSION" \
-buildName "$BUILD_NAME" \
-profile "$PROFILE" \
-outpath "$BUILD_FOLDER_FROM_ASSET" \
-appName "$APP_NAME" \
-clearCached "$CLEARCACHED" \
-enableHotUpdate "$ENABLE_HOT_UPDATE" \
-developmentBuild "$DEVELPOMENT_BUILD" \
-channel "$CHANNEL" \
-aab "$AAB" \
-logFile "$LOG_FILE"
build_result=$?
if [ $build_result -ne 0 ]; then
echo "【"$PLATFORM"】【"$VERSION"】Unity build failed. Check the log for details."
sh to_inner_wechat_robot.sh "$PLATFORM】【$VERSION】【$PROFILE】Failed to build"
sh collect_and_send_error.sh $LOG_FILE
exit 1
else
echo "【"$PLATFORM"】【"$VERSION"】Unity build successful."
fi
# upload remote resource to server
#sh upload_to_server.sh "$PLATFORM" "$VERSION"
SYMBOL_FILE="$BUILD_FOLDER/$BUILD_NAME-$VERSION-v1-IL2CPP.symbols" # 相对脚本路径
unzip "$SYMBOL_FILE".zip -d "$SYMBOL_FILE"
java -jar crashSightSymbolTool.jar \
-i "$BUILD_FOLDER" \
-version "$VERSION" \
-p aos \
-m win \
-u -url https://api.crashsight.qq.com/openapi/file/upload/symbol \
-id 669a94ce69 \
-key d9412717-2416-4270-b8bc-f7a0805f988f
upload_result=$?
if [ $upload_result -eq 0 ]; then
echo "Symbol table upload CrashSight successfully!"
else
echo "Symbol table upload CrashSight failed"
fi
rm -rf "$SYMBOL_FILE"