feat(ci): add AI-powered release notes generation#322
Conversation
- Add GitHub Models integration for automated release notes - Support bilingual (EN) release notes with highlights extraction - Fallback to conventional commit grouping when LLM unavailable - Trigger on tag push or manual workflow dispatch - Zero configuration: uses GitHub Models (gpt-4o-mini) by default
- Pin checkout and setup-deno to commit hashes matching project convention - Add .playwright-mcp/ and .mcp.json to gitignore
|
|
整体原理架构概览核心流程详解1. 数据收集阶段输入: 操作: # 获取两个 tag 之间的所有 commits
git log v0.2.4..v0.3.0 --format="%H|%s|%an"输出示例: 去重逻辑:
2. 数据结构化Conventional Commit 解析: "feat(auth): add OAuth support"
→ { type: "feat", scope: "auth", description: "add OAuth support" }
"fix: handle null response"
→ { type: "fix", scope: "", description: "handle null response" }关联 PR 信息: {
type: "feat",
scope: "auth",
description: "add OAuth support",
prNumber: 123,
prTitle: "Add OAuth 2.0 authentication", // 优先使用 PR 标题
authors: ["Alice", "Bob"],
commits: ["abc123", "def456"]
}3. LLM 生成阶段System Prompt(指令): User Prompt(数据): LLM 处理:
输出(Markdown): # SkillHub v0.3.0
This release focuses on authentication improvements and performance optimizations.
## 🌟 Highlights
- Added OAuth 2.0 authentication for secure third-party login
- Improved database performance by 50%
...
## ✨ Features
- Added OAuth 2.0 authentication by @Alice in #123
...4. Fallback 模式(无 LLM)触发条件:
处理逻辑: // 简单按 type 分组
{
"feat": [change1, change2],
"fix": [change3, change4],
"docs": [change5]
}
// 生成基础 Markdown
## ✨ Features
- add OAuth support in #123 by @Alice
- add email verification in #124 by @Bob
## 🐛 Bug Fixes
- handle null response in #125 by @Charlie缺点:
5. GitHub Release 创建API 调用: POST /repos/iflytek/skillhub/releases
{
"tag_name": "v0.3.0",
"name": "v0.3.0",
"body": "# SkillHub v0.3.0\n\n...",
"draft": true, // 关键:创建为 draft
"prerelease": false
}Draft 状态的作用:
Publish 后:
技术栈
配置优先级默认配置: {
baseUrl: "https://models.inference.ai.azure.com",
apiKey: github.token, // 自动注入
model: "gpt-4o-mini",
temperature: 0.2 // 低温度 = 更稳定输出
}为什么这样设计
这就是整个系统的工作原理。 |
使用方法(精简版)🚀 最常用:自动发布# 1. 创建并推送 tag
git tag v0.3.0
git push origin v0.3.0
# 2. 等待 1-2 分钟,自动生成 draft release
# 3. 打开 GitHub 检查并发布
# https://github.com/iflytek/skillhub/releases
# 点击 "Publish release"就这么简单! 🔍 提前预览(推送前先看看)GUI 方式:
终端方式: # 只预览,不创建 release
export RELEASE_NOTES_LLM_BASE_URL="https://models.inference.ai.azure.com"
export RELEASE_NOTES_LLM_API_KEY=$(gh auth token)
export RELEASE_NOTES_LLM_MODEL="gpt-4o-mini"
export GH_TOKEN=$(gh auth token)
deno run --allow-env --allow-net --allow-run --allow-read \
.github/scripts/release-notes.ts \
--owner iflytek --repo skillhub \
--tag v0.3.0 --dry-run⚙️ 配置(可选)默认零配置,使用 GitHub Models 免费 API。 如需自定义,在 GitHub 仓库设置:
✅ 检查清单Draft release 应包含:
推荐流程: Push tag → 等待 → 检查 draft → Publish ✨ |
修改模板内容📝 编辑模板文件# 模板位置
.github/release-template.md🎨 可以修改的内容1. 调整 Section 顺序 # 把 Breaking Changes 放到最前面
## 🚨 Breaking Changes
## 🌟 Highlights
## ✨ Features
...2. 添加新 Section ## 🔐 Security
- {{Security fixes}} by @author in #PR
## 🌍 Internationalization
- {{i18n changes}} by @author in #PR3. 修改 Emoji 和标题 ## 💡 New Features # 改用灯泡
## 🐞 Fixes # 改用瓢虫4. 调整内容格式 # 改为表格格式
## ✨ Features
| Feature | PR | Author |
|---------|----|----|
| {{description}} | #PR | @author |5. 添加固定内容 ## 📦 Installation
\`\`\`bash
npm install @iflytek/skillhub@{{version}}
\`\`\`
## ⚠️ Known Issues
- Issue #123: ...🔄 生效方式方式 1: 直接修改(推荐) # 1. 编辑模板
vim .github/release-template.md
# 2. 提交
git add .github/release-template.md
git commit -m "docs: update release notes template"
git push
# 3. 下次生成时自动使用新模板方式 2: 测试后再提交 # 1. 修改模板
vim .github/release-template.md
# 2. 本地测试
deno run --allow-env --allow-net --allow-run --allow-read \
.github/scripts/release-notes.ts \
--owner iflytek --repo skillhub \
--tag v0.2.4 --dry-run
# 3. 确认效果后提交
git add .github/release-template.md
git commit -m "docs: update release notes template"
git push💡 模板变量可用的占位符:
📋 示例:添加升级指南# SkillHub {{version}}
{{One-line summary}}
## 🌟 Highlights
...
## 📖 Upgrade Guide
### From {{prev_tag}} to {{version}}
1. Update dependencies:
\`\`\`bash
npm update
\`\`\`
2. Run migrations:
\`\`\`bash
npm run migrate
\`\`\`
3. Update configuration:
- Add `NEW_CONFIG=value` to `.env`
## 🚨 Breaking Changes
...⚙️ 高级:修改 Prompt如果想改变 AI 的生成风格,编辑: .github/scripts/release-notes-generator.ts找到 const systemPrompt = `You are a senior product manager...
Requirements:
1. Use more technical language // 改为技术化
2. Add code examples for each feature // 添加代码示例
3. Include performance metrics // 包含性能指标
...
`;总结: 直接编辑 |
Summary
Add automated release notes generation using GitHub Models (GPT-4o-mini) with zero configuration required.
Features
git push origin v0.3.0)Implementation
.github/release-template.md- Release notes template.github/scripts/release-notes-generator.ts- Core logic (collect commits, LLM generation, fallback).github/scripts/release-notes-config.ts- Configuration reader.github/scripts/release-notes.ts- Entry point.github/workflows/release-notes.yml- GitHub Actions workflowgithub.tsandissue-llm-provider.tswith release-related methodsTesting
Local dry-run tested with v0.2.4:
Output includes:
Next Steps
After merge, test cloud execution:
v0.2.4Future releases will trigger automatically on tag push.