Skip to content

Commit 91c60fd

Browse files
committed
docs: new changelog
1 parent 923af3f commit 91c60fd

File tree

18 files changed

+4208
-24
lines changed

18 files changed

+4208
-24
lines changed

.changeset/changelog.js

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,11 @@ export default {
3030
/** @type string[] */
3131
const usersFromSummary = [];
3232

33+
// Parse summary to extract scope and description
34+
const summary = changeset.summary;
35+
3336
// Remove PR, commit, author/user lines from summary
34-
const replacedChangelog = changeset.summary
37+
const replacedChangelog = summary
3538
.replace(/^\s*(?:pr|pull|pull\s+request):\s*#?(\d+)/im, (_, pr) => {
3639
const num = Number(pr);
3740
if (!Number.isNaN(num)) {
@@ -49,6 +52,24 @@ export default {
4952
})
5053
.trim();
5154

55+
// Detect scope from **scope**: format
56+
const scopeMatch = replacedChangelog.match(/^\*\*([^:]+)\*\*:?\s*(.*)$/);
57+
const scope = scopeMatch ? scopeMatch[1] : null;
58+
const description = scopeMatch ? scopeMatch[2] : replacedChangelog;
59+
60+
// Detect breaking changes (explicit BREAKING or major version) - for future use
61+
const explicitBreaking =
62+
/^BREAKING[:\s]/i.test(replacedChangelog) || /\bBREAKING CHANGE\b/i.test(replacedChangelog);
63+
void explicitBreaking;
64+
65+
// Build formatted entry
66+
const entryParts = [];
67+
if (scope) {
68+
entryParts.push(`**${scope}**: ${description}`);
69+
} else {
70+
entryParts.push(description);
71+
}
72+
5273
const links = await (async () => {
5374
if (prFromSummary !== undefined) {
5475
let { links } = await getInfoFromPullRequest({
@@ -81,27 +102,13 @@ export default {
81102
};
82103
})();
83104

84-
const users = usersFromSummary.length
85-
? usersFromSummary
86-
.map((userFromSummary) => `[@${userFromSummary}](https://github.com/${userFromSummary})`)
87-
.join(', ')
88-
: links.user;
89-
90-
const metadata = [
91-
links.pull === null ? '' : ` (${links.pull})`,
92-
links.commit === null ? '' : ` (${links.commit})`,
93-
users === null ? '' : ` by ${users}`,
94-
].join('');
95-
96-
// Split summary into first line and the rest
97-
const [firstLine, ...rest] = replacedChangelog.split('\n');
98-
const restSummary = rest.join('\n').trim();
99-
100-
// No code block conversion: preserve original triple backtick code blocks and indentation
101-
let releaseLine = `\n- ${firstLine}${metadata}`;
102-
if (restSummary) {
103-
releaseLine += '\n\n' + restSummary;
105+
// Add PR link at end
106+
if (links.pull) {
107+
entryParts.push(`(${links.pull})`);
108+
} else if (prFromSummary !== undefined) {
109+
entryParts.push(`([#${prFromSummary}](https://github.com/${repo}/pull/${prFromSummary}))`);
104110
}
105-
return releaseLine;
111+
112+
return `\n- ${entryParts.join(' ')}`;
106113
},
107114
};

.changeset/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"$schema": "https://unpkg.com/@changesets/config@3.1.1/schema.json",
33
"access": "public",
44
"baseBranch": "main",
5-
"changelog": "./changelog.js",
5+
"changelog": ["./changelog.js", { "repo": "hey-api/openapi-ts" }],
66
"commit": false,
77
"fixed": [],
88
"ignore": [],

.github/workflows/release.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,32 @@ jobs:
4949
uses: changesets/action@v1.7.0
5050
with:
5151
commit: 'ci: release'
52+
createGithubReleases: false
5253
publish: pnpm changeset publish
5354
title: 'ci: release'
54-
version: pnpm changeset version
55+
version: pnpm changeset version && pnpm changelog:assemble
5556
env:
5657
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
5758
NPM_CONFIG_PROVENANCE: true
5859

60+
- name: Generate Release Tag
61+
id: tag
62+
run: echo "tag=$(pnpm changelog:release:tag)" >> $GITHUB_OUTPUT
63+
64+
- name: Generate Release Notes
65+
id: notes
66+
run: pnpm changelog:release:notes > release-notes.md
67+
68+
- name: Create GitHub Release
69+
uses: softprops/action-gh-release@v2
70+
with:
71+
tag_name: ${{ steps.tag.outputs.tag }}
72+
name: Release ${{ steps.tag.outputs.tag }}
73+
body_path: release-notes.md
74+
generate_release_notes: false
75+
env:
76+
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
77+
5978
- name: Get current branch
6079
run: echo "CURRENT_BRANCH=$(git branch --show-current)" >> $GITHUB_ENV
6180

0 commit comments

Comments
 (0)