Skip to content

Commit 166fabe

Browse files
committed
chore(release): update dependencies and add changesets workflow
1 parent d206f06 commit 166fabe

9 files changed

Lines changed: 2902 additions & 12 deletions

File tree

.changeset/README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Changesets
2+
3+
本项目使用 [Changesets](https://github.com/changesets/changesets) 进行版本管理和发布。
4+
5+
## 添加变更记录
6+
7+
当你完成一个功能或修复后,运行:
8+
9+
```bash
10+
pnpm changeset
11+
```
12+
13+
然后按照提示:
14+
1. 选择变更类型(major/minor/patch)
15+
2. 输入变更描述
16+
17+
这会在 `.changeset` 目录下创建一个临时文件,记录本次变更。
18+
19+
## 版本发布流程
20+
21+
### 自动发布(推荐)
22+
23+
1. 创建 PR 并合并到 main 分支
24+
2. Changesets bot 会自动创建一个 "Version Packages" PR
25+
3. 这个 PR 会:
26+
- 更新版本号
27+
- 生成 CHANGELOG
28+
- 删除临时的 changeset 文件
29+
4. 合并这个 PR 后,GitHub Actions 会自动发布到 npm
30+
31+
### 本地发布
32+
33+
```bash
34+
# 1. 创建变更记录
35+
pnpm changeset
36+
37+
# 2. 更新版本(会更新 package.json 和 CHANGELOG.md)
38+
pnpm changeset version
39+
40+
# 3. 提交更改
41+
git add .
42+
git commit -m "chore: release"
43+
44+
# 4. 发布到 npm
45+
pnpm release
46+
47+
# 5. 推送到 GitHub
48+
git push --follow-tags
49+
```
50+
51+
## 变更类型说明
52+
53+
- **patch**: 修复 bug,向后兼容的小改动
54+
- **minor**: 新增功能,向后兼容
55+
- **major**: 重大更改,可能不兼容旧版本

.changeset/config.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/config@3.1.1/schema.json",
3+
"changelog": "@changesets/cli/changelog",
4+
"commit": false,
5+
"fixed": [],
6+
"linked": [],
7+
"access": "public",
8+
"baseBranch": "main",
9+
"updateInternalDependencies": "patch",
10+
"ignore": []
11+
}

