Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 072658d

Browse files
authoredDec 28, 2020
feat: remove title from the release notes
This information is redundant in the GitHub Release. BREAKING CHANGE: The title is now removed from the release notes by default. You can disable the removal of title/restore the old behavior with [`removeTitleFromReleaseNotes: false`](https://github.com/semantic-release/github#removetitlefromreleasenotes). Fixes: semantic-release#316
1 parent 8d3df0e commit 072658d

8 files changed

+17302
-75
lines changed
 

‎.vscode/extensions.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
3+
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
4+
5+
// List of extensions which should be recommended for users of this workspace.
6+
"recommendations": [
7+
"samverschueren.linter-xo"
8+
],
9+
}

‎.vscode/settings.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"xo.enable": true,
3+
"xo.format.enable": true,
4+
"[javascript]": {
5+
"editor.defaultFormatter": "samverschueren.linter-xo",
6+
"editor.formatOnSave": true
7+
},
8+
}

‎README.md

+50-25
Large diffs are not rendered by default.

‎lib/publish.js

+19-3
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,17 @@ module.exports = async (pluginConfig, context) => {
1515
cwd,
1616
options: {repositoryUrl},
1717
branch,
18-
nextRelease: {name, gitTag, notes},
18+
nextRelease: {name, gitTag, notes, version},
1919
logger,
2020
} = context;
21-
const {githubToken, githubUrl, githubApiPathPrefix, proxy, assets} = resolveConfig(pluginConfig, context);
21+
const {
22+
githubToken,
23+
githubUrl,
24+
githubApiPathPrefix,
25+
proxy,
26+
assets,
27+
removeTitleFromReleaseNotes: shouldRemoveTitleFromReleaseNotes,
28+
} = resolveConfig(pluginConfig, context);
2229
const {owner, repo} = parseGithubUrl(repositoryUrl);
2330
const github = getClient({githubToken, githubUrl, githubApiPathPrefix, proxy});
2431
const release = {
@@ -27,7 +34,7 @@ module.exports = async (pluginConfig, context) => {
2734
tag_name: gitTag,
2835
target_commitish: branch.name,
2936
name,
30-
body: notes,
37+
body: shouldRemoveTitleFromReleaseNotes ? removeTitleFromReleaseNotes(notes, version) : notes,
3138
prerelease: isPrerelease(branch),
3239
};
3340

@@ -104,3 +111,12 @@ module.exports = async (pluginConfig, context) => {
104111
logger.log('Published GitHub release: %s', url);
105112
return {url, name: RELEASE_NAME, id: releaseId};
106113
};
114+
115+
const removeTitleFromReleaseNotes = (notes, version) => {
116+
const titlePrefix = `### [${version}]`;
117+
if (notes.startsWith(titlePrefix)) {
118+
return notes.split('\n').slice(2).join('\n');
119+
}
120+
121+
return notes;
122+
};

‎lib/resolve-config.js

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module.exports = (
1313
assignees,
1414
releasedLabels,
1515
addReleases,
16+
removeTitleFromReleaseNotes,
1617
},
1718
{env}
1819
) => ({
@@ -32,4 +33,5 @@ module.exports = (
3233
? false
3334
: castArray(releasedLabels),
3435
addReleases: isNil(addReleases) ? false : addReleases,
36+
removeTitleFromReleaseNotes: isNil(removeTitleFromReleaseNotes) ? true : removeTitleFromReleaseNotes,
3537
});

‎lib/verify.js

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const VALIDATORS = {
2626
assignees: isArrayOf(isNonEmptyString),
2727
releasedLabels: canBeDisabled(isArrayOf(isNonEmptyString)),
2828
addReleases: canBeDisabled(oneOf(['bottom', 'top'])),
29+
removeTitleFromReleaseNotes: canBeDisabled(oneOf([false, true])),
2930
};
3031

3132
module.exports = async (pluginConfig, context) => {

0 commit comments

Comments
 (0)
Please sign in to comment.