| 1 | --- |
| 2 | name: release |
| 3 | description: Create a release PR with version bump, then auto-tag after merge |
| 4 | --- |
| 5 | |
| 6 | Create a release PR that bumps the version and updates the changelog. After the PR is merged, the `tag-release.yml` workflow will automatically tag the release, trigger `cargo publish`, and bump to the next development version. |
| 7 | |
| 8 | ## Arguments |
| 9 | |
| 10 | The skill accepts a version level argument: |
| 11 | - `patch` - 0.0.1 -> 0.0.2 |
| 12 | - `minor` - 0.0.1 -> 0.1.0 |
| 13 | - `major` - 0.0.1 -> 1.0.0 |
| 14 | - Or an explicit version like `0.2.0` |
| 15 | |
| 16 | Example: `/release minor` |
| 17 | |
| 18 | ## Steps |
| 19 | |
| 20 | 1. **Verify prerequisites**: |
| 21 | - Must be on `main` branch |
| 22 | - Working directory must be clean |
| 23 | - Must be up to date with origin/main |
| 24 | |
| 25 | ```bash |
| 26 | git fetch origin |
| 27 | if [ "$(git branch --show-current)" != "main" ]; then |
| 28 | echo "Error: Must be on main branch" |
| 29 | exit 1 |
| 30 | fi |
| 31 | if [ -n "$(git status --porcelain)" ]; then |
| 32 | echo "Error: Working directory not clean" |
| 33 | exit 1 |
| 34 | fi |
| 35 | if [ "$(git rev-parse HEAD)" != "$(git rev-parse origin/main)" ]; then |
| 36 | echo "Error: Not up to date with origin/main" |
| 37 | exit 1 |
| 38 | fi |
| 39 | ``` |
| 40 | |
| 41 | 2. **Run local checks**: |
| 42 | ```bash |
| 43 | cargo clippy --all-targets --all-features -- -D warnings |
| 44 | cargo test --all |
| 45 | ``` |
| 46 | If checks fail, stop and report the errors. |
| 47 | |
| 48 | 3. **Determine the new version**: |
| 49 | - Read the current version from `Cargo.toml` |
| 50 | - Calculate the new version based on the level argument (patch/minor/major) or use the explicit version provided |
| 51 | |
| 52 | 4. **Create release branch**: |
| 53 | ```bash |
| 54 | NEW_VERSION="X.Y.Z" # from step 3 |
| 55 | git checkout -b release/v${NEW_VERSION} |
| 56 | ``` |
| 57 | |
| 58 | 5. **Bump version in Cargo.toml**: |
| 59 | - Update the `version = "..."` field in the root `Cargo.toml` |
| 60 | |
| 61 | 6. **Update CHANGELOG.md**: |
| 62 | - Move items from the "Unreleased" section to a new version section with the release date |
| 63 | - Create a new empty "Unreleased" section |
| 64 | - The changelog follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) format |
| 65 | - Ask the user if they want to review/edit the changelog before proceeding |
| 66 | |
| 67 | 7. **Commit changes**: |
| 68 | |
| 69 | **CRITICAL**: The commit message MUST start with `release: v` (no other words before the version). |
| 70 | The `tag-release.yml` workflow matches `startsWith(message, 'release: v')` on the merge commit. |
| 71 | When GitHub squash-merges a single-commit PR, the commit message becomes the merge commit message. |
| 72 | |
| 73 | ```bash |
| 74 | git add Cargo.toml CHANGELOG.md |
| 75 | git commit -m "release: v${NEW_VERSION}" |
| 76 | ``` |
| 77 | |
| 78 | 8. **Push and create PR**: |
| 79 | ```bash |
| 80 | git push -u origin release/v${NEW_VERSION} |
| 81 | |
| 82 | gh pr create \ |
| 83 | --title "release: v${NEW_VERSION}" \ |
| 84 | --body "$(cat <<EOF |
| 85 | ## Release v${NEW_VERSION} |
| 86 | |
| 87 | This PR prepares the release of v${NEW_VERSION}. |
| 88 | |
| 89 | ### Changes |
| 90 | - Version bump to ${NEW_VERSION} |
| 91 | - Changelog update |
| 92 | |
| 93 | ### After Merge |
| 94 | The tag-release workflow will automatically: |
| 95 | 1. Create git tag \`v${NEW_VERSION}\` |
| 96 | 2. Trigger CI + publish to crates.io |
| 97 | 3. Create a GitHub Release |
| 98 | 4. Bump to next development version (\`-alpha.0\`) |
| 99 | |
| 100 | --- |
| 101 | See CHANGELOG.md for details. |
| 102 | EOF |
| 103 | )" |
| 104 | ``` |
| 105 | |
| 106 | 9. **Report the PR URL** to the user. |
| 107 | |
| 108 | ## After PR Merge |
| 109 | |
| 110 | When the PR is merged to main, the `tag-release.yml` workflow will: |
| 111 | 1. Detect the version from `Cargo.toml` |
| 112 | 2. Create and push the git tag `vX.Y.Z` |
| 113 | 3. The `release.yml` workflow then runs CI and publishes to crates.io |
| 114 | 4. Create a commit bumping to next dev version (e.g., `0.0.2-alpha.0`) |
| 115 | |
| 116 | ## Troubleshooting |
| 117 | |
| 118 | - **gh CLI not installed**: `brew install gh` or see https://cli.github.com/ |
| 119 | - **Not authenticated with gh**: `gh auth login` |
| 120 | - **RELEASE_TOKEN secret missing**: The tag-release workflow needs a PAT with `contents: write` stored as `RELEASE_TOKEN` in repo secrets (the default GITHUB_TOKEN can't trigger other workflows) |
| 121 | - **CARGO_REGISTRY_TOKEN secret missing**: The release workflow needs a crates.io API token stored as `CARGO_REGISTRY_TOKEN` in repo secrets |