|
| 1 | +--- |
| 2 | +name: release-note |
| 3 | +description: Generate a semver-compliant release note from git history |
| 4 | +user-invocable: true |
| 5 | +--- |
| 6 | + |
| 7 | +Generate a release note for this project following https://semver.org/. |
| 8 | + |
| 9 | +## Steps |
| 10 | + |
| 11 | +### 1. Gather git history |
| 12 | + |
| 13 | +```bash |
| 14 | +git tag --sort=-version:refname | head -5 |
| 15 | +``` |
| 16 | + |
| 17 | +Then get commits since the last tag (or last 30 if no tags exist): |
| 18 | + |
| 19 | +```bash |
| 20 | +# with tags: |
| 21 | +git log <last-tag>..HEAD --oneline --no-merges |
| 22 | +# no tags: |
| 23 | +git log --oneline --no-merges -30 |
| 24 | +``` |
| 25 | + |
| 26 | +### 2. Determine current version |
| 27 | + |
| 28 | +- If a version tag exists (e.g. `v1.2.3`) → that is the **current version** |
| 29 | +- If no tags exist → current version is `v0.0.0` |
| 30 | + |
| 31 | +### 3. Categorize commits |
| 32 | + |
| 33 | +| Category | Bump | Signals | |
| 34 | +|---|---|---| |
| 35 | +| **Breaking Changes** | MAJOR | `BREAKING CHANGE:`, `!` after type (e.g. `feat!:`), words "breaking", "incompatible" | |
| 36 | +| **Features** | MINOR | `feat:`, `feature:`, "add ", "new ", "implement" | |
| 37 | +| **Bug Fixes** | PATCH | `fix:`, `bugfix:`, "fix ", "resolve ", "correct " | |
| 38 | +| **Other** | PATCH | `refactor`, `chore`, `docs`, `style`, `test`, `perf`, `ci`, `build` | |
| 39 | + |
| 40 | +Use [Conventional Commits](https://www.conventionalcommits.org/) prefixes when present; otherwise classify by message keywords. |
| 41 | + |
| 42 | +### 4. Calculate next version |
| 43 | + |
| 44 | +Apply the **highest** bump found: |
| 45 | +- Any BREAKING CHANGE → bump MAJOR, reset minor + patch to 0 |
| 46 | +- Any feat (no breaking) → bump MINOR, reset patch to 0 |
| 47 | +- Only fixes/other → bump PATCH |
| 48 | + |
| 49 | +> **Pre-1.0 rule:** If current major is `0`, treat BREAKING as MINOR (semver §4). |
| 50 | +
|
| 51 | +### 5. Print draft release note |
| 52 | + |
| 53 | +``` |
| 54 | +## Release v<next> — <YYYY-MM-DD> |
| 55 | +
|
| 56 | +> Suggested bump: <MAJOR|MINOR|PATCH> (v<current> → v<next>) |
| 57 | +
|
| 58 | +### 💥 Breaking Changes |
| 59 | +- <message> (<sha>) |
| 60 | +
|
| 61 | +### ✨ Features |
| 62 | +- <message> (<sha>) |
| 63 | +
|
| 64 | +### 🐛 Bug Fixes |
| 65 | +- <message> (<sha>) |
| 66 | +
|
| 67 | +### 🔧 Other Changes |
| 68 | +- <message> (<sha>) |
| 69 | +``` |
| 70 | + |
| 71 | +Omit empty sections. |
| 72 | + |
| 73 | +### 6. Ask for confirmation |
| 74 | + |
| 75 | +After the draft, ask the user: |
| 76 | + |
| 77 | +> **Does `v<next>` look right?** |
| 78 | +> - Confirm → finalize and print the clean release note |
| 79 | +> - Provide a different version (e.g. `v2.0.0`) → reformat with that version |
| 80 | +> - Cancel → discard |
| 81 | +
|
| 82 | +Once confirmed: |
| 83 | + |
| 84 | +1. **Update `package.json`** — read the file, set `"version"` to the confirmed version (without the `v` prefix, e.g. `"1.3.0"`), and write it back. |
| 85 | + |
| 86 | +2. **Update `CHANGELOG.md`** — prepend the new release section (without the `> Suggested bump:` line) to the top of the entries in `CHANGELOG.md`. If the file doesn't exist, create it with a standard header: |
| 87 | + ```markdown |
| 88 | + # Changelog |
| 89 | + |
| 90 | + All notable changes to this project will be documented in this file. |
| 91 | + |
| 92 | + This project adheres to [Semantic Versioning](https://semver.org/). |
| 93 | + |
| 94 | + --- |
| 95 | + ``` |
| 96 | + Then append the release section below the `---` separator. |
| 97 | + |
| 98 | +3. **Output the final release note** ready to paste into a GitHub Release or PR description. |
0 commit comments