From ef7ba4aff44f55c41da93812dfee37d8fc59fc3d Mon Sep 17 00:00:00 2001 From: Xin Wang Date: Fri, 4 Jul 2025 17:55:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9compile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- compile.sh | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/compile.sh b/compile.sh index 035b345..b853d49 100755 --- a/compile.sh +++ b/compile.sh @@ -1,20 +1,22 @@ #!/bin/bash # 修改项目名称 -PROJECT_NAME="video-flow-frontend" +PROJECT_NAME="video-flow-pre-frontend" # 设置日志文件路径 LOGFILE="build_and_copy.log" +BRANCH_NAME="pre" + # 记录开始时间 echo "Build process started at $(date)" | tee $LOGFILE # 获取当前分支名 current_branch=$(git rev-parse --abbrev-ref HEAD) - -# 打包之前,需要检查是否在 dev 分支,工作区是否干净,是否和远程分支一致 -if [ "$(git branch --show-current)" != "dev" ]; then - echo "当前分支不是 dev 分支" + +# 打包之前,需要检查是否在 pre 分支,工作区是否干净,是否和远程分支一致 +if [ "$(git branch --show-current)" != "$BRANCH_NAME" ]; then + echo "当前分支不是 pre 分支" exit 1 fi @@ -24,27 +26,17 @@ if [ -n "$(git status --porcelain)" ]; then exit 1 fi -# 获取最新的远程分支信息 -echo "正在获取最新的远程分支信息..." | tee -a $LOGFILE -git fetch movie-flow - # 检查远程分支是否和本地分支一致 -local_commit=$(git rev-parse HEAD) -remote_commit=$(git rev-parse movie-flow/dev) -if [ "$local_commit" != "$remote_commit" ]; then - echo "本地分支和远程分支不一致" | tee -a $LOGFILE - echo "本地分支: $local_commit" | tee -a $LOGFILE - echo "远程分支: $remote_commit" | tee -a $LOGFILE - echo "请运行以下命令之一来解决:" | tee -a $LOGFILE - echo " git pull movie-flow dev # 如果远程有新提交" | tee -a $LOGFILE - echo " git push movie-flow dev # 如果本地有新提交" | tee -a $LOGFILE +if [ "$(git rev-parse HEAD)" != "$(git rev-parse origin/$BRANCH_NAME)" ]; then + echo "本地分支和远程分支不一致" exit 1 fi + # 检查当前分支并运行相应的 npm 命令 -if [ "$current_branch" = "dev" ]; then +if [ "$current_branch" = "$BRANCH_NAME" ]; then echo "On dev branch, building project..." | tee -a $LOGFILE - PROFILE_ENV=dev + PROFILE_ENV=$BRANCH_NAME # 安装依赖并构建 yarn install