pub fn publish(
version: &str,
repo_path: &Path,
yes: bool,
registry: Option<Registry>,
) -> Result<(), Box<dyn Error>>Expand description
发布版本。
内部处理流程:
- 校验版本号格式(需匹配
vX.Y.Z或scope/vX.Y.Z) - 校验 CHANGELOG.md 存在且包含对应版本记录
- 用户确认(除非
yes = true) - 创建 git tag(幂等,已存在时跳过)
- 推送 tag 到远端(无远端时静默跳过)
- 创建 GitHub Release(幂等,已存在时跳过)
- 打印 registry 发布提示(不实际发布,由 CI 执行)
回滚:步骤 5 失败时删除本地 tag;步骤 6 失败时删除本地和远端 tag。
§参数
version: 版本号。格式vX.Y.Z或scope/vX.Y.Z(如cli/v0.5.0)repo_path: git 仓库路径yes: 跳过用户确认registry: CI 发布目标提示(仅打印,不执行)