forked from arloor/rust_http_proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease.sh
More file actions
45 lines (34 loc) · 1015 Bytes
/
release.sh
File metadata and controls
45 lines (34 loc) · 1015 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
set -e # 任何命令失败时退出
# 保存当前分支
ORIGINAL_BRANCH=$(git branch --show-current)
# 错误处理函数
error_handler() {
echo "❌ 发生错误,正在回退..."
cleanup
}
cleanup() {
# 尝试回到原始分支
git checkout "$ORIGINAL_BRANCH" 2>/dev/null || true
# 如果有stash,尝试恢复
if git stash list | grep -q "stash@{0}"; then
git stash pop 2>/dev/null || echo "⚠️ 无法恢复stash,请手动执行 git stash pop"
fi
exit 1
}
# 设置错误时的trap
trap error_handler ERR
echo "📥 正在拉取远程更新..."
git fetch -p
echo "💾 正在保存本地更改..."
git stash
echo "🔀 正在切换到 release 分支..."
git checkout -b release||git checkout release
echo "🔄 正在 rebase master..."
git rebase master
echo "📤 正在推送到远程..."
git push -u origin release
echo "♻️ 正在恢复本地更改..."
git stash pop||true
echo "✅ 操作成功完成!恢复初始状态"
cleanup