|
1 | 1 | --- |
2 | | -description: Bump @coana-tech/cli to a new version, update changelog, and create a PR |
| 2 | +name: bump-coana |
| 3 | +description: Bump @coana-tech/cli to a new version, update changelog, and create a PR. Use when user wants to upgrade Coana CLI, bump Coana version, or says "bump coana" with a version number. |
3 | 4 | allowed-tools: Read, Edit, Write, Bash, Glob |
| 5 | +user-invocable: true |
4 | 6 | --- |
5 | 7 |
|
6 | 8 | # Bump Coana CLI Version |
7 | 9 |
|
8 | | -Automates the process of upgrading the @coana-tech/cli dependency to a new version. |
| 10 | +Automates the process of upgrading the @coana-tech/cli dependency to a new version, including package.json updates, changelog entry, and PR creation. |
9 | 11 |
|
10 | | -## Usage |
| 12 | +## Input |
11 | 13 |
|
12 | | -``` |
13 | | -/bump-coana <version> |
14 | | -``` |
| 14 | +- **Version**: The Coana version to upgrade to (e.g., `14.12.173`) |
| 15 | +- Passed via `$ARGUMENTS` (e.g., `/bump-coana 14.12.173`) |
| 16 | + |
| 17 | +If no version is provided, ask the user for the Coana version to upgrade to. |
15 | 18 |
|
16 | | -Where `<version>` is the Coana version number (e.g., `14.12.173`). |
| 19 | +## Workflow |
17 | 20 |
|
18 | | -## Instructions |
| 21 | +### Step 1: Parse and Validate Input |
19 | 22 |
|
20 | | -When this command is invoked with a version argument ($ARGUMENTS), perform the following steps: |
| 23 | +Extract the version number from `$ARGUMENTS`: |
| 24 | + |
| 25 | +```bash |
| 26 | +COANA_VERSION="$ARGUMENTS" |
| 27 | + |
| 28 | +# Validate version format (should be semver-like: X.Y.Z) |
| 29 | +if [[ ! "$COANA_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then |
| 30 | + echo "ERROR: Invalid version format. Expected X.Y.Z (e.g., 14.12.173)" |
| 31 | + exit 1 |
| 32 | +fi |
| 33 | +``` |
21 | 34 |
|
22 | | -### 1. Validate Input |
23 | | -- Extract the version from $ARGUMENTS (e.g., "14.12.173"). |
24 | | -- If no version is provided, ask the user for the Coana version to upgrade to. |
| 35 | +### Step 2: Update package.json |
25 | 36 |
|
26 | | -### 2. Update package.json |
27 | | -- Read `package.json` in the repository root. |
28 | | -- Find the current `@coana-tech/cli` version in devDependencies and note it for the PR body. |
29 | | -- Update the `@coana-tech/cli` version to the provided version. |
30 | | -- Bump the patch version of the package (e.g., `1.1.59` becomes `1.1.60`). |
31 | | -- Write the updated package.json. |
| 37 | +1. Read `package.json` in the repository root. |
| 38 | +2. Find the current `@coana-tech/cli` version in `devDependencies` and note it as `CURRENT_VERSION`. |
| 39 | +3. Update `@coana-tech/cli` to the new version. |
| 40 | +4. Bump the patch version of the package (e.g., `1.1.59` → `1.1.60`). |
| 41 | +5. Write the updated `package.json`. |
32 | 42 |
|
33 | | -### 3. Update CHANGELOG.md |
34 | | -- Read `CHANGELOG.md` in the repository root. |
35 | | -- Add a new version entry at the top (after the header section that ends with "The format is based on..."), using today's date in YYYY-MM-DD format. |
36 | | -- The new version should match the bumped package.json version. |
37 | | -- Use this exact format for the new entry: |
| 43 | +**Values to extract**: |
| 44 | +- `CURRENT_VERSION`: The old @coana-tech/cli version (for PR body) |
| 45 | +- `NEW_PKG_VERSION`: The bumped package.json version (for changelog) |
38 | 46 |
|
| 47 | +### Step 3: Update CHANGELOG.md |
| 48 | + |
| 49 | +1. Read `CHANGELOG.md` in the repository root. |
| 50 | +2. Add a new version entry after the header section (which ends with "The format is based on..."). |
| 51 | +3. Use today's date in `YYYY-MM-DD` format. |
| 52 | + |
| 53 | +**Entry format**: |
39 | 54 | ```markdown |
40 | | -## [NEW_VERSION](https://github.com/SocketDev/socket-cli/releases/tag/vNEW_VERSION) - YYYY-MM-DD |
| 55 | +## [NEW_PKG_VERSION](https://github.com/SocketDev/socket-cli/releases/tag/vNEW_PKG_VERSION) - YYYY-MM-DD |
41 | 56 |
|
42 | 57 | ### Changed |
43 | 58 | - Updated the Coana CLI to v `COANA_VERSION`. |
44 | 59 |
|
45 | 60 | ``` |
46 | 61 |
|
47 | | -Note: Include the blank line after the changelog entry. |
| 62 | +**Note**: Include a blank line after the entry. |
| 63 | + |
| 64 | +### Step 4: Update Lock File |
| 65 | + |
| 66 | +```bash |
| 67 | +pnpm install |
| 68 | +``` |
48 | 69 |
|
49 | | -### 4. Update Lock File |
50 | | -- Run `pnpm install` to update pnpm-lock.yaml with the new dependency version. |
| 70 | +This updates `pnpm-lock.yaml` with the new dependency version. |
51 | 71 |
|
52 | | -### 5. Create Branch and Commit |
53 | | -- Create a new branch named `coana-COANA_VERSION` (e.g., `coana-14.12.173`) from the current branch. |
54 | | -- Stage the changes: package.json, CHANGELOG.md, and pnpm-lock.yaml. |
55 | | -- Create a commit with the message: `upgrading coana to version COANA_VERSION`. |
56 | | -- Use the `-n` flag to skip pre-commit hooks. |
| 72 | +### Step 5: Create Branch and Commit |
57 | 73 |
|
58 | | -### 6. Push and Create PR |
59 | | -- Push the branch to origin with `-u` flag. |
60 | | -- Create a PR using `gh pr create` targeting the `v1.x` branch with: |
61 | | - - Title: `upgrading coana to version COANA_VERSION` |
62 | | - - Body using the format below. |
| 74 | +```bash |
| 75 | +# Create branch |
| 76 | +git checkout -b "coana-$COANA_VERSION" |
63 | 77 |
|
64 | | -Use this PR body format (use a HEREDOC for proper formatting): |
| 78 | +# Stage changes |
| 79 | +git add package.json CHANGELOG.md pnpm-lock.yaml |
| 80 | + |
| 81 | +# Commit (skip pre-commit hooks with -n) |
| 82 | +git commit -n -m "upgrading coana to version $COANA_VERSION" |
65 | 83 | ``` |
| 84 | + |
| 85 | +### Step 6: Push and Create PR |
| 86 | + |
| 87 | +```bash |
| 88 | +# Push branch |
| 89 | +git push -u origin "coana-$COANA_VERSION" |
| 90 | + |
| 91 | +# Create PR targeting v1.x branch |
| 92 | +gh pr create --base v1.x --title "upgrading coana to version $COANA_VERSION" --body "$(cat <<'EOF' |
66 | 93 | ## Summary |
67 | 94 | - Upgrades @coana-tech/cli from CURRENT_VERSION to COANA_VERSION |
68 | 95 |
|
69 | 96 | ## Coana Changelog |
70 | 97 | For details on what's included in this Coana release, see the [Coana Changelogs](https://docs.coana.tech/changelogs). |
| 98 | +EOF |
| 99 | +)" |
71 | 100 | ``` |
72 | 101 |
|
73 | | -Replace CURRENT_VERSION with the old version found in step 2, and COANA_VERSION with the new version. |
| 102 | +Replace `CURRENT_VERSION` and `COANA_VERSION` with actual values. |
| 103 | + |
| 104 | +## Output |
| 105 | + |
| 106 | +- Branch: `coana-<VERSION>` pushed to origin |
| 107 | +- PR: Created targeting `v1.x` branch |
| 108 | +- Files modified: `package.json`, `CHANGELOG.md`, `pnpm-lock.yaml` |
| 109 | + |
| 110 | +Report the PR URL to the user when complete. |
| 111 | + |
| 112 | +## Error Handling |
| 113 | + |
| 114 | +- **No version provided**: Ask user for the version number |
| 115 | +- **Invalid version format**: Report error with expected format |
| 116 | +- **pnpm install fails**: Check network connectivity and npm registry access |
| 117 | +- **PR creation fails**: Verify `gh` CLI is authenticated |
| 118 | + |
| 119 | +## Important Notes |
74 | 120 |
|
75 | | -### Important Notes |
76 | 121 | - Do NOT add any AI/Claude co-authorship or attribution to the commit message or PR. |
77 | 122 | - Do NOT include "Generated with Claude Code" or similar text anywhere. |
0 commit comments