Skip to content

Commit

Permalink
feat: remove title from the release notes
Browse files Browse the repository at this point in the history
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
  • Loading branch information
felipecrs authored Dec 28, 2020
1 parent 8d3df0e commit 8b971c1
Show file tree
Hide file tree
Showing 8 changed files with 17,302 additions and 75 deletions.
9 changes: 9 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp

// List of extensions which should be recommended for users of this workspace.
"recommendations": [
"samverschueren.linter-xo"
],
}
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"xo.enable": true,
"xo.format.enable": true,
"[javascript]": {
"editor.defaultFormatter": "samverschueren.linter-xo",
"editor.formatOnSave": true
},
}
75 changes: 50 additions & 25 deletions README.md

Large diffs are not rendered by default.

22 changes: 19 additions & 3 deletions lib/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,17 @@ module.exports = async (pluginConfig, context) => {
cwd,
options: {repositoryUrl},
branch,
nextRelease: {name, gitTag, notes},
nextRelease: {name, gitTag, notes, version},
logger,
} = context;
const {githubToken, githubUrl, githubApiPathPrefix, proxy, assets} = resolveConfig(pluginConfig, context);
const {
githubToken,
githubUrl,
githubApiPathPrefix,
proxy,
assets,
removeTitleFromReleaseNotes: shouldRemoveTitleFromReleaseNotes,
} = resolveConfig(pluginConfig, context);
const {owner, repo} = parseGithubUrl(repositoryUrl);
const github = getClient({githubToken, githubUrl, githubApiPathPrefix, proxy});
const release = {
Expand All @@ -27,7 +34,7 @@ module.exports = async (pluginConfig, context) => {
tag_name: gitTag,
target_commitish: branch.name,
name,
body: notes,
body: shouldRemoveTitleFromReleaseNotes ? removeTitleFromReleaseNotes(notes, version) : notes,
prerelease: isPrerelease(branch),
};

Expand Down Expand Up @@ -104,3 +111,12 @@ module.exports = async (pluginConfig, context) => {
logger.log('Published GitHub release: %s', url);
return {url, name: RELEASE_NAME, id: releaseId};
};

const removeTitleFromReleaseNotes = (notes, version) => {
const titlePrefix = `### [${version}]`;
if (notes.startsWith(titlePrefix)) {
return notes.split('\n').slice(2).join('\n');
}

return notes;
};
2 changes: 2 additions & 0 deletions lib/resolve-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = (
assignees,
releasedLabels,
addReleases,
removeTitleFromReleaseNotes,
},
{env}
) => ({
Expand All @@ -32,4 +33,5 @@ module.exports = (
? false
: castArray(releasedLabels),
addReleases: isNil(addReleases) ? false : addReleases,
removeTitleFromReleaseNotes: isNil(removeTitleFromReleaseNotes) ? true : removeTitleFromReleaseNotes,
});
1 change: 1 addition & 0 deletions lib/verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const VALIDATORS = {
assignees: isArrayOf(isNonEmptyString),
releasedLabels: canBeDisabled(isArrayOf(isNonEmptyString)),
addReleases: canBeDisabled(oneOf(['bottom', 'top'])),
removeTitleFromReleaseNotes: canBeDisabled(oneOf([false, true])),
};

module.exports = async (pluginConfig, context) => {
Expand Down
Loading

0 comments on commit 8b971c1

Please sign in to comment.