【打包】脚本整理

Android_release
zhangaotian 2024-07-31 16:37:34 +08:00
parent 9ca7102256
commit ac84e5b5fc
12 changed files with 176 additions and 56 deletions

37
Tool/BuildTool/blame.sh Normal file
View File

@ -0,0 +1,37 @@
#!/bin/bash
script_directory="$(cd "$(dirname "$0")" && pwd)"
#if [ "$#" -eq 0 ]; then
# echo "Usage: $0 <text>"
# exit 1
#fi
text="$1"
#测试用
#text="[Licensing::Client] Error: HandshakeResponse reported an error:
# Assets/Code/Scripts/Gameplay/UI/Shop/UI_ShopController.cs(94,77): error CS0117: 'SDKManager.SdkName' does not contain a definition for 'IAP'
# Assets/Code/Scripts/Gameplay/UI/Shop/UI_ShopController.cs(94,85): error CS0246: The type or namespace name 'IBuyServices' could not be found (are you missing a using directive or an assembly reference?)
# Assets/Code/Scripts/Gameplay/UI/Shop/UI_ShopController.cs(94,77): error CS0117: 'SDKManager.SdkName' does not contain a definition for 'IAP'
# Assets/Code/Scripts/Gameplay/UI/Shop/UI_ShopController.cs(94,85): error CS0246: The type or namespace name 'IBuyServices' could not be found (are you missing a using directive or an assembly reference?)
# Assets/Code/Scripts/Gameplay/UI/Shop/UI_ShopController.cs(94,77): error CS0117: 'SDKManager.SdkName' does not contain a definition for 'IAP'
# Assets/Code/Scripts/Gameplay/UI/Shop/UI_ShopController.cs(94,85): error CS0246: The type or namespace name 'IBuyServices' could not be found (are you missing a using directive or an assembly reference?)
# Scripts have compiler errors."
echo "blame start $text"
if [[ $text =~ (Assets\/[^:\(]+)\/([^:\(]+\.cs)[:\(]([0-9]+) ]]; then
path="${BASH_REMATCH[1]}"
fileName="${BASH_REMATCH[2]}"
line_number="${BASH_REMATCH[3]}"
echo "blame path:$path"
echo "blame file: $fileName"
echo "blame line_num: $line_number"
cd ../../ProjectNLD/"$path" || exit
#git blame -L "$line_number" "$fileName"
last_commit_author=$(git blame -L "$line_number" "$fileName" | sed 's/^[^(]*(\([^[:space:]]*\).*/\1/' | head -n 1)
message="fileName:$path/$fileName \r\n line_num:$line_number \r\n author:${last_commit_author}"
echo "message:$message"
cd "$script_directory" || exit
sh to_inner_wechat_robot.sh "$message"
fi

View File

@ -9,6 +9,12 @@ if [ -f ./local_env.sh ]; then
echo "found the local_env file"
fi
# 获取项目相关参数
if [ -f ./project_env.sh ]; then
source ./project_env.sh
echo "found the project_env file"
fi
VERSION="$1"
PROFILE="$2"
ARTIFACT_URL="$3"
@ -18,20 +24,17 @@ CLEARCACHED="$6"
DEVELPOMENT_BUILD="$7"
CHANNEL="$8"
AAB="$9"
PROJECTNAME="Forest"
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""
echo "version="$VERSION", profile="$PROFILE", PLATFORM="$PLATFORM""
echo "ARTIFACT_URL="$ARTIFACT_URL", ENABLE_HOT_UPDATE="$ENABLE_HOT_UPDATE""
echo "CLEARCACHED="$CLEARCACHED", DEVELPOMENT_BUILD = "$DEVELPOMENT_BUILD""
echo "AAB="$AAB", PROJECT_NAME="$PROJECT_NAME""
echo "BUILD_NAME="$BUILD_NAME", APP_NAME="$APP_NAME""
# Set the build folder and name
BUILD_FOLDER_FROM_ASSET="../Builds/$PLATFORM/$VERSION" #相对assets路径
BUILD_FOLDER="../../Builds/$PLATFORM/$VERSION" #相对脚本路径
BUILD_NAME="ForestBuild"
APP_NAME="Forest Journey"
EXECUTE_METHOD="BatchBuild.BuildContentAndPlayer"
LOG_FILE="$BUILD_FOLDER/build.log" # 相对脚本路径
@ -40,7 +43,7 @@ EXECUTE_SETTING_METHOD="BatchBuild.ApplyPlayerSetting"
echo "Start apply setting ... ... "
"$UNITY_PATH" -quit -batchmode -projectPath "../../$PROJECTNAME" -executeMethod "$EXECUTE_SETTING_METHOD" \
"$UNITY_PATH" -quit -batchmode -projectPath "../../$PROJECT_NAME" -executeMethod "$EXECUTE_SETTING_METHOD" \
-platform "$PLATFORM" \
-appVersion "$VERSION" \
-buildName "$BUILD_NAME" \
@ -55,7 +58,7 @@ echo "Start apply setting ... ... "
echo "build folder is: "$BUILD_FOLDER" , log is : "$LOG_FILE" , Start building ... ... "
"$UNITY_PATH" -quit -batchmode -projectPath "../../$PROJECTNAME" -executeMethod "$EXECUTE_METHOD" \
"$UNITY_PATH" -quit -batchmode -projectPath "../../$PROJECT_NAME" -executeMethod "$EXECUTE_METHOD" \
-platform "$PLATFORM" \
-appVersion "$VERSION" \
-buildName "$BUILD_NAME" \
@ -72,12 +75,12 @@ echo "build folder is: "$BUILD_FOLDER" , log is : "$LOG_FILE" , Start building .
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"
echo "$APP_NAME】【"$PLATFORM"】【"$VERSION"】 build failed. Check the log for details."
sh to_inner_wechat_robot.sh "$APP_NAME】【$PLATFORM】【$VERSION】【$PROFILE】Failed to build"
sh collect_and_send_error.sh $LOG_FILE
exit 1
else
echo "【"$PLATFORM"】【"$VERSION"】Unity build successful."
echo "$APP_NAME】【"$PLATFORM"】【"$VERSION"】Unity build successful."
fi
# upload remote resource to server

View File

@ -5,13 +5,17 @@ SHELL_DIR=$(dirname $0)
echo "change dir to $SHELL_DIR"
cd "$SHELL_DIR"
# 获取项目相关参数
if [ -f ./project_env.sh ]; then
source ./project_env.sh
echo "found the project_env file"
fi
PROJECT_NAME="$1"
SCHEME_NAME="$2"
PLATFORM="$3"
VERSION="$4"
# Define variables
BUILD_NAME="AveryBuild"
PROJECT_PATH="../../Builds/$PLATFORM/$VERSION/$BUILD_NAME/"
#PROJECT_NAME="Unity-iPhone" # Replace with your Xcode project name (without the .xcodeproj extension)
#SCHEME_NAME="Unity-iPhone" # Replace with your Xcode scheme
@ -40,9 +44,6 @@ xcodebuild -list -project $PROJECT_NAME.xcodeproj
echo "clean..."
xcodebuild clean
# Build the Xcode project and create an archive
echo "Building Xcode project..."
xcodebuild archive -project $PROJECT_NAME.xcodeproj -scheme $SCHEME_NAME -archivePath $OUTPUT_DIRECTORY/$PROJECT_NAME.xcarchive
@ -56,4 +57,4 @@ echo "Cleaning up temporary archive..."
rm -rf $OUTPUT_DIRECTORY/$PROJECT_NAME.xcarchive
# The script is now complete.
echo "Build process completed. IPA file is available at: $OUTPUT_DIRECTORY/YourProject.ipa"
echo "Build process completed. IPA file is available at: $OUTPUT_DIRECTORY/$BUILD_NAME.ipa"

View File

@ -5,16 +5,24 @@ SHELL_DIR=$(dirname $0)
echo "change dir to $SHELL_DIR"
cd "$SHELL_DIR"
if [ -f ./local_env.sh ]; then
source ./local_env.sh
echo "found the local_env file"
fi
# 获取项目相关参数
if [ -f ./project_env.sh ]; then
source ./project_env.sh
echo "found the project_env file"
fi
PROJECT_NAME="$1"
SCHEME_NAME="$2"
PLATFORM="$3"
VERSION="$4"
# Define variables
BUILD_NAME="ForestBuild"
PROJECT_PATH="../../Builds/$PLATFORM/$VERSION/$BUILD_NAME/"
#PROJECT_NAME="Unity-iPhone" # Replace with your Xcode project name (without the .xcodeproj extension)
#SCHEME_NAME="Unity-iPhone" # Replace with your Xcode scheme
OUTPUT_DIRECTORY="../" # Replace with the desired output directory for the IPA file
@ -30,9 +38,8 @@ EXPORT_OPTIONS_FILE="./exportOptions.plist"
PODFILE="./Podfile"
PODFILE_LOCK="./Podfile.lock"
#Specify the full path to the pod command (modify as needed)
POD_PATH="/Users/mayuanzheng/.gem/ruby/3.0.0/bin/pod"
#来自打包机 pod路径
#POD_PATH="/Users/mayuanzheng/.gem/ruby/3.0.0/bin/pod"
# Copy the file
echo "copy export options to $PROJECT_PATH"
@ -75,4 +82,4 @@ echo "Cleaning up temporary archive..."
rm -rf $OUTPUT_DIRECTORY/$PROJECT_NAME.xcarchive
# The script is now complete.
echo "Build process completed. IPA file is available at: $OUTPUT_DIRECTORY/YourProject.ipa"
echo "Build process completed. IPA file is available at: $OUTPUT_DIRECTORY/$BUILD_NAME.ipa"

View File

@ -1,16 +1,27 @@
#!/bin/bash
# Check if a filename is provided as an argument
#Check if a filename is provided as an argument
if [ "$#" -eq 0 ]; then
echo "Usage: $0 <filename>"
exit 1
fi
echo"$0"
# Get the filename from the command line argument
filename="$1"
exception=$(grep -A 12 "\[Build Exception\]:" "$filename")
# Use grep to search for lines containing the word "error"
result=$(grep "error" "$filename")
error=$(grep "error" "$filename")
echo "exception: $exception"
echo "error: $error"
# Pass the result to another script
sh to_inner_wechat_robot.sh "$result"
sh to_inner_wechat_robot.sh "$exception"
sh blame.sh "$exception"
sh to_inner_wechat_robot.sh "$error"
sh blame.sh "$error"

View File

@ -0,0 +1,28 @@
#项目相关参数
# 打包文件名
BUILD_NAME="ForestBuild"
# App 名字
APP_NAME="Forest Journey"
# 项目名称
PROJECT_NAME="Forest"
# 服务器管理员
REMOTE_USER="root"
# 服务器地址
REMOTE_HOST="132.232.113.98"
# 服务器上传资源路径
#REMOTE_UPLOAD_PATH=""
# 内部机器人地址
INNER_ROBOT="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=3c92758c-1128-4931-ac8d-f19669d7befe"
# 外部机器人地址 - PHXH
OUTER_ROBOT_PHXH="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=08abd6b7-67be-421b-8f9b-9bc1b2c71150"
# 外部机器人地址 - NLD委员会
OUTER_ROBOT_NLD="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=cc0e1316-dd10-4845-b067-5693f2385f66"

8
Tool/BuildTool/to_inner_wechat_robot.sh Normal file → Executable file
View File

@ -3,6 +3,12 @@ SHELL_DIR=$(dirname $0)
echo "change dir to $SHELL_DIR"
cd "$SHELL_DIR"
# 获取项目相关参数
if [ -f ./project_env.sh ]; then
source ./project_env.sh
echo "found the project_env file"
fi
# Check if exactly one arguments are provided
if [ $# -ne 1 ]; then
echo "Usage: $0 <message>"
@ -13,4 +19,4 @@ fi
MSG_TEXT="$1"
echo "$MSG_TEXT"
sh to_wechat_robot.sh "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=3c92758c-1128-4931-ac8d-f19669d7befe" "@all" "$MSG_TEXT"
sh to_wechat_robot.sh "$INNER_ROBOT" "@all" "$MSG_TEXT"

View File

@ -3,6 +3,12 @@ SHELL_DIR=$(dirname $0)
echo "change dir to $SHELL_DIR"
cd "$SHELL_DIR"
# 获取项目相关参数
if [ -f ./project_env.sh ]; then
source ./project_env.sh
echo "found the project_env file"
fi
# Check if exactly one arguments are provided
if [ $# -ne 1 ]; then
echo "Usage: $0 <message>"
@ -14,6 +20,6 @@ MSG_TEXT="$1"
echo "$MSG_TEXT"
# PHXH
sh to_wechat_robot.sh "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=08abd6b7-67be-421b-8f9b-9bc1b2c71150" "@all" "$MSG_TEXT"
sh to_wechat_robot.sh "$OUTER_ROBOT_PHXH" "@all" "$MSG_TEXT"
# NLD委员会
sh to_wechat_robot.sh "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=cc0e1316-dd10-4845-b067-5693f2385f66" "@all" "$MSG_TEXT"
sh to_wechat_robot.sh "$OUTER_ROBOT_NLD" "@all" "$MSG_TEXT"

10
Tool/BuildTool/update_build_resource_debug.sh Normal file → Executable file
View File

@ -9,6 +9,12 @@ if [ -f ./local_env.sh ]; then
echo "found the local_env file"
fi
# 获取项目相关参数
if [ -f ./project_env.sh ]; then
source ./project_env.sh
echo "found the project_env file"
fi
VERSION="$1"
PLATFORM="$2"
PROFILE="$3"
@ -27,9 +33,10 @@ LOG_FILE="$BUILD_FOLDER/UpdatePreviousBuild.log" #相对脚本路径
echo "Start update previous building ... ..."
"$UNITY_PATH" -quit -batchmode -projectPath "../../ProjectNLD" -executeMethod "$EXECUTE_METHOD" \
"$UNITY_PATH" -quit -batchmode -projectPath "../../$PROJECT_NAME" -executeMethod "$EXECUTE_METHOD" \
-platform "$PLATFORM" \
-profile "$PROFILE" \
-appVersion "$VERSION" \
-clearCached "$CLEARCACHED" \
-channel "$CHANNEL" \
-enableHotUpdate "$ENABLE_HOT_UPDATE" \
@ -40,6 +47,7 @@ build_result=$?
if [ $build_result -ne 0 ]; then
echo "Update build failed. Check the log for details."
sh to_inner_wechat_robot.sh "$PLATFORM】【$VERSION】【$PROFILE】Failed to Update a previous build Addressable, Check the log for details:$ARTIFACT_URL"
sh collect_and_send_error.sh $LOG_FILE
exit 1
else
echo " Update a previous build successful! !"

View File

@ -2,22 +2,26 @@ SHELL_DIR=$(dirname $0)
echo "change dir to $SHELL_DIR"
cd "$SHELL_DIR"
# Set remote server details (modify as needed)
REMOTE_USER="root"
REMOTE_HOST="132.232.113.98"
# 获取项目相关参数
if [ -f ./project_env.sh ]; then
source ./project_env.sh
echo "found the project_env file"
fi
VERSION="$1"
PLATFORM="$2"
WORKSPACE="$3"
APP_NAME="MyUnityBuild.apk"
APK_NAME="$BUILD_NAME.apk"
REMOTE_PATH="/var/www/html/nld/$PLATFORM/$VERSION/"
REMOTE_PATH="/$REMOTE_UPLOAD_PATH/$WORKSPACE/$PLATFORM/$VERSION/"
echo "upload folder is: ${REMOTE_PATH}"
ssh "$REMOTE_USER@$REMOTE_HOST" "mkdir -p $REMOTE_PATH"
cd "../../Builds/$PLATFORM/$VERSION/"
scp "${APP_NAME}" "$REMOTE_USER@$REMOTE_HOST:$REMOTE_PATH"
scp "${APK_NAME}" "$REMOTE_USER@$REMOTE_HOST:$REMOTE_PATH"
upload_result=$?
@ -27,4 +31,4 @@ if [ $upload_result -eq 0 ]; then
else
echo "Failed to upload apk to remote server."
fi
fi

View File

@ -2,16 +2,20 @@ SHELL_DIR=$(dirname $0)
echo "change dir to $SHELL_DIR"
cd "$SHELL_DIR"
# Set remote server details (modify as needed)
REMOTE_USER="root"
REMOTE_HOST="132.232.113.98"
# 获取项目相关参数
if [ -f ./project_env.sh ]; then
source ./project_env.sh
echo "found the project_env file"
fi
VERSION="$1"
PLATFORM="$2"
WORKSPACE="$3"
REMOTE_PATH="/var/www/html/nld/$PLATFORM/$VERSION/"
REMOTE_PATH="$REMOTE_UPLOAD_PATH/$WORKSPACE/$PLATFORM/$VERSION/"
echo "upload folder is: ${REMOTE_PATH}"
APP_NAME="MyUnityApp.ipa"
IAP_NAME="$BUILD_NAME.ipa"
ssh "$REMOTE_USER@$REMOTE_HOST" "mkdir -p $REMOTE_PATH"
@ -19,7 +23,7 @@ scp nld_self_host_ipa.plist "$REMOTE_USER@$REMOTE_HOST:$REMOTE_PATH"
cd "../../Builds/$PLATFORM/$VERSION/"
scp "${APP_NAME}" "$REMOTE_USER@$REMOTE_HOST:$REMOTE_PATH"
scp "${IAP_NAME}" "$REMOTE_USER@$REMOTE_HOST:$REMOTE_PATH"
upload_result=$?
@ -29,4 +33,4 @@ if [ $upload_result -eq 0 ]; then
else
echo "Failed to upload ipa to remote server."
fi
fi

21
Tool/BuildTool/upload_to_server.sh Normal file → Executable file
View File

@ -9,23 +9,28 @@ if [ -f ./local_env.sh ]; then
echo "found the local_env file"
fi
# 获取项目相关参数
if [ -f ./project_env.sh ]; then
source ./project_env.sh
echo "found the project_env file"
fi
VERSION="$1"
PLATFORM="$2"
WORKSPACE="$3"
NEWASSETS="$4"
# Set remote server details (modify as needed)
REMOTE_USER="root"
REMOTE_HOST="132.232.113.98"
REMOTE_PATH="/var/www/html/nld/$WORKSPACE/$PLATFORM/$VERSION"
REMOTE_PATH="/$REMOTE_UPLOAD_PATH/$WORKSPACE/$PLATFORM/$VERSION"
echo "remote path : $REMOTE_PATH"
# Set remote Build Path (local) (modify as needed)
BUILD_PATH="../../ProjectNLD/ServerData/$PLATFORM/"
# Set the URL where you want to send the message
NOTE_URL="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=3c92758c-1128-4931-ac8d-f19669d7befe"
BUILD_PATH="../../$PROJECT_NAME/ServerData/$PLATFORM/"
# Check if NEWASSETS is true, if so, delete existing assets on remote server
#if [ "$NEWASSETS" = "true" ]; then
# ssh "$REMOTE_USER@$REMOTE_HOST" "rm -rf $REMOTE_PATH/*"
#fi
tar -czvf upload.tgz -C "$BUILD_PATH" .
ssh "$REMOTE_USER@$REMOTE_HOST" "mkdir -p $REMOTE_PATH"