Skip to content

Commit 3910642

Browse files
authored
add skill for bump emitter (#3977)
1 parent 74918b7 commit 3910642

1 file changed

Lines changed: 206 additions & 0 deletions

File tree

  • .github/skills/bump-emitter-version
Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
---
2+
name: bump-emitter-version
3+
description: Bumps the emitter package versions and updates changelogs. Upgrades @azure-tools/typespec-ts and @azure-tools/rlc-common to a user-specified version, auto-increments @autorest/typescript patch version, synchronizes all cross-package dependency references, runs pnpm install to refresh the lockfile, prepends changelog entries for all three packages, then commits all changes and opens a PR to main.
4+
---
5+
6+
# Bump Emitter Version
7+
8+
Bump the three emitter packages to new versions, synchronize all internal dependency references, refresh the lockfile, and update changelogs.
9+
10+
## Input
11+
12+
The user provides a **target version** for `@azure-tools/typespec-ts` and `@azure-tools/rlc-common` (e.g., `0.54.0`).
13+
`@autorest/typescript` is always bumped by one **patch** increment automatically.
14+
15+
## Step 1: Read Current Versions
16+
17+
Read the `version` field from each package's `package.json`:
18+
19+
```
20+
packages/typespec-ts/package.json → current @azure-tools/typespec-ts version
21+
packages/rlc-common/package.json → current @azure-tools/rlc-common version
22+
packages/autorest.typescript/package.json → current @autorest/typescript version
23+
```
24+
25+
Compute the new `@autorest/typescript` version by splitting the current version on `.` and incrementing the last segment by 1 (e.g., `6.0.71``6.0.72`).
26+
27+
Display a summary table for the user to confirm before proceeding:
28+
29+
| Package | Old Version | New Version |
30+
|---------|-------------|-------------|
31+
| @azure-tools/typespec-ts | `<old>` | `<target>` |
32+
| @azure-tools/rlc-common | `<old>` | `<target>` |
33+
| @autorest/typescript | `<old>` | `<old-major>.<old-minor>.<old-patch+1>` |
34+
35+
## Step 2: Update package.json Files
36+
37+
Update all four `package.json` files. Make all changes as file edits (do NOT use terminal sed/awk):
38+
39+
### `packages/typespec-ts/package.json`
40+
41+
1. Update `"version"` to the target version.
42+
2. Update the `@azure-tools/rlc-common` entry (under `dependencies`) from `"workspace:^<old>"` to `"workspace:^<target>"`.
43+
44+
### `packages/rlc-common/package.json`
45+
46+
1. Update `"version"` to the target version.
47+
48+
### `packages/autorest.typescript/package.json`
49+
50+
1. Update `"version"` to the new `@autorest/typescript` version.
51+
2. Update the `@azure-tools/rlc-common` entry (under `dependencies`) from `"workspace:^<old>"` to `"workspace:^<target>"`.
52+
53+
### `packages/typespec-test/package.json`
54+
55+
1. Update the `@azure-tools/typespec-ts` entry (under `dependencies`) from `"workspace:^<old>"` to `"workspace:^<target>"`.
56+
57+
**Important:** Always read the file before editing to locate the exact strings. Include sufficient surrounding context (3–5 lines) in each replacement to guarantee uniqueness.
58+
59+
## Step 3: Run pnpm install
60+
61+
Run `pnpm install` from the repo root to refresh `pnpm-lock.yaml`:
62+
63+
```bash
64+
cd <repo-root>
65+
PUPPETEER_SKIP_DOWNLOAD=true pnpm install
66+
```
67+
68+
Wait for the command to complete (allow up to 5 minutes). Confirm the lockfile was updated with no errors.
69+
70+
## Step 4: Collect Merged PRs for Changelog
71+
72+
Find the date of the **last release** in `packages/typespec-ts/CHANGELOG.md` — it is the date in the first `## X.Y.Z (YYYY-MM-DD)` heading.
73+
74+
Run the following command from the repo root to list merged PRs since that date:
75+
76+
```bash
77+
git log --oneline --merges --since="<last-release-date>" --format="%s %H"
78+
```
79+
80+
Parse the output. Each line that looks like `Merge pull request #NNNN` is a PR. Extract the PR number and use the commit subject line as a description hint.
81+
82+
For each PR collected, categorize it as `[Feature]` or `[Bugfix]` based on keywords in the commit message:
83+
- Keywords suggesting a feature: `add`, `support`, `implement`, `generate`, `enable`, `introduce`, `bump`, `upgrade`, `update`
84+
- Keywords suggesting a bugfix: `fix`, `correct`, `resolve`, `repair`, `revert`, `address`
85+
- Default to `[Feature]` if ambiguous.
86+
87+
Format each entry as:
88+
```
89+
- [Category] <Brief description from commit message>. Please refer to [#NNNN](https://github.com/Azure/autorest.typescript/pull/NNNN)
90+
```
91+
92+
If no PRs are found since the last release, write a placeholder entry:
93+
```
94+
- [Feature] Version bump.
95+
```
96+
97+
## Step 5: Update CHANGELOG Files
98+
99+
Prepend a new section to the **top** of each of the three changelog files. Use today's date in `YYYY-MM-DD` format.
100+
101+
### `packages/typespec-ts/CHANGELOG.md`
102+
103+
```md
104+
## <target-version> (<today-date>)
105+
106+
<changelog-entries>
107+
108+
```
109+
110+
### `packages/rlc-common/CHANGELOG.md`
111+
112+
```md
113+
## <target-version> (<today-date>)
114+
115+
<changelog-entries>
116+
117+
```
118+
119+
### `packages/autorest.typescript/CHANGELOG.md`
120+
121+
```md
122+
## <new-autorest-version> (<today-date>)
123+
124+
<changelog-entries>
125+
126+
```
127+
128+
**Important:** All three changelogs share the same PR entries — the same list applies to all three. Insert the new section **above** the existing first line. Add a blank line between the new section and the old content.
129+
130+
## Step 6: Verify
131+
132+
After all edits, run a quick sanity check:
133+
134+
```bash
135+
grep -r '"version"' packages/typespec-ts/package.json packages/rlc-common/package.json packages/autorest.typescript/package.json packages/typespec-test/package.json
136+
grep -r '@azure-tools/rlc-common\|@azure-tools/typespec-ts' packages/typespec-ts/package.json packages/rlc-common/package.json packages/autorest.typescript/package.json packages/typespec-test/package.json | grep -v '"name"'
137+
```
138+
139+
Verify:
140+
- All `version` fields show the new versions.
141+
- All internal `workspace:^` references point to the new versions.
142+
- The first line of each `CHANGELOG.md` starts with `## <new-version>`.
143+
144+
## Step 7: Commit and Open a PR
145+
146+
### 7.1 Create a branch
147+
148+
Create a new branch from the current HEAD named after the target version:
149+
150+
```bash
151+
git checkout -b bump-version-<target-version>
152+
```
153+
154+
If the branch already exists, append a short timestamp suffix: `bump-version-<target-version>-<YYYYMMDD>`.
155+
156+
### 7.2 Stage and commit
157+
158+
Stage all modified files and create a single commit:
159+
160+
```bash
161+
git add \
162+
packages/typespec-ts/package.json \
163+
packages/rlc-common/package.json \
164+
packages/autorest.typescript/package.json \
165+
packages/typespec-test/package.json \
166+
packages/typespec-ts/CHANGELOG.md \
167+
packages/rlc-common/CHANGELOG.md \
168+
packages/autorest.typescript/CHANGELOG.md \
169+
pnpm-lock.yaml
170+
171+
git commit -m "Bump emitter version to <target-version>"
172+
```
173+
174+
### 7.3 Push the branch
175+
176+
```bash
177+
git push origin bump-version-<target-version>
178+
```
179+
180+
If `origin` is not configured or the push fails due to auth, report the error to the user and stop — do not attempt force-push or alternative remotes.
181+
182+
### 7.4 Open a PR
183+
184+
Use the GitHub CLI to create a PR targeting `main`:
185+
186+
```bash
187+
gh pr create \
188+
--base main \
189+
--title "Bump emitter version to <target-version>" \
190+
--body "## Version Bump\n\nBumps the following packages:\n\n| Package | Old Version | New Version |\n|---------|-------------|-------------|\n| @azure-tools/typespec-ts | <old-typespec-ts> | <target-version> |\n| @azure-tools/rlc-common | <old-rlc-common> | <target-version> |\n| @autorest/typescript | <old-autorest> | <new-autorest-version> |\n\n## Changes included\n\n<changelog-entries>"
191+
```
192+
193+
If `gh` is not installed or not authenticated, print the PR URL template and instruct the user to open it manually:
194+
```
195+
https://github.com/Azure/autorest.typescript/compare/main...bump-version-<target-version>
196+
```
197+
198+
## Step 8: Report
199+
200+
Report to the user:
201+
202+
- The three new package versions
203+
- Which files were updated (package.json + CHANGELOG.md + pnpm-lock.yaml)
204+
- The number of PRs collected for the changelog
205+
- Confirmation that `pnpm install` completed successfully
206+
- The PR URL (or branch URL if `gh` was unavailable)

0 commit comments

Comments
 (0)