|
| 1 | +--- |
| 2 | +name: release |
| 3 | +description: Guides Sourcegraph CLI patch, minor, and major releases. Use when preparing release branches, selecting patch commits, running Trivy checks, creating release tags, or managing local/pushed release artifacts. |
| 4 | +--- |
| 5 | + |
| 6 | +# Release |
| 7 | + |
| 8 | +## Infer the release plan |
| 9 | + |
| 10 | +Gather only the information that is actually missing. Do not ask questions whose answers can be derived safely from tags, release branches, repository conventions, or the user's wording. |
| 11 | + |
| 12 | +Proceed without clarification when the user has already provided enough intent, for example: |
| 13 | + |
| 14 | +- "create a minor release `7.3.0`" |
| 15 | +- "cut the next major release from main" |
| 16 | +- "create a patch release" plus exact versions such as `7.2.2` and `7.1.3` |
| 17 | +- "next patch for current and one minor back" |
| 18 | +- "inspect main and decide what is patch-worthy" |
| 19 | +- "create everything locally first" |
| 20 | + |
| 21 | +Before asking the user anything, derive the release plan: |
| 22 | + |
| 23 | +- `release_type`: from user wording or semver shape. |
| 24 | +- `version`: from the explicit user version, otherwise from existing tags. |
| 25 | +- `release_branch`: use the existing matching release branch when present; otherwise infer from recent branch convention. In this repository, use `release/<major>.<minor>.x`, for example `release/7.2.x` for `7.2.2`. |
| 26 | +- `source`: user-provided source, otherwise the repository default branch. |
| 27 | +- `tag`: repository's existing release tag format. In this repository, use the bare version as a signed annotated tag with message `Release v<version>`, for example `git tag -s 7.2.2 -m "Release v7.2.2"`. |
| 28 | +- `push_mode`: local-only unless the user explicitly asks to push. |
| 29 | +- `worktree_mode`: prefer temporary git worktrees when handling multiple release trains or when the current checkout is detached or managed by `jj`. |
| 30 | + |
| 31 | +Ask a narrow question only when a field cannot be inferred safely or the missing answer would change release artifacts or risk pushing/tagging the wrong thing: |
| 32 | + |
| 33 | +1. Release type, if not clear from the request or version number. |
| 34 | +2. Exact version, if it cannot be inferred from existing tags. |
| 35 | +3. Source branch, if it is not the default branch. |
| 36 | +4. Commit selection, only if the user has not provided commits/PRs and has not asked you to inspect history and decide. |
| 37 | +5. Whether to push, only after local branches/tags are ready. |
| 38 | + |
| 39 | +For version inference: |
| 40 | + |
| 41 | +- Inspect existing tags with `git tag --list --sort=-v:refname`. |
| 42 | +- Inspect release branches with `git branch -a --list '*release*'`. |
| 43 | +- For patch releases, increment the latest patch tag on the target release train. The current patch train is the highest release branch/tag line, for example `release/7.2.x` after `7.2.1` produces `7.2.2`. |
| 44 | +- For minor releases, increment the minor component from the latest released minor and set patch to `.0`, for example latest `7.2.1` produces `7.3.0`, unless the user specifies a different train. |
| 45 | +- For major releases, increment the major component and reset minor/patch to `.0.0`, for example latest `7.2.1` produces `8.0.0`, unless the user specifies a different train. |
| 46 | +- "One minor back" means the previous minor release branch, for example `release/7.1.x`; increment the latest patch tag on that line. |
| 47 | +- Confirm inferred versions in progress updates, but keep working unless the user asked for confirmation before mutation. |
| 48 | + |
| 49 | +## Hard stops |
| 50 | + |
| 51 | +Stop and ask before continuing if: |
| 52 | + |
| 53 | +- The working tree is dirty in a way not caused by this release work. |
| 54 | +- A release branch or tag would be pushed without explicit approval. |
| 55 | +- A force-push or tag replacement would be needed. |
| 56 | +- Trivy or required tests fail before tagging or pushing. |
| 57 | +- Cherry-pick conflicts remain unresolved. |
| 58 | +- The target branch for an existing patch train is missing. |
| 59 | + |
| 60 | +Never tag with a dirty working tree, unresolved conflicts, failed validation, or while checked out on the wrong branch. |
| 61 | + |
| 62 | +## Validation |
| 63 | + |
| 64 | +Before starting the release work: |
| 65 | + |
| 66 | +1. Make sure the working tree is clean with `git status`. |
| 67 | +2. Fetch current refs and tags with `git fetch --all --tags --prune`. |
| 68 | +3. Run Trivy before creating final release artifacts, and earlier when the release is vulnerability-driven. |
| 69 | + - For this repository, use `mise x trivy -- trivy fs --exit-code 1 --severity HIGH,CRITICAL`. |
| 70 | + - Use a different documented Trivy command only if the repository adds one. |
| 71 | + - If running from a temporary worktree, `mise` may require trusting that worktree's `mise.toml`. Run `mise trust -y <worktree>/mise.toml` when needed, then remove or untrust temporary state during cleanup. |
| 72 | + |
| 73 | +This repository is commonly used with `jj`, so `git status` may report `HEAD (no branch)`. Treat that as normal if the worktree is otherwise clean. |
| 74 | + |
| 75 | +## Execute the release |
| 76 | + |
| 77 | +Use the same workflow for patch, minor, and major releases. The release type mainly changes which commits from the source branch are included. |
| 78 | + |
| 79 | +1. Fetch refs/tags and inspect existing release branches/tags. |
| 80 | +2. Infer and state the release plan. |
| 81 | +3. Validate the source and target as required. |
| 82 | +4. Create or check out the target release branch: |
| 83 | + - For a new release line, create the release branch from the source branch. |
| 84 | + - For an existing release line, use the existing release branch. |
| 85 | + - Never create a new branch for an existing patch train unless the target branch is missing and the user explicitly confirms creating it. |
| 86 | +5. For patch releases, port only patch-worthy commits plus required remediation prerequisites with `git cherry-pick -x <sha>` when the target branch does not already contain them. |
| 87 | +6. For minor and major releases, branch from the intended source unless the user asked for exclusions. |
| 88 | +7. Resolve conflicts carefully and keep the release branch limited to selected commits and release-process changes. |
| 89 | +8. Validate every release branch after porting changes. |
| 90 | +9. Tag locally on the release branch. |
| 91 | +10. Push the release branch and tag only when requested or required by the release process and approved by the user. |
| 92 | + |
| 93 | +## Commit selection by release type |
| 94 | + |
| 95 | +For patch releases, include only patch-worthy commits. These are typically: |
| 96 | + |
| 97 | +- Critical bug fixes |
| 98 | +- Security fixes |
| 99 | +- Data-loss or correctness fixes |
| 100 | +- Low-risk operational fixes required for the release line |
| 101 | +- Toolchain, runtime, base-image, or dependency updates that are part of fixing a vulnerability, even if the commit message is phrased as `chore`, `update Go`, `bump`, or similar |
| 102 | + |
| 103 | +For patch releases, avoid including: |
| 104 | + |
| 105 | +- New features |
| 106 | +- Broad refactors |
| 107 | +- Dependency bumps unrelated to the patch fix, unless needed for a vulnerability or confirmed by the user |
| 108 | +- Risky behavior changes |
| 109 | +- Command migrations, doc generation, dev-only tooling, or cleanup-only changes unless they directly fix the patch issue |
| 110 | + |
| 111 | +For minor releases, include the normal release-train contents from the source branch unless the user asks to exclude something. Minor releases can include compatible features, fixes, dependency updates, migrations, and cleanup that are intended for the new minor train. |
| 112 | + |
| 113 | +For major releases, include the normal release-train contents from the source branch and any intentionally breaking changes approved for the major train. |
| 114 | + |
| 115 | +When the user asks you to inspect history and decide what to port, compare the target release branch to the source branch and inspect likely candidates: |
| 116 | + |
| 117 | +- `git log --oneline --reverse origin/release/7.2.x..origin/main` |
| 118 | +- `git show --stat --patch <candidate>` |
| 119 | +- `git cherry -v origin/release/7.2.x <candidate>` to notice already-applied equivalent changes |
| 120 | + |
| 121 | +Do not rely on commit messages alone. For security or vulnerability-driven releases, inspect the remediation sequence so prerequisite fixes are not missed: |
| 122 | + |
| 123 | +- Review nearby commits, parent/child relationships, and file-level dependencies around the obvious fix. |
| 124 | +- Treat toolchain, runtime, base-image, dependency-manifest, lockfile, scanner-configuration, and build/release-definition changes as possible prerequisite remediation, even if their commit messages are generic. |
| 125 | +- If a later vulnerability fix was made on top of an adjacent prerequisite change, include the prerequisite unless it is clearly unrelated or too risky and the user confirms excluding it. |
| 126 | +- If a scanner or release validation is the driver, check whether all changes needed to make that validation pass on the source branch are represented on the release branch, not just commits whose messages mention the scanner, vulnerability, or CVE. |
| 127 | +- Before finalizing candidate selection, summarize any excluded adjacent prerequisite commits and why they are excluded. |
| 128 | + |
| 129 | +## Tagging rules |
| 130 | + |
| 131 | +- Always tag on the release branch. |
| 132 | +- State the inferred tag before creating it; ask only if the format cannot be inferred or the operation will push. |
| 133 | +- Prefer the repository's existing tag format. Inspect existing tags if unsure. |
| 134 | +- Verify the checked-out branch before tagging with `git branch --show-current`. |
| 135 | +- After tagging, show the created tag and the commit it points to. |
| 136 | +- Create tags locally first unless the user explicitly asks to push as part of the release. |
| 137 | +- Never force-push release branches or tags unless the user explicitly authorizes it. |
| 138 | +- Summarize every mutation: branch creation, cherry-picks, version changes, commits, pushes, and tags. |
| 139 | + |
| 140 | +## Local-only release summary |
| 141 | + |
| 142 | +When local release artifacts are ready, report: |
| 143 | + |
| 144 | +- Versions created and target branches. |
| 145 | +- Cherry-picked source commits and resulting branch-tip commits. |
| 146 | +- Tag names, tag targets, and whether tags are annotated/signed. |
| 147 | +- Validation commands and outcomes. |
| 148 | +- Ahead counts versus origin, for example `git rev-list --left-right --count origin/release/7.2.x...release/7.2.x`. |
| 149 | +- That no pushes were performed, unless pushes were explicitly requested. |
0 commit comments