ccman 2.1.2 → 2.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +308 -258
- package/README_en.md +444 -0
- package/dist/cli.js +213 -33
- package/dist/cli.js.map +1 -1
- package/dist/config/default-providers.d.ts +34 -0
- package/dist/config/default-providers.d.ts.map +1 -0
- package/dist/config/default-providers.js +96 -0
- package/dist/config/default-providers.js.map +1 -0
- package/dist/config/static-env.d.ts +1 -1
- package/dist/config/static-env.js +1 -1
- package/dist/core/ClaudeConfigManager.d.ts +5 -1
- package/dist/core/ClaudeConfigManager.d.ts.map +1 -1
- package/dist/core/ClaudeConfigManager.js +19 -3
- package/dist/core/ClaudeConfigManager.js.map +1 -1
- package/dist/providers/ProviderManager.d.ts.map +1 -1
- package/dist/providers/ProviderManager.js +7 -8
- package/dist/providers/ProviderManager.js.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +24 -3
- package/.editorconfig +0 -15
- package/.env.development +0 -3
- package/.env.production +0 -3
- package/.eslintrc.js +0 -28
- package/.github/workflows/release.yml +0 -99
- package/.prettierrc +0 -10
- package/CLAUDE.md +0 -276
- package/README_zh.md +0 -394
- package/dev-test.sh +0 -40
- package/docs/npm-publish-guide.md +0 -71
- package/docs/release-guide.md +0 -144
- package/docs/scripts-guide.md +0 -221
- package/docs/version-management.md +0 -64
- package/jest.config.js +0 -22
- package/release-temp/README.md +0 -394
- package/release-temp/package.json +0 -61
- package/scripts/build-env.js +0 -75
- package/scripts/modules/check-uncommitted.sh +0 -109
- package/scripts/modules/create-tag.sh +0 -279
- package/scripts/modules/monitor-release.sh +0 -296
- package/scripts/modules/version-bump.sh +0 -262
- package/scripts/publish-local.sh +0 -91
- package/scripts/quick-release.sh +0 -100
- package/scripts/release.sh +0 -430
- package/scripts/smart-release-v3.sh +0 -283
- package/scripts/smart-release.sh +0 -322
- package/src/cli.ts +0 -598
- package/src/commands/lang.ts +0 -105
- package/src/core/CCMConfigManager.ts +0 -259
- package/src/core/ClaudeConfigManager.ts +0 -123
- package/src/i18n/LanguageManager.ts +0 -169
- package/src/i18n/messages.ts +0 -233
- package/src/index.ts +0 -4
- package/src/providers/ProviderManager.ts +0 -414
- package/src/types/index.ts +0 -100
- package/src/utils/env-config.ts +0 -53
- package/src/utils/version.ts +0 -16
- package/tsconfig.json +0 -25
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# CCM 智能发布脚本 v3.0 (模块化重构版)
|
|
4
|
-
# 功能: 串联四个独立模块实现完整的智能发布流程
|
|
5
|
-
|
|
6
|
-
set -e
|
|
7
|
-
|
|
8
|
-
# 颜色定义
|
|
9
|
-
GREEN='\033[0;32m'
|
|
10
|
-
YELLOW='\033[1;33m'
|
|
11
|
-
RED='\033[0;31m'
|
|
12
|
-
BLUE='\033[0;34m'
|
|
13
|
-
PURPLE='\033[0;35m'
|
|
14
|
-
NC='\033[0m'
|
|
15
|
-
|
|
16
|
-
print_success() { echo -e "${GREEN}✅ $1${NC}"; }
|
|
17
|
-
print_warning() { echo -e "${YELLOW}⚠️ $1${NC}"; }
|
|
18
|
-
print_error() { echo -e "${RED}❌ $1${NC}"; exit 1; }
|
|
19
|
-
print_info() { echo -e "${BLUE}ℹ️ $1${NC}"; }
|
|
20
|
-
print_step() { echo -e "${PURPLE}🔸 $1${NC}"; }
|
|
21
|
-
|
|
22
|
-
# 脚本路径配置
|
|
23
|
-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
24
|
-
MODULE_DIR="$SCRIPT_DIR/modules"
|
|
25
|
-
|
|
26
|
-
# 检查模块脚本是否存在
|
|
27
|
-
check_modules() {
|
|
28
|
-
local modules=(
|
|
29
|
-
"check-uncommitted.sh"
|
|
30
|
-
"version-bump.sh"
|
|
31
|
-
"create-tag.sh"
|
|
32
|
-
"monitor-release.sh"
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
for module in "${modules[@]}"; do
|
|
36
|
-
if [ ! -f "$MODULE_DIR/$module" ]; then
|
|
37
|
-
print_error "模块脚本不存在: $MODULE_DIR/$module"
|
|
38
|
-
fi
|
|
39
|
-
|
|
40
|
-
if [ ! -x "$MODULE_DIR/$module" ]; then
|
|
41
|
-
chmod +x "$MODULE_DIR/$module"
|
|
42
|
-
fi
|
|
43
|
-
done
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
# 显示帮助信息
|
|
47
|
-
show_help() {
|
|
48
|
-
echo "🚀 CCM 智能发布脚本 v3.0"
|
|
49
|
-
echo "========================="
|
|
50
|
-
echo ""
|
|
51
|
-
echo "用法: $0 [选项]"
|
|
52
|
-
echo ""
|
|
53
|
-
echo "选项:"
|
|
54
|
-
echo " --skip-version 跳过版本升级,直接使用当前版本"
|
|
55
|
-
echo " --version-type 指定版本类型 (patch|minor|major)"
|
|
56
|
-
echo " --no-monitor 跳过发布状态监控"
|
|
57
|
-
echo " -h, --help 显示此帮助信息"
|
|
58
|
-
echo ""
|
|
59
|
-
echo "示例:"
|
|
60
|
-
echo " $0 # 完整智能发布流程"
|
|
61
|
-
echo " $0 --skip-version # 跳过版本升级"
|
|
62
|
-
echo " $0 --version-type minor # 直接使用minor升级"
|
|
63
|
-
echo " $0 --no-monitor # 不监控发布状态"
|
|
64
|
-
echo ""
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
# 解析命令行参数
|
|
68
|
-
parse_arguments() {
|
|
69
|
-
SKIP_VERSION=false
|
|
70
|
-
VERSION_TYPE=""
|
|
71
|
-
NO_MONITOR=false
|
|
72
|
-
|
|
73
|
-
while [[ $# -gt 0 ]]; do
|
|
74
|
-
case $1 in
|
|
75
|
-
--skip-version)
|
|
76
|
-
SKIP_VERSION=true
|
|
77
|
-
shift
|
|
78
|
-
;;
|
|
79
|
-
--version-type)
|
|
80
|
-
VERSION_TYPE="$2"
|
|
81
|
-
shift 2
|
|
82
|
-
;;
|
|
83
|
-
--no-monitor)
|
|
84
|
-
NO_MONITOR=true
|
|
85
|
-
shift
|
|
86
|
-
;;
|
|
87
|
-
-h|--help)
|
|
88
|
-
show_help
|
|
89
|
-
exit 0
|
|
90
|
-
;;
|
|
91
|
-
*)
|
|
92
|
-
print_error "未知参数: $1"
|
|
93
|
-
;;
|
|
94
|
-
esac
|
|
95
|
-
done
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
# 步骤1: 检查未提交代码
|
|
99
|
-
step_check_uncommitted() {
|
|
100
|
-
print_step "步骤 1/4: 检查工作目录状态"
|
|
101
|
-
echo ""
|
|
102
|
-
|
|
103
|
-
# 调用模块脚本
|
|
104
|
-
source "$MODULE_DIR/check-uncommitted.sh"
|
|
105
|
-
check_uncommitted_changes
|
|
106
|
-
|
|
107
|
-
echo ""
|
|
108
|
-
print_success "步骤1完成: 工作目录状态正常"
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
# 步骤2: 版本升级
|
|
112
|
-
step_version_bump() {
|
|
113
|
-
print_step "步骤 2/4: 版本管理"
|
|
114
|
-
echo ""
|
|
115
|
-
|
|
116
|
-
if [ "$SKIP_VERSION" = true ]; then
|
|
117
|
-
print_info "跳过版本升级,使用当前版本"
|
|
118
|
-
local current_version=$(node -p "require('./package.json').version")
|
|
119
|
-
print_info "当前版本: v$current_version"
|
|
120
|
-
NEW_VERSION="$current_version"
|
|
121
|
-
else
|
|
122
|
-
print_info "启动版本升级流程..."
|
|
123
|
-
# 如果指定了版本类型,静默调用
|
|
124
|
-
if [ -n "$VERSION_TYPE" ]; then
|
|
125
|
-
# 使用source方式调用,然后直接调用静默函数
|
|
126
|
-
source "$MODULE_DIR/version-bump.sh"
|
|
127
|
-
NEW_VERSION=$(execute_version_bump_quiet "$VERSION_TYPE" "$(get_current_version)")
|
|
128
|
-
if [ -z "$NEW_VERSION" ]; then
|
|
129
|
-
print_error "版本升级失败"
|
|
130
|
-
fi
|
|
131
|
-
else
|
|
132
|
-
# 没有指定版本类型,调用交互模式
|
|
133
|
-
"$MODULE_DIR/version-bump.sh"
|
|
134
|
-
local version_result=$?
|
|
135
|
-
if [ $version_result -eq 0 ]; then
|
|
136
|
-
NEW_VERSION=$(node -p "require('./package.json').version")
|
|
137
|
-
else
|
|
138
|
-
print_error "版本升级失败"
|
|
139
|
-
fi
|
|
140
|
-
fi
|
|
141
|
-
print_success "版本升级成功: v$NEW_VERSION"
|
|
142
|
-
fi
|
|
143
|
-
|
|
144
|
-
echo ""
|
|
145
|
-
print_success "步骤2完成: 版本为 v$NEW_VERSION"
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
# 步骤3: 创建tag和提交
|
|
149
|
-
step_create_tag() {
|
|
150
|
-
print_step "步骤 3/4: 创建tag和提交"
|
|
151
|
-
echo ""
|
|
152
|
-
|
|
153
|
-
print_info "将为版本 v$NEW_VERSION 创建tag并提交..."
|
|
154
|
-
echo ""
|
|
155
|
-
|
|
156
|
-
# 静默调用tag创建模块,避免颜色代码泄露
|
|
157
|
-
TAG_NAME=$("$MODULE_DIR/create-tag.sh" --quiet)
|
|
158
|
-
if [ -z "$TAG_NAME" ]; then
|
|
159
|
-
print_error "tag创建失败"
|
|
160
|
-
fi
|
|
161
|
-
|
|
162
|
-
echo ""
|
|
163
|
-
print_success "步骤3完成: tag $TAG_NAME 已创建并推送"
|
|
164
|
-
print_info "GitHub Actions 已自动触发"
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
# 步骤4: 监控发布状态
|
|
168
|
-
step_monitor_release() {
|
|
169
|
-
print_step "步骤 4/4: 监控发布状态"
|
|
170
|
-
echo ""
|
|
171
|
-
|
|
172
|
-
if [ "$NO_MONITOR" = true ]; then
|
|
173
|
-
print_info "跳过发布状态监控"
|
|
174
|
-
print_info "请手动检查:"
|
|
175
|
-
echo " 🔗 GitHub Actions: https://github.com/2ue/ccm/actions"
|
|
176
|
-
echo " 🔗 NPM Package: https://www.npmjs.com/package/ccman"
|
|
177
|
-
echo " 🔗 GitHub Release: https://github.com/2ue/ccm/releases/tag/v$NEW_VERSION"
|
|
178
|
-
return 0
|
|
179
|
-
fi
|
|
180
|
-
|
|
181
|
-
# 给GitHub Actions一些时间启动
|
|
182
|
-
print_info "等待 GitHub Actions 启动... (10秒)"
|
|
183
|
-
sleep 10
|
|
184
|
-
|
|
185
|
-
# 直接执行监控模块
|
|
186
|
-
"$MODULE_DIR/monitor-release.sh"
|
|
187
|
-
local monitor_status=$?
|
|
188
|
-
|
|
189
|
-
echo ""
|
|
190
|
-
case $monitor_status in
|
|
191
|
-
0)
|
|
192
|
-
print_success "步骤4完成: 发布监控成功,所有组件已发布"
|
|
193
|
-
;;
|
|
194
|
-
1)
|
|
195
|
-
print_error "步骤4失败: 发布过程中出现错误"
|
|
196
|
-
;;
|
|
197
|
-
2)
|
|
198
|
-
print_warning "步骤4部分完成: 发布可能仍在进行中"
|
|
199
|
-
;;
|
|
200
|
-
*)
|
|
201
|
-
print_warning "步骤4完成: 发布状态需要手动确认"
|
|
202
|
-
;;
|
|
203
|
-
esac
|
|
204
|
-
|
|
205
|
-
return $monitor_status
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
# 显示最终总结
|
|
209
|
-
show_final_summary() {
|
|
210
|
-
local status=$1
|
|
211
|
-
|
|
212
|
-
echo ""
|
|
213
|
-
echo "🎊 智能发布流程总结"
|
|
214
|
-
echo "==================="
|
|
215
|
-
echo ""
|
|
216
|
-
print_info "📦 版本信息:"
|
|
217
|
-
echo " 版本: v$NEW_VERSION"
|
|
218
|
-
echo " Tag: $TAG_NAME"
|
|
219
|
-
echo ""
|
|
220
|
-
print_info "🔗 相关链接:"
|
|
221
|
-
echo " 安装命令: npm install -g ccman@$NEW_VERSION"
|
|
222
|
-
echo " NPM页面: https://www.npmjs.com/package/ccman/v/$NEW_VERSION"
|
|
223
|
-
echo " GitHub Release: https://github.com/2ue/ccm/releases/tag/v$NEW_VERSION"
|
|
224
|
-
echo ""
|
|
225
|
-
|
|
226
|
-
case $status in
|
|
227
|
-
0)
|
|
228
|
-
print_success "🎉 智能发布完全成功!"
|
|
229
|
-
;;
|
|
230
|
-
1)
|
|
231
|
-
print_error "❌ 发布过程中出现错误,请检查上述链接"
|
|
232
|
-
;;
|
|
233
|
-
*)
|
|
234
|
-
print_warning "⚠️ 发布可能仍在进行中,请稍后检查"
|
|
235
|
-
;;
|
|
236
|
-
esac
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
# 主函数
|
|
240
|
-
main() {
|
|
241
|
-
echo "🚀 CCM 智能发布脚本 v3.0 (模块化架构)"
|
|
242
|
-
echo "======================================="
|
|
243
|
-
echo ""
|
|
244
|
-
print_info "使用模块化架构,四个独立步骤:"
|
|
245
|
-
echo " 1. 检查工作目录状态"
|
|
246
|
-
echo " 2. 版本管理"
|
|
247
|
-
echo " 3. 创建tag和提交"
|
|
248
|
-
echo " 4. 监控发布状态"
|
|
249
|
-
echo ""
|
|
250
|
-
|
|
251
|
-
# 检查环境
|
|
252
|
-
check_modules
|
|
253
|
-
|
|
254
|
-
# 确认开始
|
|
255
|
-
if [ "$SKIP_VERSION" != true ] && [ -z "$VERSION_TYPE" ] && [ "$NO_MONITOR" != true ]; then
|
|
256
|
-
read -p "开始智能发布流程? (Y/n): " -n 1 -r
|
|
257
|
-
echo
|
|
258
|
-
if [[ $REPLY =~ ^[Nn]$ ]]; then
|
|
259
|
-
print_warning "发布已取消"
|
|
260
|
-
exit 0
|
|
261
|
-
fi
|
|
262
|
-
echo ""
|
|
263
|
-
fi
|
|
264
|
-
|
|
265
|
-
# 执行四个步骤
|
|
266
|
-
step_check_uncommitted
|
|
267
|
-
step_version_bump
|
|
268
|
-
step_create_tag
|
|
269
|
-
step_monitor_release
|
|
270
|
-
local final_status=$?
|
|
271
|
-
|
|
272
|
-
# 显示最终总结
|
|
273
|
-
show_final_summary $final_status
|
|
274
|
-
|
|
275
|
-
exit $final_status
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
# 错误处理
|
|
279
|
-
trap 'print_error "智能发布过程中出现错误"' ERR
|
|
280
|
-
|
|
281
|
-
# 解析参数并运行
|
|
282
|
-
parse_arguments "$@"
|
|
283
|
-
main
|
package/scripts/smart-release.sh
DELETED
|
@@ -1,322 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# CCM Enhanced Release Script
|
|
4
|
-
# 增强版快速发布脚本 - 支持智能代码处理和发布状态监控
|
|
5
|
-
|
|
6
|
-
set -e
|
|
7
|
-
|
|
8
|
-
# 颜色定义
|
|
9
|
-
GREEN='\033[0;32m'
|
|
10
|
-
YELLOW='\033[1;33m'
|
|
11
|
-
RED='\033[0;31m'
|
|
12
|
-
BLUE='\033[0;34m'
|
|
13
|
-
CYAN='\033[0;36m'
|
|
14
|
-
NC='\033[0m'
|
|
15
|
-
|
|
16
|
-
print_success() { echo -e "${GREEN}✅ $1${NC}"; }
|
|
17
|
-
print_warning() { echo -e "${YELLOW}⚠️ $1${NC}"; }
|
|
18
|
-
print_error() { echo -e "${RED}❌ $1${NC}"; exit 1; }
|
|
19
|
-
print_info() { echo -e "${BLUE}ℹ️ $1${NC}"; }
|
|
20
|
-
print_check() { echo -e "${CYAN}🔍 $1${NC}"; }
|
|
21
|
-
|
|
22
|
-
# 检查基本环境
|
|
23
|
-
check_environment() {
|
|
24
|
-
[ ! -f "package.json" ] && print_error "package.json 未找到"
|
|
25
|
-
[ ! -d ".git" ] && print_error "不在 Git 仓库中"
|
|
26
|
-
|
|
27
|
-
if ! command -v curl &> /dev/null; then
|
|
28
|
-
print_warning "curl 未安装,将跳过发布状态检查"
|
|
29
|
-
SKIP_STATUS_CHECK=true
|
|
30
|
-
fi
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
# 智能处理未提交代码
|
|
34
|
-
handle_uncommitted_changes() {
|
|
35
|
-
print_info "检查工作目录状态..."
|
|
36
|
-
|
|
37
|
-
if git diff-index --quiet HEAD --; then
|
|
38
|
-
print_success "工作目录干净"
|
|
39
|
-
return 0
|
|
40
|
-
fi
|
|
41
|
-
|
|
42
|
-
print_warning "发现未提交的更改:"
|
|
43
|
-
git status --short
|
|
44
|
-
echo ""
|
|
45
|
-
|
|
46
|
-
echo "请选择处理方式:"
|
|
47
|
-
echo "1) 提交所有更改并继续发布"
|
|
48
|
-
echo "2) 暂存所有更改并继续发布"
|
|
49
|
-
echo "3) 取消发布,手动处理"
|
|
50
|
-
echo ""
|
|
51
|
-
|
|
52
|
-
read -p "请选择 (1-3): " choice
|
|
53
|
-
|
|
54
|
-
case $choice in
|
|
55
|
-
1)
|
|
56
|
-
read -p "输入提交信息: " commit_msg
|
|
57
|
-
[ -z "$commit_msg" ] && commit_msg="chore: 发布前提交未完成更改"
|
|
58
|
-
|
|
59
|
-
git add .
|
|
60
|
-
git commit -m "$commit_msg"
|
|
61
|
-
print_success "所有更改已提交"
|
|
62
|
-
;;
|
|
63
|
-
2)
|
|
64
|
-
git add .
|
|
65
|
-
print_success "所有更改已暂存"
|
|
66
|
-
;;
|
|
67
|
-
3)
|
|
68
|
-
print_info "发布已取消,请手动处理更改后重新运行"
|
|
69
|
-
exit 0
|
|
70
|
-
;;
|
|
71
|
-
*)
|
|
72
|
-
print_error "无效选择"
|
|
73
|
-
;;
|
|
74
|
-
esac
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
# 获取和选择版本
|
|
78
|
-
get_and_select_version() {
|
|
79
|
-
current_version=$(node -p "require('./package.json').version")
|
|
80
|
-
version_type=${1:-""}
|
|
81
|
-
|
|
82
|
-
echo "🚀 CCM 智能发布"
|
|
83
|
-
echo "当前版本: $current_version"
|
|
84
|
-
echo ""
|
|
85
|
-
|
|
86
|
-
if [ -z "$version_type" ]; then
|
|
87
|
-
print_info "选择版本升级类型:"
|
|
88
|
-
echo "1) patch (修订版本): $current_version → $(pnpm version patch --dry-run 2>/dev/null | cut -d'v' -f2 || echo '计算中...')"
|
|
89
|
-
echo "2) minor (次版本): $current_version → $(pnpm version minor --dry-run 2>/dev/null | cut -d'v' -f2 || echo '计算中...')"
|
|
90
|
-
echo "3) major (主版本): $current_version → $(pnpm version major --dry-run 2>/dev/null | cut -d'v' -f2 || echo '计算中...')"
|
|
91
|
-
echo "4) 跳过版本升级,仅重新发布当前版本"
|
|
92
|
-
echo ""
|
|
93
|
-
|
|
94
|
-
read -p "请选择 (1-4, 回车默认选择 patch): " choice
|
|
95
|
-
|
|
96
|
-
case ${choice:-1} in
|
|
97
|
-
1|"") version_type="patch" ;;
|
|
98
|
-
2) version_type="minor" ;;
|
|
99
|
-
3) version_type="major" ;;
|
|
100
|
-
4) version_type="skip" ;;
|
|
101
|
-
*) print_error "无效选择" ;;
|
|
102
|
-
esac
|
|
103
|
-
fi
|
|
104
|
-
|
|
105
|
-
print_info "选择: $version_type"
|
|
106
|
-
|
|
107
|
-
if [ "$version_type" != "skip" ]; then
|
|
108
|
-
echo ""
|
|
109
|
-
read -p "确认升级版本? (y/N): " -n 1 -r
|
|
110
|
-
echo
|
|
111
|
-
[[ ! $REPLY =~ ^[Yy]$ ]] && { print_warning "取消发布"; exit 0; }
|
|
112
|
-
fi
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
# 执行发布流程
|
|
116
|
-
execute_release() {
|
|
117
|
-
print_success "开始发布流程..."
|
|
118
|
-
|
|
119
|
-
# 1. 构建和测试
|
|
120
|
-
print_info "运行构建和代码检查..."
|
|
121
|
-
pnpm run build
|
|
122
|
-
pnpm run lint
|
|
123
|
-
|
|
124
|
-
# 2. 更新版本号
|
|
125
|
-
if [ "$version_type" != "skip" ]; then
|
|
126
|
-
print_info "更新版本号..."
|
|
127
|
-
new_version=$(pnpm version $version_type --no-git-tag-version)
|
|
128
|
-
new_version=${new_version#v}
|
|
129
|
-
print_success "版本已更新: $current_version → $new_version"
|
|
130
|
-
else
|
|
131
|
-
new_version=$current_version
|
|
132
|
-
print_info "跳过版本更新,使用当前版本: $new_version"
|
|
133
|
-
fi
|
|
134
|
-
|
|
135
|
-
# 3. 先创建tag,再提交(按你的需求顺序)
|
|
136
|
-
tag_name="v$new_version"
|
|
137
|
-
|
|
138
|
-
if [ "$version_type" != "skip" ]; then
|
|
139
|
-
print_info "创建标签: $tag_name"
|
|
140
|
-
git tag -a "$tag_name" -m "Release v$new_version
|
|
141
|
-
|
|
142
|
-
🚀 智能发布 $version_type 版本
|
|
143
|
-
⏰ $(date '+%Y-%m-%d %H:%M:%S')
|
|
144
|
-
|
|
145
|
-
🤖 Generated with [Claude Code](https://claude.ai/code)
|
|
146
|
-
|
|
147
|
-
Co-Authored-By: Claude <noreply@anthropic.com>"
|
|
148
|
-
|
|
149
|
-
print_info "提交版本更改..."
|
|
150
|
-
git add .
|
|
151
|
-
git commit -m "chore: 发布版本 v$new_version
|
|
152
|
-
|
|
153
|
-
🚀 智能发布 $version_type 版本,标签 $tag_name 已创建
|
|
154
|
-
⏰ $(date '+%Y-%m-%d %H:%M:%S')
|
|
155
|
-
|
|
156
|
-
🤖 Generated with [Claude Code](https://claude.ai/code)
|
|
157
|
-
|
|
158
|
-
Co-Authored-By: Claude <noreply@anthropic.com>"
|
|
159
|
-
|
|
160
|
-
print_success "标签 $tag_name 已创建,更改已提交"
|
|
161
|
-
fi
|
|
162
|
-
|
|
163
|
-
# 4. 推送
|
|
164
|
-
print_info "推送到远程仓库..."
|
|
165
|
-
git push origin $(git branch --show-current)
|
|
166
|
-
git push origin "$tag_name"
|
|
167
|
-
|
|
168
|
-
print_success "版本 v$new_version 已推送,GitHub Actions 已触发"
|
|
169
|
-
|
|
170
|
-
# 输出监控链接(按你的需求)
|
|
171
|
-
print_info "📊 监控链接:"
|
|
172
|
-
echo " 🔗 GitHub Actions: https://github.com/2ue/ccm/actions"
|
|
173
|
-
echo " 🔗 NPM Registry: https://www.npmjs.com/package/ccman"
|
|
174
|
-
echo " 🔗 GitHub Releases: https://github.com/2ue/ccm/releases"
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
# 监控发布状态
|
|
178
|
-
monitor_release_status() {
|
|
179
|
-
if [ "$SKIP_STATUS_CHECK" = true ]; then
|
|
180
|
-
print_warning "跳过发布状态检查"
|
|
181
|
-
show_manual_links
|
|
182
|
-
return 0
|
|
183
|
-
fi
|
|
184
|
-
|
|
185
|
-
print_info "开始监控发布状态..."
|
|
186
|
-
echo ""
|
|
187
|
-
|
|
188
|
-
# GitHub Actions 状态检查
|
|
189
|
-
print_check "检查 GitHub Actions 状态..."
|
|
190
|
-
|
|
191
|
-
local max_attempts=30 # 最多检查5分钟
|
|
192
|
-
local attempt=0
|
|
193
|
-
local actions_success=false
|
|
194
|
-
|
|
195
|
-
while [ $attempt -lt $max_attempts ]; do
|
|
196
|
-
# 检查最新的 workflow run
|
|
197
|
-
local run_status=$(curl -s -H "Accept: application/vnd.github.v3+json" \
|
|
198
|
-
"https://api.github.com/repos/2ue/ccm/actions/runs?per_page=1" \
|
|
199
|
-
| grep -o '"status":"[^"]*"' | head -1 | cut -d'"' -f4 2>/dev/null || echo "unknown")
|
|
200
|
-
|
|
201
|
-
local run_conclusion=$(curl -s -H "Accept: application/vnd.github.v3+json" \
|
|
202
|
-
"https://api.github.com/repos/2ue/ccm/actions/runs?per_page=1" \
|
|
203
|
-
| grep -o '"conclusion":"[^"]*"' | head -1 | cut -d'"' -f4 2>/dev/null || echo "null")
|
|
204
|
-
|
|
205
|
-
case "$run_status" in
|
|
206
|
-
"completed")
|
|
207
|
-
if [ "$run_conclusion" = "success" ]; then
|
|
208
|
-
print_success "GitHub Actions 构建成功!"
|
|
209
|
-
actions_success=true
|
|
210
|
-
break
|
|
211
|
-
else
|
|
212
|
-
print_error "GitHub Actions 构建失败: $run_conclusion"
|
|
213
|
-
return 1
|
|
214
|
-
fi
|
|
215
|
-
;;
|
|
216
|
-
"in_progress"|"queued")
|
|
217
|
-
echo -ne "\r${CYAN}🔍 GitHub Actions 运行中... (${attempt}/${max_attempts})${NC}"
|
|
218
|
-
;;
|
|
219
|
-
*)
|
|
220
|
-
echo -ne "\r${YELLOW}⚠️ 等待 GitHub Actions 开始... (${attempt}/${max_attempts})${NC}"
|
|
221
|
-
;;
|
|
222
|
-
esac
|
|
223
|
-
|
|
224
|
-
sleep 10
|
|
225
|
-
((attempt++))
|
|
226
|
-
done
|
|
227
|
-
|
|
228
|
-
echo # 换行
|
|
229
|
-
|
|
230
|
-
if [ "$actions_success" != true ]; then
|
|
231
|
-
print_warning "GitHub Actions 检查超时,请手动确认"
|
|
232
|
-
show_manual_links
|
|
233
|
-
return 0
|
|
234
|
-
fi
|
|
235
|
-
|
|
236
|
-
# NPM 发布状态检查
|
|
237
|
-
print_check "检查 NPM 包发布状态..."
|
|
238
|
-
|
|
239
|
-
local npm_attempts=20
|
|
240
|
-
local npm_attempt=0
|
|
241
|
-
local npm_success=false
|
|
242
|
-
|
|
243
|
-
while [ $npm_attempt -lt $npm_attempts ]; do
|
|
244
|
-
local npm_response=$(curl -s "https://registry.npmjs.org/ccman" | grep -o "\"$new_version\"" 2>/dev/null || echo "")
|
|
245
|
-
|
|
246
|
-
if [ -n "$npm_response" ]; then
|
|
247
|
-
print_success "NPM 包 v$new_version 发布成功!"
|
|
248
|
-
npm_success=true
|
|
249
|
-
break
|
|
250
|
-
else
|
|
251
|
-
echo -ne "\r${CYAN}🔍 等待 NPM 包发布... (${npm_attempt}/${npm_attempts})${NC}"
|
|
252
|
-
sleep 15
|
|
253
|
-
((npm_attempt++))
|
|
254
|
-
fi
|
|
255
|
-
done
|
|
256
|
-
|
|
257
|
-
echo # 换行
|
|
258
|
-
|
|
259
|
-
if [ "$npm_success" != true ]; then
|
|
260
|
-
print_warning "NPM 包检查超时,可能仍在发布中"
|
|
261
|
-
fi
|
|
262
|
-
|
|
263
|
-
# GitHub Release 检查
|
|
264
|
-
print_check "检查 GitHub Release..."
|
|
265
|
-
|
|
266
|
-
local release_response=$(curl -s "https://api.github.com/repos/2ue/ccm/releases/tags/v$new_version" \
|
|
267
|
-
| grep -o '"tag_name":"[^"]*"' 2>/dev/null || echo "")
|
|
268
|
-
|
|
269
|
-
if [ -n "$release_response" ]; then
|
|
270
|
-
print_success "GitHub Release v$new_version 创建成功!"
|
|
271
|
-
else
|
|
272
|
-
print_warning "GitHub Release 可能仍在创建中"
|
|
273
|
-
fi
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
# 显示手动检查链接
|
|
277
|
-
show_manual_links() {
|
|
278
|
-
print_info "请手动检查以下链接:"
|
|
279
|
-
echo " GitHub Actions: https://github.com/2ue/ccm/actions"
|
|
280
|
-
echo " GitHub Release: https://github.com/2ue/ccm/releases/tag/v$new_version"
|
|
281
|
-
echo " NPM 包: https://www.npmjs.com/package/ccman"
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
# 显示发布总结
|
|
285
|
-
show_release_summary() {
|
|
286
|
-
echo ""
|
|
287
|
-
print_success "🎉 发布流程完成!"
|
|
288
|
-
echo ""
|
|
289
|
-
print_info "📋 发布总结:"
|
|
290
|
-
echo " 版本: v$new_version"
|
|
291
|
-
echo " NPM 包: ccman@$new_version"
|
|
292
|
-
echo ""
|
|
293
|
-
print_info "📦 安装命令:"
|
|
294
|
-
echo " npm install -g ccman@$new_version"
|
|
295
|
-
echo ""
|
|
296
|
-
print_info "🔗 相关链接:"
|
|
297
|
-
echo " NPM: https://www.npmjs.com/package/ccman/v/$new_version"
|
|
298
|
-
echo " GitHub: https://github.com/2ue/ccm/releases/tag/v$new_version"
|
|
299
|
-
echo ""
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
# 主函数
|
|
303
|
-
main() {
|
|
304
|
-
print_info "🚀 CCM 智能发布脚本 v2.0"
|
|
305
|
-
print_info "=================================="
|
|
306
|
-
echo ""
|
|
307
|
-
|
|
308
|
-
check_environment
|
|
309
|
-
handle_uncommitted_changes
|
|
310
|
-
get_and_select_version "$1"
|
|
311
|
-
execute_release
|
|
312
|
-
monitor_release_status
|
|
313
|
-
show_release_summary
|
|
314
|
-
|
|
315
|
-
print_success "✨ 发布成功完成!"
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
# 错误处理
|
|
319
|
-
trap 'print_error "发布过程中出现错误,请检查输出信息"' ERR
|
|
320
|
-
|
|
321
|
-
# 运行主函数
|
|
322
|
-
main "$@"
|