|
| 1 | +# Plan: `/release` Skill for Gem Releases |
| 2 | + |
| 3 | +**Issue:** #304 |
| 4 | +**Previous release pain:** Missing v0.5.0 tag, building from wrong directory, manual changelog |
| 5 | + |
| 6 | +--- |
| 7 | + |
| 8 | +## Gem Registry |
| 9 | + |
| 10 | +| Key | Gem name | Version file | Tag prefix | Downstream deps | |
| 11 | +|-----|----------|-------------|------------|-----------------| |
| 12 | +| `sdk` | `bsv-sdk` | `gem/bsv-sdk/lib/bsv/version.rb` | `v` | `bsv-wallet`, `bsv-attest` | |
| 13 | +| `wallet` | `bsv-wallet` | `gem/bsv-wallet/lib/bsv/wallet_interface/version.rb` | `wallet-v` | `bsv-wallet-postgres` | |
| 14 | +| `wallet-postgres` | `bsv-wallet-postgres` | `gem/bsv-wallet-postgres/lib/bsv/wallet_postgres/version.rb` | `wallet-postgres-v` | none | |
| 15 | +| `attest` | `bsv-attest` | `gem/bsv-attest/lib/bsv/attest/version.rb` | `attest-v` | none | |
| 16 | + |
| 17 | +Dependency chain: `bsv-sdk → bsv-wallet → bsv-wallet-postgres` |
| 18 | + |
| 19 | +--- |
| 20 | + |
| 21 | +## Release Flow (16 steps) |
| 22 | + |
| 23 | +### Step 0: Hard refusal |
| 24 | +Refuse if user requests releasing multiple gems at once. One at a time only. |
| 25 | + |
| 26 | +### Step 1: Pre-flight checks |
| 27 | +- Dirty working tree → abort |
| 28 | +- Not on master → abort |
| 29 | +- Local master behind origin → abort |
| 30 | + |
| 31 | +### Step 2: Select gem |
| 32 | +From `$ARGUMENTS` or prompt user. Show current versions. |
| 33 | + |
| 34 | +### Step 3: Already-released checks |
| 35 | +- Version already tagged locally → abort |
| 36 | +- Version already on RubyGems (`gem search --remote --exact`) → abort |
| 37 | + |
| 38 | +### Step 4: Choose version bump |
| 39 | +- Gather commits since last tag scoped to `gem/<dir>/` |
| 40 | +- Suggest bump based on conventional commits (`feat!:` → major, `feat:` → minor, else → patch) |
| 41 | +- User confirms or overrides |
| 42 | + |
| 43 | +### Step 5: Downstream dependency check |
| 44 | +Only for gems with downstream dependents (sdk, wallet). |
| 45 | + |
| 46 | +**Part A — Dependency floor check:** |
| 47 | +Read downstream gemspec, check `add_dependency` floor version. Soft warning if floor < new version. |
| 48 | + |
| 49 | +**Part B — Interface compliance check (wallet only):** |
| 50 | +- Extract `def method_name` from `StorageAdapter` (methods raising `NotImplementedError`) |
| 51 | +- Extract `def method_name` from each downstream adapter (all `.rb` files in `lib/`) |
| 52 | +- Report any gaps. Default to abort; user can override. |
| 53 | + |
| 54 | +### Step 6: Generate changelog draft |
| 55 | +- `git log <last_tag>..HEAD -- gem/<dir>/` grouped by conventional commit type |
| 56 | +- Map to Keep a Changelog sections (Added, Fixed, Changed, Breaking, Security) |
| 57 | +- British English throughout |
| 58 | +- Display for user review/edit |
| 59 | + |
| 60 | +### Step 7: Bump version.rb |
| 61 | +Simple string replacement of `VERSION = 'x.y.z'` line. |
| 62 | + |
| 63 | +### Step 8: Update CHANGELOG.md |
| 64 | +Prepend new section after the header, before the first existing `## X.Y.Z` entry. |
| 65 | + |
| 66 | +### Step 9: Commit |
| 67 | +``` |
| 68 | +git add gem/<dir>/lib/.../version.rb gem/<dir>/CHANGELOG.md |
| 69 | +git commit -m "chore: release <gem-name> v<version>" |
| 70 | +``` |
| 71 | + |
| 72 | +### Step 10: Tag |
| 73 | +`git tag <prefix><version>` using gem's prefix convention. |
| 74 | + |
| 75 | +### Step 11: Push to master (with confirmation) |
| 76 | +``` |
| 77 | +git push origin master |
| 78 | +git push origin <tag> |
| 79 | +``` |
| 80 | + |
| 81 | +### Step 12: Build gem |
| 82 | +`cd gem/<dir> && gem build <name>.gemspec` (must build from inside gem directory). |
| 83 | + |
| 84 | +### Step 13: Sanity check |
| 85 | +Inspect `.gem` contents — verify `lib/`, `CHANGELOG.md`, `LICENSE` present, no unexpected files. |
| 86 | + |
| 87 | +### Step 14: Prompt user to push to RubyGems |
| 88 | +Skill cannot push — credentials are manual. Display the command and wait for confirmation. |
| 89 | + |
| 90 | +### Step 15: Create GitHub release |
| 91 | +``` |
| 92 | +gh release create <tag> --title "<gem-name> <version>" --notes "<changelog>" --target master |
| 93 | +gh release upload <tag> gem/<dir>/<gem-name>-<version>.gem |
| 94 | +``` |
| 95 | + |
| 96 | +### Step 16: Summary |
| 97 | +Table with gem, version, tag, commit, RubyGems link, GitHub release link, next steps. |
| 98 | + |
| 99 | +--- |
| 100 | + |
| 101 | +## Error Handling |
| 102 | + |
| 103 | +**Hard aborts:** dirty tree, wrong branch, behind origin, already tagged, already on RubyGems, user declines confirmation. |
| 104 | + |
| 105 | +**Soft warnings:** downstream floor not raised, interface compliance failure (default abort, overridable), sanity check anomalies, GitHub release creation failure. |
| 106 | + |
| 107 | +**Recovery guidance:** at every abort, explain what state the release is in and how to continue or roll back. |
| 108 | + |
| 109 | +--- |
| 110 | + |
| 111 | +## Rakefile Cleanup |
| 112 | + |
| 113 | +Remove all four `Bundler::GemHelper.install_tasks` lines. The `/release` skill replaces the entire `release[remote]` workflow. Keep `rspec` and `docs:` tasks. Add comment directing to `/release`. |
| 114 | + |
| 115 | +--- |
| 116 | + |
| 117 | +## CLAUDE.md Updates |
| 118 | + |
| 119 | +- Update "Releasing Companion Gems" section to reference `/release` as canonical mechanism |
| 120 | +- Document tag prefix conventions for all four gems |
| 121 | +- Fix the `gem build` example in Commands section (currently references old path) |
| 122 | + |
| 123 | +--- |
| 124 | + |
| 125 | +## Task Breakdown |
| 126 | + |
| 127 | +1. **Create `.claude/commands/release.md`** — the skill file with full flow |
| 128 | +2. **Clean up Rakefile** — remove unsafe `install_tasks`, add comment |
| 129 | +3. **Update CLAUDE.md** — releasing docs, tag conventions, fix build example |
| 130 | +4. **Manual verification** — dry-run `/release` to test the flow |
| 131 | + |
| 132 | +--- |
| 133 | + |
| 134 | +## Risks |
| 135 | + |
| 136 | +| Risk | Mitigation | |
| 137 | +|------|-----------| |
| 138 | +| `gem search --remote` slow/unavailable | Timeout + soft warning | |
| 139 | +| `gh` CLI not authenticated | Check `gh auth status` in pre-flight | |
| 140 | +| No previous tag for a gem (e.g. attest) | Use earliest commit touching `gem/<dir>/` | |
| 141 | +| Interface check false positives (mixins) | Scan all `.rb` files in downstream `lib/` | |
| 142 | +| New gems added to monorepo | Update gem registry in skill file | |
0 commit comments