本项目已配置 GitHub Actions 工作流,支持一键自动构建跨平台包并创建 GitHub Release。
# 1. 添加 .github 目录
git add .github
# 2. 提交
git commit -m "feat: 添加 GitHub Actions 自动构建和发布工作流"
# 3. 推送到远程仓库
git push origin ls-dev
# 4. 如果需要同步到 github_main 分支
npm run sync-to-github-
访问仓库设置页面:
https://github.com/OrionStarAI/DeepVCode/settings/actions -
找到 "Workflow permissions" 部分
-
选择 "Read and write permissions"
-
勾选 "Allow GitHub Actions to create and approve pull requests"(可选)
-
点击 "Save" 保存
⚠️ 重要:这一步是必须的,否则工作流无法创建 Release!
适用场景:想立即发布新版本,或测试构建流程
步骤:
-
访问 GitHub Actions 页面
https://github.com/OrionStarAI/DeepVCode/actions/workflows/release.yml -
点击右上角 "Run workflow" 按钮
-
选择分支(通常选择
ls-dev或main) -
填写参数(全部可选):
参数 说明 示例 version 指定版本号(留空则使用 package.json 中的版本) 1.0.262或1.0.262-beta.1prerelease 是否为预发布版本(测试版本勾选) 勾选 ✅ draft 是否创建草稿(需要手动发布) 勾选 ✅ -
点击绿色的 "Run workflow" 按钮
-
等待构建完成(约 3-5 分钟)
-
查看结果:
- 访问 Releases 页面 查看新发布的版本
- 或在 workflow 运行页面的 Artifacts 区域下载构建产物
适用场景:版本发布流程规范化,自动触发构建,并通过 tag 消息生成 Release Notes
步骤:
# 1. 本地更新版本号
npm version 1.0.262
# 或手动修改 package.json 中的 version
# 2. 创建带注释的 tag(tag 消息将作为 Release Notes)
git tag -a v1.0.262 -m "Release v1.0.262
## ✨ New Features
- Add new authentication flow with enhanced security
- Support for custom proxy configurations
## 🐛 Bug Fixes
- Fix memory leak in file watcher
- Resolve issue with clipboard on Ubuntu
## 📚 Documentation
- Update installation guide
- Add troubleshooting section for Windows users
"
# 或者使用编辑器编写详细的 tag 消息
git tag -a v1.0.262
# 这会打开编辑器,让你编写多行 Release Notes
# 3. 推送代码和 tag
git push && git push --tags
# 工作流会自动运行,使用 tag 消息生成 Release Notes💡 Tag 消息格式建议:
Release v1.0.262
## ✨ New Features
- Feature 1 description
- Feature 2 description
## 🐛 Bug Fixes
- Bug fix 1
- Bug fix 2
## 🔧 Improvements
- Improvement 1
- Improvement 2
## 📚 Documentation
- Documentation updates
## ⚠️ Breaking Changes
- Breaking change description (if any)当你触发工作流后,GitHub Actions 会自动执行以下步骤:
- ✅ 检出代码 - 获取最新代码(包含完整 tag 信息)
- ✅ 设置环境 - 安装 Node.js 20
- ✅ 安装依赖 -
npm ci - ✅ 运行测试 -
npm run test(失败不会中断) - ✅ 代码检查 -
npm run lint(失败不会中断) - ✅ 类型检查 -
npm run typecheck(失败不会中断) - ✅ 构建跨平台包 -
npm run pack:prod:ci(不自动递增版本号) - ✅ 获取版本号 - 从输入参数、tag 或 package.json
- ✅ 查找构建产物 - 找到生成的
.tgz文件 - ✅ 提取 tag 注释 - 从 annotated tag 中提取 Release Notes
- ✅ 生成 Release Notes - 使用 tag 消息 + 安装说明模板
- ✅ 创建 GitHub Release - 上传
.tgz文件并发布 - ✅ 上传构建产物 - 作为 workflow artifact(保留 90 天)
- 访问 Releases 页面
- 找到对应版本
- 下载
deepv-code-x.x.x.tgz文件 - 安装:
npm install -g ./deepv-code-1.0.262.tgz
npm install -g deepv-code@1.0.262- 访问 Actions 页面
- 点击对应的工作流运行
- 在页面底部的 "Artifacts" 区域下载
- 解压后安装
# 1. 确保代码已提交
git status
# 2. 更新版本号(手动或使用 npm version)
npm version patch # 1.0.261 → 1.0.262
# 或
npm version minor # 1.0.261 → 1.1.0
# 或
npm version major # 1.0.261 → 2.0.0
# 3. 推送代码和 tags
git push && git push --tags
# 4. GitHub Actions 自动构建并创建 Release(使用 package.json 中的版本号)💡 注意:GitHub Actions 使用
pack:prod:ci命令,不会自动递增版本号,而是使用package.json中的当前版本。请确保在触发 workflow 前手动更新版本号。
方法 A: 使用手动触发
- 访问 Actions 页面
- Run workflow
- 设置:
- version:
1.0.262-beta.1 - prerelease: ✅
- version:
- 运行
方法 B: 使用 tag(推荐)
# 1. 修改 package.json 版本为 1.0.262-beta.1
# 2. 创建带注释的 tag 并标记为预发布
git tag -a v1.0.262-beta.1 -m "Beta Release v1.0.262-beta.1
## 🧪 Testing Features
- New feature A (needs testing)
- Experimental feature B
## ⚠️ Known Issues
- Issue X is being investigated
"
# 3. 推送 tag
git push origin v1.0.262-beta.1💡 提示:包含
-alpha,-beta,-rc的版本号会自动被标记为 prerelease。
- 访问 Actions 页面
- Run workflow
- 设置:
- draft: ✅
- 运行完成后
- 访问 Releases 页面
- 编辑草稿 Release
- 点击 "Publish release"
如果只想测试构建是否正常,可以:
- 临时修改
.github/workflows/release.yml - 注释掉 "Create GitHub Release" 步骤
- 手动触发工作流
- 查看构建日志和下载 Artifacts
在 .github/workflows/release.yml 中添加:
- name: 📤 Publish to npm
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}然后在 GitHub 仓库设置中添加 NPM_TOKEN secret:
- 访问
https://github.com/OrionStarAI/DeepVCode/settings/secrets/actions - 点击 "New repository secret"
- Name:
NPM_TOKEN - Value: 你的 npm token(从 https://www.npmjs.com/settings/YOUR_USERNAME/tokens 获取)
如果测试很慢,可以:
方法 1: 注释掉测试步骤
# - name: 🧪 Run tests
# run: npm run test方法 2: 保留但允许失败(已配置)
- name: 🧪 Run tests
run: npm run test
continue-on-error: true # 测试失败也继续修改 .github/workflows/release.yml 中的 "Generate Release Notes" 步骤。
解决方案:
- 检查仓库 Actions 权限设置
- 路径: Settings → Actions → General → Workflow permissions
- 选择 "Read and write permissions"
可能原因:
npm run pack:prod执行失败- 依赖安装问题
- 构建脚本错误
解决方案:
- 查看工作流日志中的 "Build cross-platform package" 步骤
- 本地测试
npm run pack:prod是否正常 - 检查构建脚本
scripts/newpack.js
可能原因:
- 文件路径配置错误
- 文件未找到
解决方案:
检查 .github/workflows/release.yml 中的 files: 配置:
files: |
${{ steps.find_artifacts.outputs.TGZ_FILE }}
bundle/**/*方案:
- 访问 Releases 页面
- 找到对应的 Release
- 点击 "Edit release"
- 修改标题、描述或上传/删除文件
- 保存
- 首次使用前,务必配置仓库权限(见"第一次设置")
- 推荐使用 annotated tag 触发,Release Notes 更有意义
- 使用
git tag -a创建带注释的 tag,消息会成为 Release Notes - 可以先用
draft: true创建草稿测试 - Workflow artifacts 保留 90 天,适合临时测试
- 正式 Release 永久保存
- Tag 消息支持 Markdown 格式,可以包含链接、代码块等
git tag -a v1.0.262 -m "Fix critical authentication bug"git tag -a v1.0.262
# 在编辑器中写入:Release v1.0.262
## ✨ New Features
- **Authentication**: Add OAuth2 support for enterprise users
- **Performance**: Implement intelligent caching for 50% faster startup
- **UI**: New dark theme with customizable color schemes
## 🐛 Bug Fixes
- Fix memory leak in file watcher (#123)
- Resolve clipboard issue on Ubuntu 22.04 (#145)
- Correct Windows path handling for spaces (#156)
## 🔧 Improvements
- Reduce bundle size by 30% through tree-shaking
- Improve error messages for network failures
- Add progress indicators for long-running operations
## 📚 Documentation
- Add comprehensive authentication guide
- Update installation instructions for ARM64
- Include troubleshooting section for common issues
## 🙏 Contributors
Thanks to @user1, @user2, and @user3 for their contributions!git tag -a v1.0.262 -m "Release v1.0.262
feat: add OAuth2 authentication support
feat: implement intelligent caching system
fix: resolve memory leak in file watcher (#123)
fix: correct Windows path handling (#156)
perf: reduce bundle size by 30%
docs: add authentication guide
"