semantic-release-github-pr

Preview the semantic release notes that would result from merging a Github PR.

This semantic-release
plugin will post a Github PR comment with a preview of the release that would result from merging.
Install
npm install -D semantic-release-github-pr
Configuration
This plugin is a complement to semantic-release
. It is assumed the user is already fully familiar with that package and its workflow.
Github
Github authentication must be configured for semantic-relase
.
Usage
The easiest way to use the plugin is through the CLI. If more flexibility is needed, the plugin can also be set through the semantic-release
config in package.json
.
CLI
Post a comment to any open Github PRs with a matching base branch and git head. Previous comments generated by this plugin will be removed.
npx semantic-release-github-pr
The semantic-release-github-pr
command is provided as a convenience. Internally, it simply wraps the semantic-release
command, using the necessary plugins hooks (see config below). Otherwise, it works just the same and accepts the same options .
package.json
config
If more flexibility is needed, the plugins can be configured manually. This package provides verifyConditions
(deletes old comments) and publish
(creates new commens) plugins.
Default configuration (as encapsulated in the semantic-release-github-pr
command):
{
"release": {
"publish": "semantic-release-github-pr",
"verifyConditions": ["@semantic-release/github", "semantic-release-github-pr"]
}
}
CI
This plugin is best used with a CI build process to fully automate the posting of comments in Github PRs. Ideally, it should run whenever a PR is opened/updated.
Travis
To only run when necessary, we use the $TRAVIS_PULL_REQUEST
environment variable to detect whether the build is a "pull request build".
after_success:
- "[[ $TRAVIS_PULL_REQUEST != 'false' ]] npx semantic-release-github-pr"
CircleCI
To only run when necessary, we use the $CI_PULL_REQUEST
environment variable to detect whether the build has a corresponding pull request.
Unfortunately, CircleCI only supports building on push, not when a PR is created. This limits the usefulness of the plugin somewhat, as a build will have to be triggered manually after a PR is opened for the changelog to post.
test:
post:
- "[[ $CI_PULL_REQUEST != '' ]] npx semantic-release-github-pr"