Skip to content

fix: add only title form commit messages to release changelog #14

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 1 commit into from
Apr 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
"build:post": "ncc build src/post.ts -o dist/post",
"prebuild": "rm -rf dist",
"build": "npm-run-all -p build:main build:post",
"watch": "ncc build --watch",
"start": "node dist/index.js",
"upgrade": "ncu -u"
},
"dependencies": {
Expand Down
9 changes: 7 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ async function main() {
const versionMinor = newVersion.getMinor();
const versionPatch = newVersion.getPatch();
const released = newVersion.isIncreased();
const changelog = createChangelog(messages);

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

Expand All @@ -79,9 +80,9 @@ async function main() {
core.saveState('tag', tag);
core.saveState('version', version);
core.saveState('released', released);
core.saveState('messages', messages);
core.saveState('changelog', changelog);

core.debug(`main: state set tag: ${tag}, version: ${version}, released: ${released}, message count: ${messages.length}`);
core.debug(`main: state set tag: ${tag}, version: ${version}, released: ${released}, changelog count: ${changelog.length}`);
}

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

function createChangelog(messages: string[]): string[] {
return messages.map(message => message.split('\n')[ 0 ]);
}

function increaseVersionByMessages(version: Version, messages: string[]): Version {
if (messages.findIndex(breakingChangeTest) >= 0) {
return version.increaseMajor();
Expand Down
10 changes: 5 additions & 5 deletions src/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ async function main() {
const tag = getState('tag');
const version = getState('version');
const released = getParsedState<boolean>('released');
const messages = getParsedState<string[]>('messages');
const changelog = getParsedState<string[]>('changelog');

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

const release = await createRelease(tag, messages);
const release = await createRelease(tag, changelog);

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

Expand Down Expand Up @@ -48,9 +48,9 @@ function getState(key: string): string {
return state;
}

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

return github.createRelease(tag, body);
}
Expand Down