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
|
|
|
|
|
2024-07-31 16:37:34 +08:00
|
|
|
# 获取项目相关参数
|
|
|
|
if [ -f ./project_env.sh ]; then
|
|
|
|
source ./project_env.sh
|
|
|
|
echo "found the project_env file"
|
|
|
|
fi
|
|
|
|
|
2024-06-12 15:01:54 +08:00
|
|
|
VERSION="$1"
|
|
|
|
PLATFORM="$2"
|
|
|
|
WORKSPACE="$3"
|
2024-07-31 16:37:34 +08:00
|
|
|
NEWASSETS="$4"
|
2024-06-12 15:01:54 +08:00
|
|
|
|
2024-07-31 16:37:34 +08:00
|
|
|
REMOTE_PATH="/$REMOTE_UPLOAD_PATH/$WORKSPACE/$PLATFORM/$VERSION"
|
2024-06-12 15:01:54 +08:00
|
|
|
|
|
|
|
echo "remote path : $REMOTE_PATH"
|
|
|
|
|
|
|
|
# Set remote Build Path (local) (modify as needed)
|
2024-07-31 16:37:34 +08:00
|
|
|
BUILD_PATH="../../$PROJECT_NAME/ServerData/$PLATFORM/"
|
2024-06-12 15:01:54 +08:00
|
|
|
|
2024-07-31 16:37:34 +08:00
|
|
|
# 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
|
2024-06-12 15:01:54 +08:00
|
|
|
|
|
|
|
tar -czvf upload.tgz -C "$BUILD_PATH" .
|
|
|
|
ssh "$REMOTE_USER@$REMOTE_HOST" "mkdir -p $REMOTE_PATH"
|
|
|
|
scp upload.tgz "$REMOTE_USER@$REMOTE_HOST:$REMOTE_PATH"
|
|
|
|
ssh "$REMOTE_USER@$REMOTE_HOST" "cd $REMOTE_PATH;tar -xzvf upload.tgz;rm -rf upload.tgz"
|
|
|
|
|
|
|
|
upload_result=$?
|
|
|
|
|
|
|
|
if [ $upload_result -eq 0 ]; then
|
|
|
|
echo "Build uploaded to remote server successfully."
|
|
|
|
|
|
|
|
else
|
|
|
|
sh to_inner_wechat_robot.sh "【$PLATFORM】【$VERSION】【$PROFILE】Failed to upload build to remote server! "
|
|
|
|
echo "Failed to upload build to remote server."
|
|
|
|
fi
|
|
|
|
|
|
|
|
rm -rf upload.tgz
|
|
|
|
|