|
| 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 | +Before asking the user anything, derive the release plan: |
| 13 | + |
| 14 | +- `release_type`: from user wording or semver shape. |
| 15 | +- `version`: from the explicit user version, otherwise from existing tags. |
| 16 | +- `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`. |
| 17 | +- `source`: user-provided source, otherwise the repository default branch. |
| 18 | +- `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"`. |
| 19 | +- `push_mode`: local-only unless the user explicitly asks to push. |
| 20 | +- `worktree_mode`: prefer temporary git worktrees when handling multiple release trains or when the current checkout is detached or managed by `jj`. |
| 21 | + |
| 22 | +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: |
| 23 | + |
| 24 | +1. Release type, if not clear from the request or version number. |
| 25 | +2. Exact version, if it cannot be inferred from existing tags. |
| 26 | +3. Source branch, if it is not the default branch. |
| 27 | +4. Commit selection, only if the user has not provided commits/PRs and has not asked you to inspect history and decide. |
| 28 | +5. Whether to push, only after local branches/tags are ready. |
| 29 | + |
| 30 | +For version inference: |
| 31 | + |
| 32 | +- Inspect existing tags with `git tag --list --sort=-v:refname`. |
| 33 | +- Inspect release branches with `git branch -a --list '*release*'`. |
| 34 | +- For patch releases, increment the latest patch tag on the target release train. |
| 35 | +- For minor and major releases, increment the requested component from the latest released version and reset lower components to zero. |
| 36 | +- "One minor back" means the previous minor release branch; increment the latest patch tag on that line. |
| 37 | +- Confirm inferred versions in progress updates, but keep working unless the user asked for confirmation before mutation. |
| 38 | + |
| 39 | +## Hard stops |
| 40 | + |
| 41 | +Stop and ask before continuing if: |
| 42 | + |
| 43 | +- The working tree is dirty in a way not caused by this release work. |
| 44 | +- A release branch or tag would be pushed without explicit approval. |
| 45 | +- A force-push or tag replacement would be needed. |
| 46 | +- Trivy or required tests fail before tagging or pushing. |
| 47 | +- Cherry-pick conflicts remain unresolved. |
| 48 | +- The target branch for an existing patch train is missing. |
| 49 | + |
| 50 | +Never tag with a dirty working tree, unresolved conflicts, failed validation, or while checked out on the wrong branch. |
| 51 | + |
| 52 | +## Validation |
| 53 | + |
| 54 | +Before starting the release work: |
| 55 | + |
| 56 | +1. Make sure the working tree is clean with `git status`. |
| 57 | +2. Fetch current refs and tags with `git fetch --all --tags --prune`. |
| 58 | +3. Run Trivy before creating final release artifacts, and earlier when the release is vulnerability-driven. |
| 59 | + - For this repository, use `mise x trivy -- trivy fs --exit-code 1 --severity HIGH,CRITICAL`. |
| 60 | + - Use a different documented Trivy command only if the repository adds one. |
| 61 | + - 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. |
| 62 | + |
| 63 | +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. |
| 64 | + |
| 65 | +## Execute the release |
| 66 | + |
| 67 | +Use the same workflow for patch, minor, and major releases. The release type mainly changes which commits from the source branch are included. |
| 68 | + |
| 69 | +1. Inspect refreshed refs/tags and existing release branches. |
| 70 | +2. Infer and state the release plan. |
| 71 | +3. Validate the source and target as required. |
| 72 | +4. Create or check out the target release branch: |
| 73 | + - For a new release line, create the release branch from the source branch. |
| 74 | + - For an existing release line, use the existing release branch. |
| 75 | +5. Apply the release-type commit selection rules; use `git cherry-pick -x <sha>` for commits ported onto an existing release branch. |
| 76 | +6. Resolve conflicts carefully and keep the release branch limited to selected commits and release-process changes. |
| 77 | +7. Validate every release branch after porting changes. |
| 78 | +8. Before tagging, show the release contents summary and ask `Proceed?`. |
| 79 | +9. Tag locally on the release branch. |
| 80 | +10. Push the release branch and tag only when requested or required by the release process and approved by the user. |
| 81 | + |
| 82 | +Use this pre-tag summary format: |
| 83 | + |
| 84 | +```md |
| 85 | +### Included in <release> |
| 86 | +- <one-line summary> - PR #<number> |
| 87 | + |
| 88 | +### Excluded |
| 89 | +- <one-line summary> - PR #<number> (reason: <reason>) |
| 90 | + |
| 91 | +Proceed? |
| 92 | +``` |
| 93 | + |
| 94 | +## Commit selection by release type |
| 95 | + |
| 96 | +For patch releases, infer the selection from the purpose of a patch release: include only low-risk fixes needed for the release line, and exclude features, broad refactors, cleanup-only work, and unrelated dependency churn unless the user explicitly asks otherwise. |
| 97 | + |
| 98 | +For vulnerability-driven patch releases, include the full remediation closure, not just commits whose messages mention a CVE, scanner, or vulnerability. Toolchain, runtime, base-image, dependency-manifest, lockfile, scanner-configuration, and build/release-definition changes may be required prerequisites even when their commit messages are generic. |
| 99 | + |
| 100 | +For minor and major releases, include the normal release-train contents from the source branch, respecting any user-requested exclusions or intentionally breaking-change boundaries. |
| 101 | + |
| 102 | +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: |
| 103 | + |
| 104 | +- `git log --oneline --reverse origin/release/7.2.x..origin/main` |
| 105 | +- `git show --stat --patch <candidate>` |
| 106 | +- `git cherry -v origin/release/7.2.x <candidate>` to notice already-applied equivalent changes |
| 107 | + |
| 108 | +Do not rely on commit messages alone. Inspect nearby commits, parent/child relationships, and file-level dependencies so prerequisite fixes are not missed. Before finalizing candidate selection, summarize any excluded adjacent prerequisite commits and why they are excluded. |
| 109 | + |
| 110 | +## Tagging rules |
| 111 | + |
| 112 | +- Always tag on the release branch. |
| 113 | +- State the inferred tag before creating it; ask only if the format cannot be inferred or the operation will push. |
| 114 | +- Prefer the repository's existing tag format. Inspect existing tags if unsure. |
| 115 | +- Verify the checked-out branch before tagging with `git branch --show-current`. |
| 116 | +- After tagging, show the created tag and the commit it points to. |
| 117 | +- Summarize every mutation: branch creation, cherry-picks, version changes, commits, pushes, and tags. |
| 118 | + |
| 119 | +## Local-only release summary |
| 120 | + |
| 121 | +When local release artifacts are ready, report: |
| 122 | + |
| 123 | +- Versions created and target branches. |
| 124 | +- Cherry-picked source commits and resulting branch-tip commits. |
| 125 | +- Tag names, tag targets, and whether tags are annotated/signed. |
| 126 | +- Validation commands and outcomes. |
| 127 | +- Ahead counts versus origin, for example `git rev-list --left-right --count origin/release/7.2.x...release/7.2.x`. |
| 128 | +- That no pushes were performed, unless pushes were explicitly requested. |
0 commit comments