.github/PUBLISHING.md

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# 发布指南
2+
3+
本项目使用 [Changesets](https://github.com/changesets/changesets) 进行版本管理和自动发布。
4+
5+
## 🚀 快速开始
6+
7+
### 1. 添加变更记录
8+
9+
完成功能开发或修复后,创建变更记录:
10+
11+
```bash
12+
pnpm changeset
13+
```
14+
15+
按照提示选择:
16+
- 变更类型(patch/minor/major)
17+
- 输入变更描述(支持 Markdown)
18+
19+
### 2. 自动发布流程(推荐)
20+
21+
1. **创建 PR**:将你的代码推送到分支,创建 PR 到 main
22+
2. **合并 PR**:代码审查通过后合并
23+
3. **自动创建发布 PR**:Changesets bot 会自动创建 "Version Packages" PR
24+
4. **合并发布 PR**:合并后自动发布到 npm
25+
26+
## 📦 发布流程详解
27+
28+
### 自动化流程
29+
30+
当代码合并到 main 分支后:
31+
32+
1. GitHub Actions 检测到新的 changesets
33+
2. 自动创建/更新 "Version Packages" PR,包含:
34+
- 版本号更新
35+
- CHANGELOG 生成
36+
- changeset 文件清理
37+
3. 合并该 PR 触发自动发布
38+
39+
### 本地发布(备选)
40+
41+
```bash
42+
# 1. 添加变更记录
43+
pnpm changeset
44+
45+
# 2. 更新版本
46+
pnpm changeset version
47+
48+
# 3. 构建并发布
49+
pnpm release
50+
51+
# 4. 推送代码
52+
git push origin main --follow-tags
53+
```
54+
55+
## 🏷️ 版本规范
56+
57+
遵循语义化版本(Semantic Versioning):
58+
59+
| 类型 | 版本变化 | 适用场景 |
60+
|------|---------|---------|
61+
| **patch** | x.x.1 | Bug 修复、文档更新、依赖更新 |
62+
| **minor** | x.1.0 | 新增功能、向后兼容的改进 |
63+
| **major** | 1.0.0 | 破坏性更改、架构调整、API 变更 |
64+
65+
## 🔧 配置要求
66+
67+
### GitHub Secrets
68+
69+
在仓库设置中配置:
70+
- `NPM_TOKEN`: npm 发布令牌
71+
1. 访问 https://www.npmjs.com/settings/[username]/tokens
72+
2. 创建 "Automation" 类型的 token
73+
3. 添加到 GitHub Secrets
74+
75+
### 权限设置
76+
77+
确保 GitHub Actions 有以下权限:
78+
- `contents: write` - 创建发布
79+
- `pull-requests: write` - 创建 PR
80+
- `id-token: write` - npm provenance
81+
82+
## 📋 CI/CD 工作流
83+
84+
### CI 工作流(ci.yml)
85+
- **触发**:Push 到 main 或 PR
86+
- **测试矩阵**
87+
- OS: Ubuntu, macOS, Windows
88+
- Node: 18, 20
89+
- **步骤**:依赖安装 → 类型检查 → 构建 → 测试
90+
91+
### Release 工作流(release.yml)
92+
- **触发**:Push 到 main
93+
- **功能**
94+
- 检测 changesets
95+
- 创建版本 PR
96+
- 自动发布到 npm
97+
- 支持 npm provenance
98+
99+
## 💡 最佳实践
100+
101+
1. **每个 PR 一个 changeset**:确保每个功能都有变更记录
102+
2. **描述要清晰**:changeset 描述会出现在 CHANGELOG 中
103+
3. **选择正确的版本类型**:参考版本规范
104+
4. **不要手动修改版本号**:让 changesets 管理版本
105+
106+
## 🔍 常见问题
107+
108+
### Q: 忘记添加 changeset 怎么办?
109+
A: 可以在 PR 中补充,运行 `pnpm changeset` 并提交
110+
111+
### Q: 如何发布预发布版本?
112+
A: 使用 `pnpm changeset pre enter <tag>` 进入预发布模式
113+
114+
### Q: 如何撤销发布?
115+
A: npm 不支持撤销,只能发布新版本修复
116+
117+
## 📚 相关链接
118+
119+
- [Changesets 文档](https://github.com/changesets/changesets)
120+
- [语义化版本规范](https://semver.org/lang/zh-CN/)
121+
- [npm 发布文档](https://docs.npmjs.com/cli/v8/commands/npm-publish)

.github/workflows/ci.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
test:
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
matrix:
16+
os: [ubuntu-latest, macos-latest, windows-latest]
17+
node-version: [18, 20]
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Setup Node.js
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: ${{ matrix.node-version }}
27+
28+
- name: Install pnpm
29+
uses: pnpm/action-setup@v2
30+
with:
31+
version: 9
32+
run_install: false
33+
34+
- name: Get pnpm store directory
35+
shell: bash
36+
run: |
37+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
38+
39+
- name: Setup pnpm cache
40+
uses: actions/cache@v3
41+
with:
42+
path: ${{ env.STORE_PATH }}
43+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
44+
restore-keys: |
45+
${{ runner.os }}-pnpm-store-
46+
47+
- name: Install dependencies
48+
run: pnpm install --frozen-lockfile
49+
50+
- name: Run type check
51+
run: pnpm typecheck
52+
53+
- name: Build package
54+
run: pnpm build
55+
56+
- name: Test build
57+
run: pnpm test

.github/workflows/release.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
concurrency: ${{ github.workflow }}-${{ github.ref }}
9+
10+
jobs:
11+
release:
12+
name: Release
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
pull-requests: write
17+
id-token: write
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Setup Node.js
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: '20'
27+
registry-url: 'https://registry.npmjs.org'
28+
29+
- name: Install pnpm
30+
uses: pnpm/action-setup@v2
31+
with:
32+
version: 9
33+
run_install: false
34+
35+
- name: Get pnpm store directory
36+
shell: bash
37+
run: |
38+
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
39+
40+
- name: Setup pnpm cache
41+
uses: actions/cache@v3
42+
with:
43+
path: ${{ env.STORE_PATH }}
44+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
45+
restore-keys: |
46+
${{ runner.os }}-pnpm-store-
47+
48+
- name: Install dependencies
49+
run: pnpm install --frozen-lockfile
50+
51+
- name: Create Release Pull Request or Publish to npm
52+
id: changesets
53+
uses: changesets/action@v1
54+
with:
55+
publish: pnpm release
56+
title: 'chore: release'
57+
commit: 'chore: release'
58+
env:
59+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
61+
NPM_CONFIG_PROVENANCE: true

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ dist
66
.env
77
.env.*
88
!.env.example
9-
pnpm-lock.yaml
109
package-lock.json
1110
yarn.lock
1211
test.mjs

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Changelog
2+
3+
## 1.0.1
4+
5+
### Patch Changes
6+
7+
- 更新依赖, 增加自动发布流水线
8+
9+
All notable changes to this project will be documented in this file.
10+
11+
## [1.0.0] - 2025-08-03
12+
13+
### Features
14+
15+
- 初始版本发布
16+
- 支持中英文双语配置
17+
- 自动检测并安装 Claude Code
18+
- 智能配置文件管理(备份、合并、跳过)
19+
- MCP 服务自动配置
20+
- 支持多种 MCP 服务:Context7、DeepWiki、Exa、Playwright 等
21+
- 交互式命令行界面
22+
- 跨平台支持(Windows、macOS、Linux)

package.json

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
"name": "zcf",
33
"type": "module",
4-
"version": "1.0.0",
5-
"packageManager": "pnpm@9.0.0",
4+
"version": "1.0.1",
5+
"packageManager": "pnpm@9.15.9",
66
"description": "Zero-Config Claude-Code Flow - One-click configuration tool for Claude Code",
77
"license": "MIT",
8-
"homepage": "https://github.com/UfoMiao/claude-code-config#readme",
8+
"homepage": "https://github.com/UfoMiao/zcf#readme",
99
"repository": {
1010
"type": "git",
11-
"url": "git+https://github.com/UfoMiao/claude-code-config.git"
11+
"url": "git+https://github.com/UfoMiao/zcf.git"
1212
},
1313
"main": "dist/index.mjs",
1414
"module": "dist/index.mjs",
@@ -26,22 +26,26 @@
2626
"build": "unbuild",
2727
"typecheck": "tsc",
2828
"prepublishOnly": "npm run build",
29-
"test": "npm run build && node bin/zcf.mjs"
29+
"test": "npm run build && node bin/zcf.mjs",
30+
"changeset": "changeset",
31+
"version": "changeset version",
32+
"release": "pnpm build && changeset publish"
3033
},
3134
"dependencies": {
3235
"@posva/prompts": "^2.4.4",
33-
"ansis": "^3.3.2",
36+
"ansis": "^3.17.0",
3437
"cac": "^6.7.14",
3538
"dayjs": "^1.11.13",
3639
"find-up-simple": "^1.0.1",
37-
"pathe": "^2.0.0",
40+
"pathe": "^2.0.3",
3841
"tinyexec": "^1.0.1"
3942
},
4043
"devDependencies": {
41-
"@types/node": "^22.15.12",
42-
"tsx": "^4.19.4",
43-
"typescript": "^5.8.3",
44-
"unbuild": "^3.5.0"
44+
"@changesets/cli": "^2.29.5",
45+
"@types/node": "^22.17.0",
46+
"tsx": "^4.20.3",
47+
"typescript": "^5.9.2",
48+
"unbuild": "^3.6.0"
4549
},
4650
"keywords": [
4751
"claude",

0 commit comments

Comments
 (0)