fix(release): use absolute paths and add error handling in release scripts
- Add error handling to `cd` command to exit with a clear message if the worktree directory is missing - Change relative `cp` source/destination paths to absolute paths prefixed with `$WORKTREE_PATH`, ensuring files are always read from and written to the intended worktree regardless of the current working directory - Update inline comments to reflect the new absolute-path behavior in both `pre_release_web.sh` and `release_web.sh`
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
WORKTREE_PATH="/Users/chase/Documents/cozsweet-frontend-nextjs.worktrees/cozsweet-nextjs-main"
|
||||
|
||||
echo "=== 进入 main 分支 worktree ==="
|
||||
cd "$WORKTREE_PATH"
|
||||
cd "$WORKTREE_PATH" || { echo "错误: 无法进入 $WORKTREE_PATH"; exit 1; }
|
||||
|
||||
echo "=== 检查当前分支 ==="
|
||||
git branch --show-current
|
||||
@@ -12,15 +12,15 @@ git branch --show-current
|
||||
echo "=== 合并 dev 分支 ==="
|
||||
git merge dev
|
||||
|
||||
# 复制生产环境图标(source: icons/production → dest: public/)
|
||||
# 复制生产环境图标(source: $WORKTREE_PATH/icons/production → dest: $WORKTREE_PATH/public/)
|
||||
echo "=== 复制生产环境图标(icons/production → public/) ==="
|
||||
cp -f icons/production/favicon.ico public/favicon.ico
|
||||
cp -f icons/production/icons/Icon-192.png public/images/icons/Icon-192.png
|
||||
cp -f icons/production/icons/Icon-512.png public/images/icons/Icon-512.png
|
||||
cp -f "$WORKTREE_PATH/icons/production/favicon.ico" "$WORKTREE_PATH/public/favicon.ico"
|
||||
cp -f "$WORKTREE_PATH/icons/production/icons/Icon-192.png" "$WORKTREE_PATH/public/images/icons/Icon-192.png"
|
||||
cp -f "$WORKTREE_PATH/icons/production/icons/Icon-512.png" "$WORKTREE_PATH/public/images/icons/Icon-512.png"
|
||||
|
||||
# 准备生产环境变量(env-example/.env.production.example → .env.local,供 purge_cdn_cache 读 CDN 凭据)
|
||||
# 准备生产环境变量($WORKTREE_PATH/env-example/.env.production.example → $WORKTREE_PATH/.env.local)
|
||||
echo "=== 准备生产环境变量(env-example/.env.production.example → .env.local) ==="
|
||||
cp -f env-example/.env.production.example .env.local
|
||||
cp -f "$WORKTREE_PATH/env-example/.env.production.example" "$WORKTREE_PATH/.env.local"
|
||||
|
||||
echo "=== 执行构建部署脚本 ==="
|
||||
./scripts/deploy/deploy_web.sh
|
||||
|
||||
Reference in New Issue
Block a user