Skip to content
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

Add --no-release-notes option to disable auto-generated release notes in GitHub draft #709

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions readme.md
Expand Up @@ -88,6 +88,7 @@ $ np --help
--contents Subdirectory to publish
--no-release-draft Skips opening a GitHub release draft
--release-draft-only Only opens a GitHub release draft
--no-release-notes Skips generating release notes when opening a GitHub release draft
--test-script Name of npm run script to run tests before publishing (default: test)
--no-2fa Don't enable 2FA on new packages (not recommended)
--message Version bump commit message. `%s` will be replaced with version. (default: '%s' with npm and 'v%s' with yarn)
Expand Down Expand Up @@ -123,6 +124,7 @@ Currently, these are the flags you can configure:
- `yarn` - Use yarn if possible (`true` by default).
- `contents` - Subdirectory to publish (`.` by default).
- `releaseDraft` - Open a GitHub release draft after releasing (`true` by default).
- `releaseNotes` - Auto-generate release notes when opening a GitHub release draft (`true` by default).
- `testScript` - Name of npm run script to run tests before publishing (`test` by default).
- `2fa` - Enable 2FA on new packages (`true` by default) (setting this to `false` is not recommended).
- `message` - The commit message used for the version bump. Any `%s` in the string will be replaced with the new version. By default, npm uses `%s` and Yarn uses `v%s`.
Expand Down
5 changes: 5 additions & 0 deletions source/cli-implementation.js
Expand Up @@ -34,6 +34,7 @@ const cli = meow(`
--contents Subdirectory to publish
--no-release-draft Skips opening a GitHub release draft
--release-draft-only Only opens a GitHub release draft for the latest published version
--no-release-notes Skips generating release notes when opening a GitHub release draft
--test-script Name of npm run script to run tests before publishing (default: test)
--no-2fa Don't enable 2FA on new packages (not recommended)
--message Version bump commit message, '%s' will be replaced with version (default: '%s' with npm and 'v%s' with yarn)
Expand Down Expand Up @@ -72,6 +73,9 @@ const cli = meow(`
releaseDraftOnly: {
type: 'boolean',
},
releaseNotes: {
type: 'boolean',
},
tag: {
type: 'string',
},
Expand Down Expand Up @@ -106,6 +110,7 @@ try {
tests: true,
publish: true,
releaseDraft: true,
releaseNotes: true,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this could default to false. The "Generate release notes" button which now exists tends to work a little better for me.

yarn: hasYarn(),
'2fa': true,
};
Expand Down
2 changes: 1 addition & 1 deletion source/release-task-helper.js
Expand Up @@ -14,7 +14,7 @@ const releaseTaskHelper = async (options, pkg) => {
const url = newGithubReleaseUrl({
repoUrl: options.repoUrl,
tag,
body: options.releaseNotes(tag),
body: options.releaseNotes ? options.generateReleaseNotes(tag) : '',
isPrerelease: isPreRelease,
});

Expand Down
12 changes: 6 additions & 6 deletions source/ui.js
Expand Up @@ -22,7 +22,7 @@ const printCommitLog = async (repoUrl, registryUrl, fromLatestTag, releaseBranch
return {
hasCommits: false,
hasUnreleasedCommits: false,
releaseNotes() {},
generateReleaseNotes() {},
};
}

Expand Down Expand Up @@ -64,7 +64,7 @@ const printCommitLog = async (repoUrl, registryUrl, fromLatestTag, releaseBranch
return `- ${commitMessage} ${commitId}`;
}).join('\n');

const releaseNotes = nextTag => commits.map(commit =>
const generateReleaseNotes = nextTag => commits.map(commit =>
`- ${htmlEscape(commit.message)} ${commit.id}`,
).join('\n') + `\n\n${repoUrl}/compare/${revision}...${nextTag}`;

Expand All @@ -74,7 +74,7 @@ const printCommitLog = async (repoUrl, registryUrl, fromLatestTag, releaseBranch
return {
hasCommits: true,
hasUnreleasedCommits,
releaseNotes,
generateReleaseNotes,
};
};

Expand Down Expand Up @@ -151,7 +151,7 @@ const ui = async (options, {pkg, rootDir}) => {
}

const useLatestTag = !options.releaseDraftOnly;
const {hasCommits, hasUnreleasedCommits, releaseNotes} = await printCommitLog(repoUrl, registryUrl, useLatestTag, releaseBranch);
const {hasCommits, hasUnreleasedCommits, generateReleaseNotes} = await printCommitLog(repoUrl, registryUrl, useLatestTag, releaseBranch);

if (hasUnreleasedCommits && options.releaseDraftOnly) {
const answers = await inquirer.prompt({
Expand All @@ -175,7 +175,7 @@ const ui = async (options, {pkg, rootDir}) => {
...options,
confirm: true,
repoUrl,
releaseNotes,
generateReleaseNotes,
};
}

Expand Down Expand Up @@ -296,7 +296,7 @@ const ui = async (options, {pkg, rootDir}) => {
publishScoped: answers.publishScoped,
confirm: true,
repoUrl,
releaseNotes,
generateReleaseNotes,
};
};

Expand Down