Skip to content

Commit 3a3a78a

Browse files
fix: add only title form commit messages to release changelog (#14)
1 parent f8fbe45 commit 3a3a78a

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
"build:post": "ncc build src/post.ts -o dist/post",
1010
"prebuild": "rm -rf dist",
1111
"build": "npm-run-all -p build:main build:post",
12-
"watch": "ncc build --watch",
13-
"start": "node dist/index.js",
1412
"upgrade": "ncu -u"
1513
},
1614
"dependencies": {

src/main.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ async function main() {
5757
const versionMinor = newVersion.getMinor();
5858
const versionPatch = newVersion.getPatch();
5959
const released = newVersion.isIncreased();
60+
const changelog = createChangelog(messages);
6061

6162
core.debug(`main: computed tag: ${tag}, version: ${version}, released: ${released}`);
6263

@@ -79,9 +80,9 @@ async function main() {
7980
core.saveState('tag', tag);
8081
core.saveState('version', version);
8182
core.saveState('released', released);
82-
core.saveState('messages', messages);
83+
core.saveState('changelog', changelog);
8384

84-
core.debug(`main: state set tag: ${tag}, version: ${version}, released: ${released}, message count: ${messages.length}`);
85+
core.debug(`main: state set tag: ${tag}, version: ${version}, released: ${released}, changelog count: ${changelog.length}`);
8586
}
8687

8788
function getLatestRelease(releases: Release[], prefix: string): Release | undefined {
@@ -115,6 +116,10 @@ function extractMessages(commits: Commit[]): string[] {
115116
.map(m => m.replace(/\n\n/g, '\n'));
116117
}
117118

119+
function createChangelog(messages: string[]): string[] {
120+
return messages.map(message => message.split('\n')[ 0 ]);
121+
}
122+
118123
function increaseVersionByMessages(version: Version, messages: string[]): Version {
119124
if (messages.findIndex(breakingChangeTest) >= 0) {
120125
return version.increaseMajor();

src/post.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ async function main() {
1111
const tag = getState('tag');
1212
const version = getState('version');
1313
const released = getParsedState<boolean>('released');
14-
const messages = getParsedState<string[]>('messages');
14+
const changelog = getParsedState<string[]>('changelog');
1515

1616
if (released) {
1717
core.info(`release: creating for version: ${version}, tag: ${tag}`);
1818

19-
const release = await createRelease(tag, messages);
19+
const release = await createRelease(tag, changelog);
2020

2121
core.info(`release: created id: ${release.id}`);
2222

@@ -48,9 +48,9 @@ function getState(key: string): string {
4848
return state;
4949
}
5050

51-
async function createRelease(tag: string, messages: string[]) {
52-
const changelog = messages.map(m => `* ${m}\n`).join('');
53-
const body = `**Changelog:**\n${changelog}`;
51+
async function createRelease(tag: string, changelog: string[]) {
52+
const changes = changelog.map(m => `* ${m}\n`).join('');
53+
const body = `**Changelog:**\n${changes}`;
5454

5555
return github.createRelease(tag, body);
5656
}

0 commit comments

Comments
 (0)