Skip to content

Commit e0fd1c8

Browse files
authored
feat: add /release slash command for automated releases (#52)
1 parent 6fd449b commit e0fd1c8

2 files changed

Lines changed: 178 additions & 0 deletions

File tree

.claude/commands/release.md

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
---
2+
description: Create a new release with version bump, tag, and push
3+
argument-hint: [patch|minor|major]
4+
---
5+
6+
# Release
7+
8+
Automate the release process: verify CI status, bump version, create tag, and push.
9+
10+
## What This Command Does
11+
12+
1. **Verify CI**: Check that main branch CI is green
13+
2. **Analyze**: Find latest tag and commits since then
14+
3. **Bump Version**: Update version in all config files
15+
4. **Release**: Commit, tag, and push to trigger release workflow
16+
17+
## Usage
18+
19+
```bash
20+
# Interactive - will ask for bump type
21+
/release
22+
23+
# Direct - specify bump type
24+
/release patch # 1.2.0 → 1.2.1
25+
/release minor # 1.2.0 → 1.3.0
26+
/release major # 1.2.0 → 2.0.0
27+
```
28+
29+
## Implementation Steps
30+
31+
When this command is invoked:
32+
33+
### 1. Verify CI Status
34+
35+
Run the following command to check CI status on main branch:
36+
37+
```bash
38+
gh run list --branch main --limit 3
39+
```
40+
41+
**Expected**: All recent runs should show `completed` and `success`.
42+
43+
If CI is failing:
44+
- Report the failing workflow to the user
45+
- Stop and do not proceed with release
46+
47+
### 2. Get Current Release State
48+
49+
Run these commands in parallel:
50+
51+
```bash
52+
# Get latest tag
53+
git tag --list --sort=-v:refname | head -1
54+
55+
# Get current version from package.json
56+
grep '"version"' package.json | head -1
57+
```
58+
59+
### 3. Check for New Commits
60+
61+
Using the latest tag from step 2, check for commits since that tag:
62+
63+
```bash
64+
git log <latest-tag>..HEAD --oneline
65+
```
66+
67+
If no commits are found:
68+
- Report "No new commits since last release (v{version})"
69+
- Stop and do not proceed
70+
71+
If commits exist, display them to the user.
72+
73+
### 4. Determine Bump Type
74+
75+
If argument was provided (patch/minor/major):
76+
- Use the provided bump type
77+
78+
If no argument provided:
79+
- Use AskUserQuestion tool to ask the user which bump type:
80+
- **patch** - Bug fixes, small changes (1.2.0 → 1.2.1)
81+
- **minor** - New features, backwards compatible (1.2.0 → 1.3.0)
82+
- **major** - Breaking changes (1.2.0 → 2.0.0)
83+
84+
### 5. Calculate New Version
85+
86+
Parse current version (MAJOR.MINOR.PATCH) and calculate new version based on bump type:
87+
- patch: increment PATCH (1.2.3 → 1.2.4)
88+
- minor: increment MINOR, reset PATCH (1.2.3 → 1.3.0)
89+
- major: increment MAJOR, reset MINOR and PATCH (1.2.3 → 2.0.0)
90+
91+
### 6. Update Version Files
92+
93+
Update version string in these three files using Edit tool:
94+
95+
1. **package.json** - line with `"version": "X.Y.Z"`
96+
2. **src-tauri/tauri.conf.json** - line with `"version": "X.Y.Z"`
97+
3. **src-tauri/Cargo.toml** - line with `version = "X.Y.Z"` (in [package] section)
98+
99+
Read each file first, then use Edit tool to replace the old version with new version.
100+
101+
### 7. Create Commit
102+
103+
Stage only the modified files and create commit:
104+
105+
```bash
106+
git add package.json src-tauri/Cargo.toml src-tauri/tauri.conf.json
107+
git commit -m "chore: release v{new_version}"
108+
```
109+
110+
**IMPORTANT**:
111+
- Do NOT use `git add -A` or `git add .`
112+
- Do NOT add Co-Authored-By footer
113+
114+
### 8. Create and Push Tag
115+
116+
Create the tag and push both commit and tag:
117+
118+
```bash
119+
git tag v{new_version}
120+
git push origin main
121+
git push origin v{new_version}
122+
```
123+
124+
### 9. Report Success
125+
126+
Display success message with:
127+
- Version bump: v{old} → v{new}
128+
- Link to watch the release workflow: `https://github.com/leonardocouy/claudometer/actions`
129+
130+
## Important Notes
131+
132+
- **NEVER proceed if CI is failing** - always verify green status first
133+
- **NEVER use `git add -A` or `git add .`** - only stage the 3 version files
134+
- **NEVER add AI attribution** - no Co-Authored-By in commit message
135+
- **Verify commits exist** - don't create empty releases
136+
137+
## Error Handling
138+
139+
If any step fails:
140+
- Report the specific command that failed
141+
- Show the error message
142+
- Stop and ask user how to proceed
143+
144+
Common errors:
145+
- **CI failing**: "CI is not green. Please fix failing checks before releasing."
146+
- **No commits**: "No new commits since v{version}. Nothing to release."
147+
- **Push rejected**: "Push failed. Check if branch is up to date with remote."
148+
149+
## Example Output
150+
151+
```
152+
Release v1.3.0
153+
154+
CI Status: All checks passing
155+
Latest tag: v1.2.0
156+
New commits since v1.2.0:
157+
- f3f6c31 feat(tray): add color-coded usage percentage
158+
159+
Version bump: patch/minor/major? → minor
160+
Updating: 1.2.0 → 1.3.0
161+
162+
Updated files:
163+
- package.json
164+
- src-tauri/tauri.conf.json
165+
- src-tauri/Cargo.toml
166+
167+
Created commit: chore: release v1.3.0
168+
Created tag: v1.3.0
169+
Pushed to origin
170+
171+
Release workflow triggered!
172+
Watch progress: https://github.com/leonardocouy/claudometer/actions
173+
```

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,8 @@ models/
5656

5757
# Local secrets (DO NOT COMMIT)
5858
.secrets/
59+
60+
# Claude Code commands (allow tracking)
61+
!.claude/
62+
.claude/*
63+
!.claude/commands/

0 commit comments

Comments
 (0)