feat: add automated release workflow and configuration

- Introduced a new release configuration file to define commit types and sections for changelog generation.
- Created a publish workflow to automate the release process on main branch pushes, including version bumping, changelog generation, and GitHub release creation.
- Added a separate release workflow to build artifacts for multiple platforms and upload them as release assets.
- Documented the automated release process, including commit message conventions and local release commands in AUTOMATED_RELEASE.md.
This commit is contained in:
zhanggy committed 2025-10-29 10:24:39 +08:00
1 parent 0eb2dcf8c2
commit 18fc065a17
6 files changed
+1316 -7

No files matched your search

+44
View File
@@ -0,0 +1,44 @@
{
"types": [
{
"type": "feat",
"section": "Features"
},
{
"type": "fix",
"section": "Bug Fixes"
},
{
"type": "docs",
"section": "Documentation"
},
{
"type": "style",
"section": "Styles"
},
{
"type": "refactor",
"section": "Refactoring"
},
{
"type": "perf",
"section": "Performance Improvements"
},
{
"type": "test",
"section": "Tests"
},
{
"type": "build",
"section": "Build System"
},
{
"type": "ci",
"section": "CI"
},
{
"type": "chore",
"section": "Chores"
}
]
}
+87
View File
@@ -0,0 +1,87 @@
name: Publish Release
on:
push:
branches:
- main
# 在同一个工作流中处理发布任务
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
- name: Setup Git user
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: Bump version and generate changelog
run: |
# 根据 commit 信息自动更新版本和生成 changelog
pnpm release
# 获取新版本号
VERSION=$(node -p "require('./package.json').version")
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Push changes
run: |
git push origin main
git push origin v${{ env.VERSION }}
- name: Build for all platforms
run: pnpm build:all
env:
# 在 macOS 上禁用代码签名
CSC_IDENTITY_AUTO_DISCOVERY: false
# GitHub token 用于发布
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ env.VERSION }}
name: Release v${{ env.VERSION }}
body_path: CHANGELOG.md
draft: false
prerelease: false
files: |
release/${{ env.VERSION }}/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+60
View File
@@ -0,0 +1,60 @@
name: Release
on:
push:
branches:
- main
jobs:
release:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
- name: Build
run: pnpm build:all
env:
# 在 macOS 上禁用代码签名
CSC_IDENTITY_AUTO_DISCOVERY: false
# GitHub token 用于发布
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: release-${{ matrix.os }}
path: release/**
+61
View File
@@ -0,0 +1,61 @@
# 自动化发布流程
本项目配置了自动化的发布流程,包括自动版本更新和变更日志生成。以下是相关说明:
## 工作流程
当代码合并到 main 分支后,GitHub Actions 会自动执行以下步骤:
1. 检出代码
2. 设置 Node.js 和 pnpm 环境
3. 安装依赖
4. 根据 Git 提交信息自动更新版本号
5. 生成变更日志 (CHANGELOG.md)
6. 构建应用程序 (所有平台)
7. 创建 GitHub Release
8. 上传构建产物
## 提交信息规范
为了确保自动版本管理和变更日志生成正常工作,提交信息必须遵循约定格式:
- `feat: ...` - 添加新功能,触发 MINOR 版本更新
- `fix: ...` - 修复错误,触发 PATCH 版本更新
- `perf: ...` - 性能改进,触发 PATCH 版本更新
- `docs: ...` - 文档更新,不触发版本更新
- `style: ...` - 代码格式调整,不触发版本更新
- `refactor: ...` - 重构代码,不触发版本更新
- `test: ...` - 测试相关,不触发版本更新
- `build: ...` - 构建系统或依赖更新,可能触发版本更新
- `ci: ...` - CI 配置更新,不触发版本更新
- `chore: ...` - 其他杂项,不触发版本更新
示例:
- `feat: 添加用户认证功能`
- `fix: 修复登录页面的错误`
- `docs: 更新 API 文档`
## 本地版本发布
如果需要在本地手动执行发布流程,可运行以下命令:
```bash
# 根据提交历史自动发布新版本
pnpm release
# 手动指定发布类型
pnpm release:major # 主版本更新 (1.x.x -> 2.x.x)
pnpm release:minor # 次版本更新 (1.1.x -> 1.2.x)
pnpm release:patch # 补丁更新 (1.1.1 -> 1.1.2)
```
## 配置文件
- `.versionrc.json` 或 `package.json` 中的 `standard-version` 配置定义了版本管理和变更日志生成规则
- `.github/workflows/publish.yml` 包含了自动化发布的工作流程定义
## 重要说明
1. 为了使自动化发布正常工作,必须正确配置 GitHub 仓库的 secrets,特别是用于发布构建产物的令牌。
2. 构建过程会生成适用于多个平台(Windows、macOS、Linux)的应用程序包。
3. 变更日志会自动包含在 GitHub Release 中。
+50 -1
View File
@@ -35,7 +35,55 @@
"lint": "eslint . --ext .js,.ts,.vue .",
"lint:fix": "eslint . --ext .js,.ts,.vue --fix .",
"test": "npm run build:pre && playwright test",
"test:linux": "npm run build:pre && xvfb-run --auto-servernum --server-args='-screen 0, 1280x960x24' -- playwright test"
"test:linux": "npm run build:pre && xvfb-run --auto-servernum --server-args='-screen 0, 1280x960x24' -- playwright test",
"release": "standard-version",
"release:major": "standard-version --release-as major",
"release:minor": "standard-version --release-as minor",
"release:patch": "standard-version --release-as patch"
},
"standard-version": {
"types": [
{
"type": "feat",
"section": "Features"
},
{
"type": "fix",
"section": "Bug Fixes"
},
{
"type": "docs",
"section": "Documentation"
},
{
"type": "style",
"section": "Styles"
},
{
"type": "refactor",
"section": "Refactoring"
},
{
"type": "perf",
"section": "Performance Improvements"
},
{
"type": "test",
"section": "Tests"
},
{
"type": "build",
"section": "Build System"
},
{
"type": "ci",
"section": "CI"
},
{
"type": "chore",
"section": "Chores"
}
]
},
"engines": {
"node": ">=20.0.0"
@@ -74,6 +122,7 @@
"jiti": "^2.6.1",
"playwright": "^1.56.1",
"prettier": "^3.6.2",
"standard-version": "^9.5.0",
"typescript": "^5.9.3",
"typescript-eslint": "^8.46.1",
"vite": "^7.1.10",
+1014 -6
View File
File diff suppressed because it is too large. Load diff