Skip to content

Commit e44724a

Browse files
authored
Merge pull request #78 from igerber/feat/bump-version-skill
Add /bump-version skill for release management
2 parents 164d815 + 887b67f commit e44724a

1 file changed

Lines changed: 111 additions & 0 deletions

File tree

.claude/commands/bump-version.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
---
2+
description: Update version numbers across codebase and ensure CHANGELOG is populated
3+
argument-hint: "<version> (e.g., 2.2.0)"
4+
---
5+
6+
# Bump Version
7+
8+
Update version numbers across the codebase and ensure CHANGELOG is properly populated for a new release.
9+
10+
## Arguments
11+
12+
The user must provide a version number: `$ARGUMENTS`
13+
14+
- If empty or not provided: Ask the user for the target version
15+
- Otherwise: Use the provided version (must match semver pattern X.Y.Z)
16+
17+
## Version Locations
18+
19+
Files that need updating:
20+
21+
| File | Format | Line |
22+
|------|--------|------|
23+
| `diff_diff/__init__.py` | `__version__ = "X.Y.Z"` | ~134 |
24+
| `pyproject.toml` | `version = "X.Y.Z"` | ~7 |
25+
| `rust/Cargo.toml` | `version = "X.Y.Z"` | ~3 |
26+
| `CHANGELOG.md` | Section header + comparison link | Top + bottom |
27+
28+
## Instructions
29+
30+
1. **Parse and validate version**:
31+
- If no argument provided, use AskUserQuestion to get the target version
32+
- Validate format matches semver pattern `X.Y.Z` (e.g., `2.2.0`, `3.0.0`, `1.10.5`)
33+
- If invalid, ask user to provide a valid version
34+
35+
2. **Get current version**:
36+
- Read `diff_diff/__init__.py` and extract the current `__version__` value
37+
- Store as `OLD_VERSION` for comparison link generation
38+
39+
3. **Check CHANGELOG entry**:
40+
- Search `CHANGELOG.md` for `## [NEW_VERSION]` section header
41+
- If found: Verify it has content (at least one `### Added/Changed/Fixed` subsection with bullet points)
42+
- If not found or empty: Generate entry from git commits (step 4)
43+
- If found with content: Skip to step 5
44+
45+
4. **Generate CHANGELOG from git** (only if needed):
46+
- Run: `git log v{OLD_VERSION}..HEAD --oneline`
47+
- If no tag exists, use: `git log --oneline -50`
48+
- Categorize commits using these heuristics:
49+
- **Added**: commits containing "add", "new", "implement", "introduce", "create"
50+
- **Changed**: commits containing "update", "change", "improve", "optimize", "refactor", "enhance"
51+
- **Fixed**: commits containing "fix", "bug", "correct", "repair", "resolve"
52+
- Get today's date in YYYY-MM-DD format
53+
- Create CHANGELOG entry in this format:
54+
```markdown
55+
## [X.Y.Z] - YYYY-MM-DD
56+
57+
### Added
58+
- Feature description from commit message
59+
60+
### Changed
61+
- Change description from commit message
62+
63+
### Fixed
64+
- Fix description from commit message
65+
```
66+
- Only include sections that have commits (omit empty sections)
67+
- Insert the new entry after the changelog header (after the "adheres to Semantic Versioning" line)
68+
69+
5. **Update version in all files**:
70+
Use the Edit tool to update each file:
71+
72+
- `diff_diff/__init__.py`:
73+
Replace `__version__ = "OLD_VERSION"` with `__version__ = "NEW_VERSION"`
74+
75+
- `pyproject.toml`:
76+
Replace `version = "OLD_VERSION"` with `version = "NEW_VERSION"`
77+
78+
- `rust/Cargo.toml`:
79+
Replace `version = "OLD_VERSION"` (the first version line under [package]) with `version = "NEW_VERSION"`
80+
Note: Rust version may differ from Python version; always sync to the new version
81+
82+
6. **Update CHANGELOG comparison links**:
83+
- At the bottom of `CHANGELOG.md`, after `[OLD_VERSION]:`, add the new comparison link:
84+
```
85+
[NEW_VERSION]: https://github.com/igerber/diff-diff/compare/vOLD_VERSION...vNEW_VERSION
86+
```
87+
88+
7. **Report summary**:
89+
Display a summary of all changes made:
90+
```
91+
Version bump complete: OLD_VERSION -> NEW_VERSION
92+
93+
Files updated:
94+
- diff_diff/__init__.py: __version__ = "NEW_VERSION"
95+
- pyproject.toml: version = "NEW_VERSION"
96+
- rust/Cargo.toml: version = "NEW_VERSION"
97+
- CHANGELOG.md: Added/verified [NEW_VERSION] entry
98+
99+
Next steps:
100+
1. Review changes: git diff
101+
2. Commit: git commit -am "Bump version to NEW_VERSION"
102+
3. Tag: git tag vNEW_VERSION
103+
4. Push: git push && git push --tags
104+
```
105+
106+
## Notes
107+
108+
- The Rust version in `rust/Cargo.toml` is always synced to match the Python version
109+
- If CHANGELOG already has the target version entry with content, it will not be overwritten
110+
- Commit messages are cleaned up (prefixes like "feat:", "fix:" are removed) for CHANGELOG
111+
- The comparison link format uses `v` prefix for tags (e.g., `v2.2.0`)

0 commit comments

Comments
 (0)