---
name: rc-release
description: >-
  Create an RC (release candidate) pre-release on GitHub. Use when the user asks
  to create an RC, release candidate, pre-release, or test release.
---

# RC Release

Create a GitHub pre-release with an auto-incremented patch version and `-rc` suffix.

## Process

### Step 1: Determine the target branch

```bash
current_branch=$(git branch --show-current)
```

- If on `master` or `main`: ask the user which branch to release from using AskQuestion.
- If on any other branch: use the current branch.

### Step 2: Determine the next version

```bash
gh release list --limit 50 --json tagName --jq '.[].tagName'
```

1. Parse all tags matching `vMAJOR.MINOR.PATCH` or `vMAJOR.MINOR.PATCH-rc`.
2. Find the highest version by comparing major, minor, patch numerically (ignore the `-rc` suffix when comparing).
3. Bump the version: if patch is 9, reset patch to 0 and bump minor by 1. Otherwise bump patch by 1.
4. Append `-rc`.

Examples:
- latest `v4.4.5` → `v4.4.6-rc`
- latest `v4.4.6-rc` → `v4.4.7-rc`
- latest `v4.4.9` → `v4.5.0-rc`
- latest `v4.4.9-rc` → `v4.5.0-rc`

### Step 3: Create the release

```bash
gh release create <tag> --target <branch> --prerelease --generate-notes
```

- `<tag>`: the computed version (e.g., `v4.4.6-rc`)
- `<branch>`: the target branch from Step 1
- `--prerelease`: marks it as a pre-release
- `--generate-notes`: auto-generates changelog from commits since the last release

### Step 4: Confirm

Print the release URL and tag to the user.
