Files
knowledge-base/4 - Resources/Engineering/Billo Release & PR Review Workflow.md

184 lines
5.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
created: "2026-03-17"
type: resource
tags: [engineering, workflow, azure-devops, jira, slack, billo]
source: "C:/Users/yaoji/git/Billo/release-workflow/SKILL.md"
---
# Billo Release & PR Review Workflow
## 概述
基于 Azure DevOps + Jira + Slack 的半自动化发布和 PR review 工作流。通过告知 Claude PR 链接或指令触发,自动执行 Jira 状态变更、PR merge、release notes 生成、Slack 通知等操作。
## 工具栈
| 工具 | 用途 |
|------|------|
| Azure DevOps CLI (`az`) | PR 管理、repo 操作 |
| jira-cli v1.7.0 | Jira ticket 状态变更、link 记录 |
| jq | JSON 处理release-staging.json|
| Slack Incoming Webhook | 发送 release 通知 |
| git worktree | PR code review 隔离环境 |
## 配置信息
- **Jira**: https://billolife.atlassian.net
- **Azure DevOps**: https://dev.azure.com/billodev / Project: Billo App Platform
- **本地 Repo 根目录**: `C:/Users/yaoji/git/Billo/`
- **Skill 文件**: `C:/Users/yaoji/git/Billo/release-workflow/SKILL.md`
- **Staging 文件**: `C:/Users/yaoji/git/Billo/release-workflow/release-staging.json`
- **Release 归档**: `C:/Users/yaoji/git/Billo/release-workflow/releases/`
## Branch 命名规则
格式:`{任意前缀}/{TICKET_ID}_{description}`
```
feature/ALLPOST-4028_login-page
feat/ALLPOST-4028_login-page
bug/ALLPOST-4029_fix-logout-redirect
fix/ALLPOST-4030_crash
chore/ALLPOST-4031_cleanup
```
Ticket ID 提取正则:
```bash
TICKET_ID=$(echo "$BRANCH" | sed -E 's#[^/]+/([A-Z]+-[0-9]+)_.*#\1#')
```
## Jira 状态流转
```
Dev in Progress
↓ (PR 提交 review)
code review
↓ (review 有 comment)
Code review comment
↓ (review 通过PR merge to develop)
Ready for stage (2)
↓ (release PR merge to main)
Done
```
---
## 工作流一PR Merge 到 develop
**触发**:给 Claude PR 链接approve + merge 场景)
**执行步骤**
1. 解析 PR URL → 提取 repo 名、PR ID
2. 获取 branch 名 → 提取 ticket ID
3. Merge PR`az repos pr update --status completed`
4. 移动 Jira ticket → `Ready for stage (2)`
5. 在 Jira ticket 上记录 PR remote link
6. 计算版本号(从 `releases/` 目录最新版本 patch +1首次为 `v1.0.0`
7. 追加 ticket 信息到 `release-staging.json`
**release-staging.json 格式**
```json
{
"version": "v1.0.0",
"repo": "Billo.Platform.Document",
"started_at": "2026-03-17",
"tickets": [
{
"id": "ALLPOST-4219",
"summary": "Test release bot",
"pr_id": "10460",
"pr_url": "https://dev.azure.com/...",
"pr_title": "chore: trigger release bot test",
"branch": "feature/ALLPOST-4219_test_release_bot",
"merged_at": "2026-03-17"
}
]
}
```
---
## 工作流二:准备 Release
**触发**:告知 Claude `"准备 release"`
**执行步骤**
1. 读取 `release-staging.json`
2. 显示 ticket 列表供确认
3. 创建 `develop → main` PR描述包含所有 ticket 列表
---
## 工作流三Release 完成
**触发**:告知 Claude `"release PR merged"`
**执行步骤**
1. Merge release PR
2. 所有 ticket 状态移动 → `Done`
3. 发送 Slack 通知
4. 归档 `release-staging.json``releases/v1.0.0.json`
5. 重置 `release-staging.json` 准备下个版本
**Slack 消息格式**rich_text Block Kit
```
Release - Billo.Platform.Document (2026-03-17) ← 加粗标题
• ALLPOST-4219 Test release bot ← bullet + 可点击 Jira 链接
• ALLPOST-4220 Fix login redirect
```
> [!important]
> 使用 Slack `rich_text` Block Kit非 `mrkdwn`),避免 Windows 环境下 emoji 和中文乱码bullet 正常渲染。
---
## 工作流四PR Code Review
**触发**:给 Claude PR 链接(说明要 review
**执行步骤**
1. 解析 PR URL → 提取 repo、branch、ticket ID
2. 移动 Jira ticket → `code review`(无 ticket ID 则跳过)
3. `git fetch` branch + 创建 git worktree路径`C:/Users/yaoji/git/_reviews/pr-{PR_ID}`
4. 启动 code-reviewer agent分析所有变更的 `.cs` 文件
5. 输出结构化 review 报告CRITICAL / HIGH / MEDIUM / LOW
6. **有 comment** → 列出 issues移动 Jira → `Code review comment`,等待用户决定
7. **无 comment** → APPROVE等待用户决定是否 merge
8. 清理 worktree
---
## 版本号规则
- 自动从 `releases/` 目录读取最新版本patch +1
- 例:最新 `v1.0.2` → 下个版本 `v1.0.3`
- 首次(`releases/` 为空)→ `v1.0.0`
---
## 触发关键词速查
| 你说的 | Claude 执行 |
|--------|------------|
| PR 链接(无其他说明) | 工作流一merge + Jira + staging |
| `"准备 release"` | 工作流二:创建 release PR |
| `"release PR merged"` | 工作流三Jira Done + Slack + 归档 |
| PR 链接 + `"review"` | 工作流四code review |
---
## 环境变量(~/.bashrc
```bash
export JIRA_API_TOKEN="..."
export JIRA_AUTH_TYPE=basic
export SLACK_WEBHOOK_URL="https://hooks.slack.com/services/..."
export AZURE_DEVOPS_EXT_PAT="..."
export PATH="/c/Program Files/Microsoft SDKs/Azure/CLI2/wbin:/c/Users/yaoji/AppData/Local/Microsoft/WinGet/Links:/c/Users/yaoji/bin:/usr/bin:/bin:$PATH"
```
## Related
- [[OpenClaw-Skill-Reference]]
- [[Everything Claude Code 完整指南]]