-
-
Notifications
You must be signed in to change notification settings - Fork 31
chore: add release notes skill #1249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| --- | ||
| name: create-draft-release-notes | ||
| description: Create or update draft GitHub releases for the current project's main GitHub repository, then organize GitHub-generated release notes into user-friendly sections without rewriting release note items. Use for preparing, formatting, categorizing, creating, or updating GitHub release notes or draft releases. | ||
| --- | ||
|
|
||
| # Create Draft Release Notes | ||
|
|
||
| ## Overview | ||
|
|
||
| Create a GitHub draft release, organize the generated notes by conventional commit type, and save the organized body back to the draft. Preserve each release note item exactly; only split accidentally joined bullets, move bullets into sections, and adjust headings. | ||
|
|
||
| ## Draft Release Workflow | ||
|
|
||
| Input: a release tag/title such as `v2.0.6`. If title and tag differ, ask for the tag. | ||
|
|
||
| 1. Resolve `repo` as `<owner>/<repo>`. | ||
| Prefer an explicit repo from the user. Otherwise infer the current project's main GitHub repository from project metadata or the current GitHub remote. For npm projects, `package.json` `repository` is a useful signal; in monorepos, inspect the package or project being released rather than assuming the workspace root. Ignore subdirectory metadata such as `repository.directory` because GitHub releases are repository-level. If the repo is ambiguous, ask. | ||
|
|
||
| 2. Set variables: | ||
|
|
||
| ```bash | ||
| repo="<owner>/<repo>" | ||
| release_tag="v2.0.6" | ||
| release_title="$release_tag" | ||
| ``` | ||
|
|
||
| 3. Verify access and ensure the release does not already exist: | ||
|
|
||
| ```bash | ||
| gh auth status | ||
| gh repo view "$repo" --json nameWithOwner --jq '.nameWithOwner' | ||
| gh release view "$release_tag" -R "$repo" --json tagName,isDraft,url | ||
| ``` | ||
|
|
||
| If the release exists, stop unless the user explicitly asked to update that draft. | ||
|
|
||
| 4. Infer the previous tag: | ||
|
|
||
| ```bash | ||
| previous_tag="$(gh release list -R "$repo" --exclude-drafts --exclude-pre-releases --limit 1 --json tagName --jq '.[0].tagName')" | ||
| gh release list -R "$repo" --exclude-drafts --exclude-pre-releases --limit 5 | ||
| ``` | ||
|
|
||
| Ask for confirmation if the previous tag is missing, surprising, or part of a non-standard range. | ||
|
|
||
| 5. Before creating anything, state the repo and range: `previous_tag -> release_tag`. If the user did not explicitly ask to create the draft in this turn, ask for confirmation. | ||
|
|
||
| 6. Create the draft with GitHub-generated notes: | ||
|
|
||
| ```bash | ||
| gh release create "$release_tag" -R "$repo" --draft --generate-notes --notes-start-tag "$previous_tag" --title "$release_title" | ||
| ``` | ||
|
|
||
| Add `--verify-tag` when the release must use an existing remote tag. | ||
|
|
||
| 7. Organize and save the draft body: | ||
|
|
||
| ```bash | ||
| tmp_dir="$(mktemp -d)" | ||
| gh release view "$release_tag" -R "$repo" --json body --jq '.body' > "$tmp_dir/generated.md" | ||
| node .agents/skills/create-draft-release-notes/scripts/create-draft-release-notes.mjs "$tmp_dir/generated.md" > "$tmp_dir/organized.md" | ||
| gh release edit "$release_tag" -R "$repo" --draft --title "$release_title" --notes-file "$tmp_dir/organized.md" | ||
| ``` | ||
|
|
||
| 8. Return the draft URL: | ||
|
|
||
| ```bash | ||
| gh release view "$release_tag" -R "$repo" --json url --jq '.url' | ||
| ``` | ||
|
|
||
| ## Markdown-Only Workflow | ||
|
|
||
| Use this when the user provides generated release note Markdown and only wants it organized: | ||
|
|
||
| ```bash | ||
| node .agents/skills/create-draft-release-notes/scripts/create-draft-release-notes.mjs release-notes.md | ||
| ``` | ||
|
|
||
| Omit the file path to read from stdin. Review that every original item still appears once and non-item sections remain. | ||
|
|
||
| ## Categories | ||
|
|
||
| Emit non-empty sections in this order: | ||
|
|
||
| 1. `### Breaking Changes 🍭` | ||
| 2. `### New Features 🎉` | ||
| 3. `### Performance 🚀` | ||
| 4. `### Bug Fixes 🐞` | ||
| 5. `### Refactor 🔨` | ||
| 6. `### Document 📖` | ||
| 7. `### Other Changes` | ||
|
|
||
| Classify by the item prefix: | ||
|
|
||
| - Breaking Changes: `type!:` or `type(scope)!:`, plus `breaking:` / `break:`. | ||
| - New Features: `feat:` / `feat(scope):`, plus `feature:`. | ||
| - Performance: `perf:`. | ||
| - Bug Fixes: `fix:`. | ||
| - Refactor: `refactor:`. | ||
| - Document: `docs:` / `docs(scope):`, plus `doc:`. | ||
| - Other Changes: everything else. | ||
|
|
||
| Keep each category in generated top-to-bottom order. | ||
|
|
||
| ## Preservation Rules | ||
|
|
||
| - Do not rewrite bullet text, authors, URLs, PR numbers, package names, scopes, punctuation, or casing. | ||
| - Do not drop comments, `**Full Changelog**`, or other non-item sections. | ||
| - Do not add commentary to the release note itself. | ||
| - Do not emit empty category sections. | ||
|
|
||
| ## Resources | ||
|
|
||
| - `scripts/create-draft-release-notes.mjs`: deterministic formatter for generated release note Markdown. | ||
119 changes: 119 additions & 0 deletions
119
.agents/skills/create-draft-release-notes/scripts/create-draft-release-notes.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| #!/usr/bin/env node | ||
|
|
||
| import { readFile } from 'node:fs/promises'; | ||
| import { argv, stdin, stdout, stderr } from 'node:process'; | ||
|
|
||
| const categories = [ | ||
| ['breaking', '### Breaking Changes 🍭'], | ||
| ['feat', '### New Features 🎉'], | ||
| ['perf', '### Performance 🚀'], | ||
| ['fix', '### Bug Fixes 🐞'], | ||
| ['refactor', '### Refactor 🔨'], | ||
| ['docs', '### Document 📖'], | ||
| ['other', '### Other Changes'], | ||
| ]; | ||
|
|
||
| const typeMap = { | ||
| feat: 'feat', | ||
| feature: 'feat', | ||
| perf: 'perf', | ||
| fix: 'fix', | ||
| refactor: 'refactor', | ||
| docs: 'docs', | ||
| doc: 'docs', | ||
| }; | ||
|
|
||
| const itemRE = /^[*-]\s+([a-zA-Z]+)(?:\([^)]+\))?(!)?:\s+/; | ||
| const joinedItemRE = /(?<!^)(?=\*\s+[a-zA-Z]+(?:\([^)]+\))?!?:\s+)/g; | ||
|
chenjiahan marked this conversation as resolved.
|
||
|
|
||
| async function readMarkdown(input) { | ||
| if (input && input !== '-') { | ||
| return readFile(input, 'utf8'); | ||
| } | ||
|
|
||
| let markdown = ''; | ||
| stdin.setEncoding('utf8'); | ||
|
|
||
| for await (const chunk of stdin) { | ||
| markdown += chunk; | ||
| } | ||
|
|
||
| return markdown; | ||
| } | ||
|
|
||
| function classify(item) { | ||
| const match = itemRE.exec(item); | ||
|
|
||
| if (!match) { | ||
| return 'other'; | ||
| } | ||
|
|
||
| const type = match[1].toLowerCase(); | ||
|
|
||
| if (match[2] === '!' || type === 'breaking' || type === 'break') { | ||
| return 'breaking'; | ||
| } | ||
|
|
||
| return typeMap[type] ?? 'other'; | ||
| } | ||
|
|
||
| function organize(markdown) { | ||
| const heading = /^##\s+What's Changed\s*$/m.exec(markdown); | ||
|
|
||
| if (!heading) { | ||
| throw new Error("Could not find a `## What's Changed` section."); | ||
| } | ||
|
|
||
| const bodyStart = heading.index + heading[0].length; | ||
| const afterHeading = markdown.slice(bodyStart); | ||
| const nextSection = /^(?:##\s+|\*\*Full Changelog\*\*:)/m.exec(afterHeading); | ||
| const bodyEnd = nextSection ? bodyStart + nextSection.index : markdown.length; | ||
| const grouped = Object.fromEntries(categories.map(([key]) => [key, []])); | ||
| const preserved = []; | ||
|
|
||
| for (const rawLine of markdown.slice(bodyStart, bodyEnd).split('\n')) { | ||
| for (const line of rawLine.split(joinedItemRE)) { | ||
| const trimmed = line.trim(); | ||
|
|
||
| if (!trimmed || trimmed.startsWith('### ')) { | ||
| continue; | ||
| } | ||
|
|
||
| if (trimmed.startsWith('* ') || trimmed.startsWith('- ')) { | ||
| grouped[classify(trimmed)].push(trimmed); | ||
| } else { | ||
| preserved.push(line); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| const lines = preserved.filter((line) => line.trim()); | ||
|
|
||
| for (const [key, title] of categories) { | ||
| if (grouped[key].length > 0) { | ||
| lines.push(title, ...grouped[key]); | ||
| } | ||
| } | ||
|
|
||
| if (lines.length === 0) { | ||
| return markdown; | ||
| } | ||
|
|
||
| const prefix = markdown.slice(0, bodyStart).trimEnd(); | ||
| const suffix = markdown.slice(bodyEnd).replace(/^\n+/, ''); | ||
|
|
||
| return suffix | ||
| ? `${prefix}\n${lines.join('\n')}\n\n${suffix}` | ||
| : `${prefix}\n${lines.join('\n')}\n`; | ||
| } | ||
|
|
||
| try { | ||
| if (argv.length > 3) { | ||
| throw new Error('Usage: create-draft-release-notes.mjs [release-notes.md]'); | ||
| } | ||
|
|
||
| stdout.write(organize(await readMarkdown(argv[2]))); | ||
| } catch (error) { | ||
| stderr.write(`${error.message}\n`); | ||
|
chenjiahan marked this conversation as resolved.
|
||
| process.exitCode = 1; | ||
| } | ||
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "version": 1, | ||
| "skills": { | ||
| "create-draft-release-notes": { | ||
| "source": "rstackjs/agent-skills", | ||
| "sourceType": "github", | ||
| "skillPath": "skills/create-draft-release-notes/SKILL.md", | ||
| "computedHash": "72a427134af52e91cbba9bc55f9926cadd8f5bedf48d654952697f08d540e7bb" | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.