github-release
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGitHub Release Skill
GitHub Release Skill
This skill automates the full release workflow for a single-package GitHub repository,
from analysis through changelog authoring and PR creation. It relies exclusively on
(GitHub CLI) and no other tools needed.
ghgitSteps 1 - 4 are read-only reconnaissance nothing is written to the repo until
Step 5, once the version number is confirmed.
此 Skill 自动化单包 GitHub 仓库的完整发布工作流,涵盖分析、编写 changelog 和创建 PR。它仅依赖 (GitHub CLI)和 ,不需要其他工具。
ghgit步骤 1 - 4 是 只读侦察;在步骤 5 确认版本号之前,不会向仓库写入任何内容。
When to Use This Skill
何时使用此 Skill
Use this skill whenever the user wants to cut a new release, publish a new version,
bump a version, create a release branch, generate a changelog, or open a release PR
on a GitHub repository. Trigger even if the user says something casual like "let's
ship a new version" or "time to release".
每当用户想要发布新版本、发布新版、升级版本号、创建发布分支、生成 changelog,或为 GitHub 仓库创建发布 PR 时,都应使用此 Skill。即使用户只是随口说“让我们发布一个新版本”或“该发版了”,也应触发。
Prerequisites
前置条件
Examples below include both Bash and PowerShell variants; Windows users should prefer
the PowerShell blocks.
Before starting, verify the environment:
bash
gh auth status # must be authenticated
gh repo view --json nameWithOwner # must be inside a GitHub repo
git status # working tree should be cleanIf any check fails, stop and tell the user what to fix before continuing.
Then ask the user one question:
"Which directory contains your library's public-facing source code? (e.g.,src/,lib/- used to focus the diff on what consumers actually see. Press Enter to scan the whole repo.)"pkg/
Store the answer as . If empty, is (repo root).
Exclude these paths from all diffs regardless: , , ,
, , , , , generated files
(files with a "do not edit" header comment), and build artefacts.
PUBLIC_PATHPUBLIC_PATH.tests/test/spec/__tests__/docs/*.lock*-lock.json*.sum以下示例同时包含 Bash 和 PowerShell 两种版本;Windows 用户应优先使用 PowerShell 代码块。
开始前,验证环境:
bash
gh auth status # must be authenticated
gh repo view --json nameWithOwner # must be inside a GitHub repo
git status # working tree should be clean如果任何检查失败,请停止并告知用户需要先修复什么,然后再继续。
然后向用户提出一个问题:
"你的库的面向用户的源代码位于哪个目录? (例如、src/、lib/——用于将 diff 聚焦于使用者实际可见的内容。按 Enter 扫描整个仓库。)"pkg/
将答案保存为 。如果答案为空,则 为 (仓库根目录)。
无论何种情况,都从所有 diff 中排除以下路径:、、、、、、、、生成文件(文件头注释中含有 "do not edit")以及构建产物。
PUBLIC_PATHPUBLIC_PATH.tests/test/spec/__tests__/docs/*.lock*-lock.json*.sumThe 9-Step Release Workflow
9 步发布工作流
Work through every step in order. Show the user what command you're about to run and
its output. Pause and ask for confirmation only when explicitly noted.
按顺序完成每个步骤。向用户展示即将运行的命令及其输出。仅在明确标注的位置暂停并请求确认。
Step 1 - Ensure main is up to date
步骤 1 - 确保 main 为最新状态
bash
git checkout main
git pull origin mainStay on for now. The release branch is created in Step 5, after the version
is confirmed.
mainbash
git checkout main
git pull origin main暂时保持在 。发布分支将在步骤 5 创建,即版本确认之后。
mainStep 2 - Grab the latest version tag
步骤 2 - 获取最新的版本 tag
Why not? GitHub Releases are an optional layer on top of Git tags. Many repos tag releases withgh release listwithout ever creating a GitHub Release, sogit tagcan return empty even when version tags exist. Reading tags directly from git is the reliable source of truth.gh release list
bash
undefined为什么不用? GitHub Releases 是构建在 Git tag 之上的可选层。许多仓库会使用gh release list标记发布,却从未创建 GitHub Release,因此即使版本 tag 已经存在,git tag也可能返回空结果。直接读取 git 中的 tag 才是可靠的事实来源。gh release list
bash
undefinedFetch all tags from remote to ensure local view is current
Fetch all tags from remote to ensure local view is current
git fetch --tags
git fetch --tags
Find the latest version tag, sorted semantically
Find the latest version tag, sorted semantically
--sort=-version:refname handles 1.10.0 > 1.9.0 correctly (unlike alphabetical)
--sort=-version:refname handles 1.10.0 > 1.9.0 correctly (unlike alphabetical)
PREV_TAG=$(git tag --sort=-version:refname | grep -E '^v?[0-9]+.[0-9]+.[0-9]+' | head -1)
echo "Latest tag: $PREV_TAG"
```PowerShellPREV_TAG=$(git tag --sort=-version:refname | grep -E '^v?[0-9]+.[0-9]+.[0-9]+' | head -1)
echo "Latest tag: $PREV_TAG"
```PowerShellFetch all tags from remote to ensure local view is current
Fetch all tags from remote to ensure local view is current
git fetch --tags
git fetch --tags
Find the latest version tag, sorted semantically
Find the latest version tag, sorted semantically
--sort=-version:refname handles 1.10.0 > 1.9.0 correctly (unlike alphabetical)
--sort=-version:refname handles 1.10.0 > 1.9.0 correctly (unlike alphabetical)
$prevTag = git tag --sort='-version:refname' |
Select-Object -First 1 -ExpandProperty Line
Select-String '^[vV]?\d+\.\d+\.\d+' |if ($prevTag) {
$prevSha = git rev-list -n 1 $prevTag
} else {
$prevSha = git rev-list --max-parents=0 HEAD
}
Write-Output "Latest tag: $prevTag"
Then verify the tag exists on the remote (not just locally):
```bash
git ls-remote --tags origin | grep "refs/tags/$PREV_TAG$"If the remote check returns nothing, warn the user that the tag appears to be local-only
and hasn't been pushed - they may want to push it before continuing.
- is the tag name exactly as found (e.g.
PREV_TAG). Strip any leadingv1.4.2when doing arithmetic; preserve it when naming things.v - If no tags exist at all, treat as
PREV_TAG, set(none)to the first commit, and default the new version toPREV_SHA(skip Step 4 versioning logic; go straight to Step 5).1.0.0 - If the tag does not point to a real commit (orphaned tag), fall back to
and warn the user.
git rev-list --max-parents=0 HEAD
bash
PREV_SHA=$(git rev-list -n 1 "$PREV_TAG" 2>/dev/null || git rev-list --max-parents=0 HEAD)$prevTag = git tag --sort='-version:refname' |
Select-Object -First 1 -ExpandProperty Line
Select-String '^[vV]?\d+\.\d+\.\d+' |if ($prevTag) {
$prevSha = git rev-list -n 1 $prevTag
} else {
$prevSha = git rev-list --max-parents=0 HEAD
}
Write-Output "Latest tag: $prevTag"
然后验证 tag 存在于远程仓库中,而不仅仅存在于本地:
```bash
git ls-remote --tags origin | grep "refs/tags/$PREV_TAG$"如果远程检查没有返回任何结果,请警告用户:该 tag 似乎仅存在于本地,尚未推送——用户可能需要先推送它再继续。
- 是找到的 tag 的确切名称(例如
PREV_TAG)。进行算术运算时去掉前导v1.4.2;命名时则保留。v - 如果完全不存在任何 tag,将 视为
PREV_TAG,把(none)设为首个 commit,并将新版本默认设为PREV_SHA(跳过步骤 4 的版本逻辑;直接进入步骤 5)。1.0.0 - 如果 tag 未指向真实 commit(孤立 tag),回退到 并警告用户。
git rev-list --max-parents=0 HEAD
bash
PREV_SHA=$(git rev-list -n 1 "$PREV_TAG" 2>/dev/null || git rev-list --max-parents=0 HEAD)Step 3 - Analyse what changed since the last release
步骤 3 - 分析上次发布以来发生的变更
This step uses two complementary signals. The code diff is the primary source of
truth; commit messages provide supporting context about intent.
此步骤使用两个互补的信号。代码 diff 是主要事实来源;commit message 为变更意图提供辅助上下文。
3a - Code diff (primary signal)
3a - 代码 diff(主要信号)
bash
undefinedbash
undefinedFocused diff on the public source path, excluding noise
Focused diff on the public source path, excluding noise
git diff "$PREV_SHA"..HEAD -- "$PUBLIC_PATH"
':(exclude)tests/' ':(exclude)test/' ':(exclude)spec/'
':(exclude)tests/' ':(exclude)docs/'
':(exclude).lock' ':(exclude)-lock.json' ':(exclude)*.sum'
':(exclude)tests/' ':(exclude)test/' ':(exclude)spec/'
':(exclude)tests/' ':(exclude)docs/'
':(exclude).lock' ':(exclude)-lock.json' ':(exclude)*.sum'
```PowerShellgit diff "$PREV_SHA"..HEAD -- "$PUBLIC_PATH"
':(exclude)tests/' ':(exclude)test/' ':(exclude)spec/'
':(exclude)tests/' ':(exclude)docs/'
':(exclude).lock' ':(exclude)-lock.json' ':(exclude)*.sum'
':(exclude)tests/' ':(exclude)test/' ':(exclude)spec/'
':(exclude)tests/' ':(exclude)docs/'
':(exclude).lock' ':(exclude)-lock.json' ':(exclude)*.sum'
```PowerShellFocused diff on the public source path, excluding noise
Focused diff on the public source path, excluding noise
git diff "$($prevSha)..HEAD" -- $publicPath
':(exclude)tests/' ':(exclude)docs/' `
':(exclude).lock' ':(exclude)-lock.json' ':(exclude)*.sum'
':(exclude)tests/' ':(exclude)test/' ':(exclude)spec/'
Read the full diff output. For each changed file, identify:
1. **Removed symbols** - functions, classes, methods, constants, exported names that
existed before and are now gone. ? Strong signal for MAJOR.
2. **Changed signatures** - functions that exist in both versions but with different
parameters, return types, or thrown errors. ? Strong signal for MAJOR.
3. **New exported symbols** - public functions, classes, constants that didn't exist
before. ? Signal for MINOR.
4. **Internal-only changes** - modifications that don't touch any public interface
(private helpers, unexported functions, algorithm internals). ? PATCH.
5. **Bug fixes** - corrections to logic that was provably wrong (e.g. off-by-one,
null check, wrong condition), without changing the public API. ? PATCH.
If the diff is very large (thousands of lines), first run the stat summary to
prioritise which files to read in full:
```bash
git diff "$PREV_SHA"..HEAD --stat -- "$PUBLIC_PATH"Focus your detailed reading on files with the most changes and files whose names
suggest they define public interfaces (e.g. , , ,
, , ).
index.*api.*exports.*public.*mod.*__init__.*git diff "$($prevSha)..HEAD" -- $publicPath
':(exclude)tests/' ':(exclude)docs/' `
':(exclude).lock' ':(exclude)-lock.json' ':(exclude)*.sum'
':(exclude)tests/' ':(exclude)test/' ':(exclude)spec/'
完整阅读 diff 输出。对于每个发生变更的文件,识别:
1. **已移除的符号**——此前存在、现已消失的函数、类、方法、常量或导出名称。→ 强烈表明应升级 MAJOR。
2. **签名变更**——两个版本中都存在、但参数、返回类型或抛出的错误不同的函数。→ 强烈表明应升级 MAJOR。
3. **新增导出符号**——此前不存在的公共函数、类或常量。→ 表明应升级 MINOR。
4. **仅限内部的变更**——未触及任何公共接口的修改(私有辅助函数、未导出函数、算法内部实现)。→ PATCH。
5. **Bug 修复**——对可证明存在错误的逻辑进行修正(例如差一错误、空值检查、错误条件),且未改变公共 API。→ PATCH。
如果 diff 非常大(数千行),先运行统计摘要,以确定优先完整阅读哪些文件:
```bash
git diff "$PREV_SHA"..HEAD --stat -- "$PUBLIC_PATH"详细阅读应聚焦于变更最多的文件,以及文件名表明其定义公共接口的文件(例如 、、、、、)。
index.*api.*exports.*public.*mod.*__init__.*3b - Commit log (secondary signal)
3b - Commit log(辅助信号)
bash
git log "$PREV_SHA"..HEAD --oneline --no-mergesUse this to:
- Understand the intent behind code changes that aren't self-explanatory from the diff alone (e.g. a one-line security fix labelled as such).
- Catch changes that may be in paths outside but are still user-visible (e.g. a CLI flag change in a
PUBLIC_PATHdirectory).cmd/ - Fill in context for changelog entries where the code alone doesn't tell the whole story.
See for mapping message patterns to change types.
references/commit-classification.mdbash
git log "$PREV_SHA"..HEAD --oneline --no-merges使用它来:
- 理解仅凭 diff 无法明确说明的代码变更背后的意图(例如一行代码的安全修复虽在 commit message 中有明确标注)。
- 捕获 之外路径中可能发生的变更,但这些变更仍对用户可见(例如
PUBLIC_PATH目录中的 CLI flag 变更)。cmd/ - 为代码本身无法完整呈现的 changelog 条目补充上下文。
请参阅 ,了解如何将 message 模式映射到变更类型。
references/commit-classification.md3c - Reconcile the two signals
3c - 协调两个信号
When signals agree ? use that classification with confidence.
When signals conflict ? prefer the code diff. Examples:
- Commit says but the diff shows a removed public method ? treat as MAJOR.
fix: typo - Commit says but the diff only touches private internals ? treat as PATCH.
feat: new API - Commit says but the diff adds new exported symbols ? treat as MINOR.
chore: refactor
Document any conflicts you notice - flag them to the user during the changelog review
in Step 6.
当两个信号一致时 → 使用该分类并给予高度确信。
当两个信号冲突时 → 优先采用代码 diff。示例:
- Commit 表示 ,但 diff 显示移除了一个公共方法 → 按 MAJOR 处理。
fix: typo - Commit 表示 ,但 diff 只涉及私有内部实现 → 按 PATCH 处理。
feat: new API - Commit 表示 ,但 diff 新增了导出符号 → 按 MINOR 处理。
chore: refactor
记录发现的任何冲突——在步骤 6 的 changelog 审查期间向用户标记。
Step 4 - Determine the next SemVer version
步骤 4 - 确定下一个 SemVer 版本
Apply these rules to your analysis from Step 3 (full rules in ):
references/semver-rules.md| Condition | Bump |
|---|---|
| Any breaking change to public API (removal, signature change, behaviour change) | MAJOR |
| New exported symbol or feature, no breaking changes | MINOR |
| Bug fix, perf improvement, security fix, docs, chore only | PATCH |
When a release contains a mix, the highest precedence wins:
.
MAJOR > MINOR > PATCHCompute :
NEXT_VERSION- Split into
PREV_TAGintegers.MAJOR.MINOR.PATCH - Apply the appropriate bump.
- Format as .
vMAJOR.MINOR.PATCH
Present the proposed version to the user with a brief rationale that cites
specific code findings, not just commit messages. Example:
"I'm proposing v2.1.0. The diff shows two new exported functions (andNewClient) inWithTimeout, and no existing public symbols were removed or changed. Commit messages corroborate this as feature additions."src/client.go
Ask: "Does this version look right, or would you like to adjust it?"
Wait for confirmation before proceeding.
根据步骤 3 的分析应用以下规则(完整规则见 ):
references/semver-rules.md| 条件 | 升级类型 |
|---|---|
| 公共 API 的任何破坏性变更(移除、签名变更、行为变更) | MAJOR |
| 新增导出符号或功能,且没有破坏性变更 | MINOR |
| Bug 修复、性能改进、安全修复、文档、杂务 | PATCH |
当一次发布包含多种类型时,优先级最高的类型胜出:
。
MAJOR > MINOR > PATCH计算 :
NEXT_VERSION- 将 拆分为整数形式的
PREV_TAG。MAJOR.MINOR.PATCH - 应用相应的版本升级。
- 格式化为 。
vMAJOR.MINOR.PATCH
向用户提出建议版本,并给出简短理由,引用具体的代码发现,而不只引用 commit message。示例:
"我建议使用 v2.1.0。diff 显示中新增了两个导出函数(src/client.go和NewClient),且没有现有公共符号被移除或修改。Commit message 也印证了这是功能新增。"WithTimeout
询问:"这个版本合适吗?或者你希望进行调整?"
继续之前等待确认。
Step 5 - Create the release branch
步骤 5 - 创建发布分支
Now that the version is confirmed, create the branch with the correct name from the start:
bash
git checkout -b release/vX.Y.Z
git push -u origin release/vX.Y.Z现在版本已经确认,从一开始就使用正确的名称创建分支:
bash
git checkout -b release/vX.Y.Z
git push -u origin release/vX.Y.ZStep 6 - Update CHANGELOG.md
步骤 6 - 更新 CHANGELOG.md
Read the existing (or create it if absent). Follow the
Keep a Changelog format strictly.
CHANGELOG.mdStructure to insert at the top (just below the header):
# Changelogmarkdown
undefined读取现有的 (如果不存在则创建)。严格遵循 Keep a Changelog 格式。
CHANGELOG.md要在顶部插入的结构(紧接在 标题下方):
# Changelogmarkdown
undefined[X.Y.Z] - YYYY-MM-DD
[X.Y.Z] - YYYY-MM-DD
Added
Added
- ...
- ...
Changed
Changed
- ...
- ...
Deprecated
Deprecated
- ...
- ...
Removed
Removed
- ...
- ...
Fixed
Fixed
- ...
- ...
Security
Security
- ...
Rules:
- Use today's date in `YYYY-MM-DD` format.
- Omit sections that have no entries - don't leave empty headings.
- Write entries in **plain English from a user's perspective**, derived primarily
from what the code diff shows, supplemented by commit message context.
Good: *"Added `WithTimeout` option to HTTP client constructor."*
Bad: *"feat: add timeout cfg param"*
- Map findings to sections:
- New exported symbol ? Added
- Breaking removal ? Removed
- Breaking change to existing API ? Changed (flag it as breaking)
- Bug/logic fix, perf ? Fixed
- Security fix ? Security
- Internal refactor, docs, chore, test ? omit unless user-visible
- If a commit message revealed intent that the code diff alone wouldn't convey
(e.g. a security fix disguised as a one-line change), include that context in
the changelog entry.
- Also update the diff link at the bottom of the file:
```markdown
[X.Y.Z]: https://github.com/OWNER/REPO/compare/vPREV...vNEXTShow the user the proposed changelog section before writing it to disk.
If any signal conflicts were found in Step 3c, flag them here so the user can verify.
Ask: "Does this changelog look accurate? Any entries to add, remove, or reword?"
Incorporate feedback, then write to disk.
- ...
规则:
- 使用今天的日期,格式为 `YYYY-MM-DD`。
- 省略没有任何条目的分区——不要留下空标题。
- 主要依据代码 diff 显示的内容,并辅以 commit message 上下文,以**面向用户的通俗英文**编写条目。
正确:*"Added `WithTimeout` option to HTTP client constructor."*
错误:*"feat: add timeout cfg param"*
- 将发现映射到各分区:
- 新增导出符号 → Added
- 破坏性移除 → Removed
- 对现有 API 的破坏性变更 → Changed(并标记为 breaking)
- Bug 或逻辑修复、性能改进 → Fixed
- 安全修复 → Security
- 内部重构、文档、杂务、测试 → 除非对用户可见,否则省略
- 如果 commit message 揭示了仅靠代码 diff 无法传达的意图(例如伪装成一行代码修改的安全修复),请在 changelog 条目中包含这些上下文。
- 还要更新文件底部的 diff link:
```markdown
[X.Y.Z]: https://github.com/OWNER/REPO/compare/vPREV...vNEXT在写入磁盘前,向用户展示建议的 changelog 段落。
如果步骤 3c 中发现任何信号冲突,请在此标记,以便用户验证。
询问:"这个 changelog 准确吗?需要添加、删除或改写任何条目吗?"
纳入反馈后,再写入磁盘。
Step 7 - Commit and push
步骤 7 - 提交并推送
bash
git add CHANGELOG.md
git commit -m "chore: release vX.Y.Z"
git push origin release/vX.Y.ZConfirm the push succeeded before moving on.
bash
git add CHANGELOG.md
git commit -m "chore: release vX.Y.Z"
git push origin release/vX.Y.Z确认推送成功后继续。
Step 8 - Open a Pull Request
步骤 8 - 创建 Pull Request
?? IMPORTANT: Always use to pass PR body text, never with inline text.
Inline escape sequences like are not interpreted as newlines by PowerShell and will appear
as literal text in the PR. Using a file ensures proper markdown formatting.
--body-file--body\nbash
gh pr create \
--base main \
--head release/vX.Y.Z \
--title "Release vX.Y.Z" \
--body "$(cat <<'EOF'⚠️ 重要: 始终使用 传递 PR 正文,绝不要使用带内联文本的 。
PowerShell 不会将内联转义序列(例如 )解释为换行,而会将其显示为字面文本。使用文件可确保 Markdown 格式正确。
--body-file--body\nbash
gh pr create \
--base main \
--head release/vX.Y.Z \
--title "Release vX.Y.Z" \
--body "$(cat <<'EOF'Release vX.Y.Z
Release vX.Y.Z
This PR prepares the vX.Y.Z release.
This PR prepares the vX.Y.Z release.
What's included
What's included
<!-- paste the changelog section here -->
<!-- paste the changelog section here -->
Checklist
Checklist
- Changelog reviewed
- Version bump verified
- CI passing
After merging, create the tag on the merge commit:
```
git tag vX.Y.Z <merge-commit-sha>
git push origin vX.Y.Z
```
EOF
)"
````PowerShell- Changelog reviewed
- Version bump verified
- CI passing
After merging, create the tag on the merge commit:
```
git tag vX.Y.Z <merge-commit-sha>
git push origin vX.Y.Z
```
EOF
)"
````PowerShellCreate PR body using here-string (preserves actual newlines, not escape sequences)
Create PR body using here-string (preserves actual newlines, not escape sequences)
$prBody = @"
$prBody = @"
Release vX.Y.Z
Release vX.Y.Z
This PR prepares the vX.Y.Z release.
This PR prepares the vX.Y.Z release.
What's included
What's included
<paste changelog here>
<paste changelog here>
Checklist
Checklist
- Changelog reviewed
- Version bump verified
- CI passing
After merging, create the tag on the merge commit:
git tag vX.Y.Z <merge-commit-sha>
git push origin vX.Y.Z"@
- Changelog reviewed
- Version bump verified
- CI passing
After merging, create the tag on the merge commit:
git tag vX.Y.Z <merge-commit-sha>
git push origin vX.Y.Z"@
Write to file and use --body-file (do NOT use inline --body with escape sequences)
Write to file and use --body-file (do NOT use inline --body with escape sequences)
$prBody | Out-File -FilePath release_pr_body.md -Encoding utf8 -NoNewline
gh pr create --base main --head release/vX.Y.Z --title "Release vX.Y.Z" --body-file release_pr_body.md
Paste the changelog section into the PR body's "What's included" block (or leave placeholder for manual review).
---$prBody | Out-File -FilePath release_pr_body.md -Encoding utf8 -NoNewline
gh pr create --base main --head release/vX.Y.Z --title "Release vX.Y.Z" --body-file release_pr_body.md
将 changelog 段落粘贴到 PR 正文的 "What's included" 区块中,或者保留占位符供人工审查。
---Step 9 - Hand off to the user
步骤 9 - 移交给用户
Tell the user:
Release PR is open! ??New version: vX.Y.ZOnce the PR is reviewed and merged, you'll need to create the tag yourself on the merge commit:bashgit tag vX.Y.Z <merge-commit-sha> git push origin vX.Y.ZThen go to GitHub Releases and publish the release from that tag. You can copy the changelog section directly into the release notes.
告知用户:
发布 PR 已创建!🎉新版本:vX.Y.ZPR 审核并合并后,你需要在 merge commit 上自行创建 tag:bashgit tag vX.Y.Z <merge-commit-sha> git push origin vX.Y.Z然后前往 GitHub Releases,并从该 tag 发布版本。你可以直接将 changelog 段落复制到 release notes 中。
Error handling
错误处理
| Situation | What to do |
|---|---|
| Stop; tell user to run |
| Not inside a git repo | Stop; tell user to |
| Working tree is dirty | Warn; ask if they want to stash or abort |
| No commits since last tag | Tell user there's nothing to release |
| Tag exists but points to no commit | Use first commit as diff base; warn user |
| Latest tag exists locally but not on remote | Warn user; ask if they want to push the tag first or continue anyway |
Diff is empty for | Warn; all changes may be internal; ask if they still want to proceed |
| Report the error verbatim; suggest they check branch protection settings |
| 情况 | 处理方式 |
|---|---|
| 停止;告知用户运行 |
| 当前不在 git 仓库中 | 停止;告知用户使用 |
| 工作区不干净 | 警告;询问用户是希望 stash 还是中止 |
| 自上次 tag 后没有 commit | 告知用户没有可发布的内容 |
| tag 存在但未指向任何 commit | 使用首个 commit 作为 diff 基准;警告用户 |
| 最新 tag 仅存在于本地,远程不存在 | 警告用户;询问是希望先推送 tag,还是无论如何继续 |
| 警告;所有变更可能都属于内部修改;询问用户是否仍要继续 |
| 原样报告错误;建议用户检查分支保护设置 |
Troubleshooting in PowerShell
PowerShell 故障排除
- If a command that works locally prints gh usage or treats a subcommand as separate token, ensure you're invoking the gh.exe on PATH (Get-Command gh) and avoid passing unexpanded nested substitutions; use the PowerShell patterns above.
- Recommend tests: gh --version; git fetch --tags; run the PowerShell snippet to set $prevTag and run git diff --name-only $prevSha..HEAD -- src/
- 如果某个在本地可正常运行的命令打印了 gh usage,或将子命令视为单独的 token,请确保调用的是 PATH 中的 gh.exe(Get-Command gh),并避免传递未展开的嵌套替换;请使用上述 PowerShell 模式。
- 建议测试:gh --version;git fetch --tags;运行 PowerShell 代码片段设置 $prevTag,并执行 git diff --name-only $prevSha..HEAD -- src/
Limitations
限制
- Requires the CLI to be installed and authenticated.
gh - Requires git tags to determine current version.
- 要求已安装 CLI 并完成认证。
gh - 要求使用 git tag 确定当前版本。
Reference files
参考文件
- - Extended SemVer decision rules and edge cases
references/semver-rules.md - - Heuristics for classifying commit messages into change types
references/commit-classification.md
- - 扩展的 SemVer 决策规则和边缘情况
references/semver-rules.md - - 将 commit message 分类为变更类型的启发式规则
references/commit-classification.md