Skip to content

Commit 379a917

Browse files
committed
feat(release): auto-increment minor version and add /release skill
1 parent 7ae186b commit 379a917

File tree

4 files changed

+124
-9
lines changed

4 files changed

+124
-9
lines changed

.claude/CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ Invoke with `/skill-name`:
8686
| `/add-assertion` | Add new assertion with TDD |
8787
| `/check-coverage` | Analyze test coverage gaps |
8888
| `/pre-release` | Pre-release validation checklist |
89+
| `/release` | Run pre-release checks and execute release |
8990
| `/commit` | Stage and commit with conventional commits |
9091
| `/gh-issue <N>` | GitHub issue → branch → implement → PR |
9192
| `/pr [#N]` | Push branch and create PR |

.claude/skills/release/SKILL.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
---
2+
name: release
3+
description: Run pre-release validation and execute the release process
4+
user-invocable: true
5+
argument-hint: "[version]"
6+
allowed-tools: Bash, Read, Grep, Glob
7+
---
8+
9+
# Release
10+
11+
Run pre-release checks and create a new bashunit release.
12+
13+
## Arguments
14+
15+
- `$ARGUMENTS` - Version number (optional, e.g., `0.34.0`). If omitted, auto-increments the minor version.
16+
17+
## Current State
18+
19+
- Current version: !`grep -o 'BASHUNIT_VERSION="[^"]*"' bashunit | cut -d'"' -f2`
20+
- Branch: !`git branch --show-current`
21+
- Working tree: !`git status --short`
22+
- Unreleased changes: !`awk '/^## Unreleased$/,/^## \[/' CHANGELOG.md | head -30`
23+
24+
## Instructions
25+
26+
### 1. Pre-flight validation
27+
28+
Run these checks and report pass/fail for each:
29+
30+
```bash
31+
# Tests
32+
./bashunit tests/
33+
34+
# Static analysis
35+
make sa
36+
37+
# Linting
38+
make lint
39+
40+
# Bash 3.0+ compatibility (must return no results)
41+
grep -rn '\[\[' src/ || true
42+
grep -rn 'declare -A' src/ || true
43+
44+
# CI status
45+
gh run list --limit 3 --branch main
46+
```
47+
48+
If ANY check fails, stop and report the issue. Do NOT proceed to release.
49+
50+
### 2. Confirm with user
51+
52+
Show a summary:
53+
- Version: current → new (from `$ARGUMENTS` or auto-incremented)
54+
- Key changes from CHANGELOG Unreleased section (abbreviated)
55+
- All checks passed
56+
57+
Ask the user to confirm before proceeding.
58+
59+
### 3. Execute release
60+
61+
```bash
62+
./release.sh $ARGUMENTS
63+
```
64+
65+
If `$ARGUMENTS` is empty, run `./release.sh` (auto-increments minor version).
66+
67+
The script handles everything interactively: version bumps, build, commit, tag, GitHub release, and docs deployment.
68+
69+
### 4. Post-release
70+
71+
After the script completes, verify:
72+
```bash
73+
git log --oneline -1
74+
git tag --list | tail -1
75+
```
76+
77+
Report the release URL to the user.
78+
79+
## Example Usage
80+
81+
```
82+
/release
83+
/release 0.34.0
84+
/release 1.0.0
85+
```

release.sh

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,11 @@ CURRENT_VERSION=""
4747

4848
function release::show_usage() {
4949
cat >&2 <<EOF
50-
Usage: ./release.sh <version> [options]
50+
Usage: ./release.sh [version] [options]
5151
5252
Arguments:
5353
version The new version number (e.g., 0.30.0)
54+
If omitted, auto-increments the minor version (e.g., 0.33.0 → 0.34.0)
5455
5556
Options:
5657
--dry-run Preview changes without modifying any files
@@ -68,6 +69,7 @@ Exit Codes:
6869
2 Execution error (build failed, git failed)
6970
7071
Examples:
72+
./release.sh # Auto-increment minor version
7173
./release.sh 0.31.0 # Interactive release
7274
./release.sh 0.31.0 --dry-run # Preview changes
7375
./release.sh 0.31.0 --sandbox # Test in isolated sandbox
@@ -551,6 +553,13 @@ function release::sandbox::run() {
551553
release::sandbox::cleanup
552554
}
553555

556+
function release::increment_minor() {
557+
local version=$1
558+
local major minor
559+
IFS=. read -r major minor _ <<<"$version"
560+
echo "$major.$((minor + 1)).0"
561+
}
562+
554563
function release::validate_semver() {
555564
local version=$1
556565
if ! regex_match "$version" '^[0-9]+\.[0-9]+\.[0-9]+$'; then
@@ -935,17 +944,17 @@ function release::main() {
935944
esac
936945
done
937946

938-
# Validate version argument
947+
# Get current version
948+
CURRENT_VERSION=$(release::get_current_version)
949+
950+
# Auto-increment minor version if not specified
939951
if [[ -z "$VERSION" ]]; then
940-
release::log_error "Version argument is required"
941-
release::show_usage
942-
exit $EXIT_VALIDATION_ERROR
952+
VERSION=$(release::increment_minor "$CURRENT_VERSION")
953+
release::log_info "No version specified, auto-incrementing minor: $CURRENT_VERSION$VERSION"
954+
else
955+
release::validate_semver "$VERSION"
943956
fi
944957

945-
release::validate_semver "$VERSION"
946-
947-
# Get current version
948-
CURRENT_VERSION=$(release::get_current_version)
949958
release::log_info "Current version: $CURRENT_VERSION"
950959
release::log_info "New version: $VERSION"
951960

tests/unit/release_validation_test.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,26 @@ function test_validate_semver_rejects_text() {
7070
assert_contains "Invalid version format" "$result"
7171
}
7272

73+
##########################
74+
# release::increment_minor tests
75+
##########################
76+
77+
function test_increment_minor_bumps_minor_version() {
78+
assert_equals "0.34.0" "$(release::increment_minor "0.33.0")"
79+
}
80+
81+
function test_increment_minor_resets_patch_to_zero() {
82+
assert_equals "1.3.0" "$(release::increment_minor "1.2.5")"
83+
}
84+
85+
function test_increment_minor_handles_zero_minor() {
86+
assert_equals "2.1.0" "$(release::increment_minor "2.0.0")"
87+
}
88+
89+
function test_increment_minor_handles_large_numbers() {
90+
assert_equals "10.21.0" "$(release::increment_minor "10.20.30")"
91+
}
92+
7393
##########################
7494
# release::version_gt tests
7595
##########################

0 commit comments

Comments
 (0)