semantic-release-pr-analyzer
semantic-release plugin that imitates the behaviour when the team relies on the squash and merge strategy on GitHub.
Install
$ npm install semantic-release-pr-analyzer -D
Usage
The plugin can be configured in the semantic-release configuration file:
{
"plugins": [
[
"semantic-release-pr-analyzer",
{
"strategy": "github"
}
]
]
}
Configuration
Options
Option | Description | Default |
---|---|---|
strategy |
analyzing strategy | github |
commitAnalyzerConfig |
standard commit-analyzer plugin configuration | default one for commit-analyzer |
notesGeneratorConfig |
standard release-notes-generator plugin configuration | default one for release-notes-generator |
Strategy
{strategy: 'github'}
)
GitHub strategy (Once PR is merged, GitHib creates a squash commit in the main branch following the rules below:
Number of commits in the pull request | Main Branch Commit Title | Main Branch Commit Description |
---|---|---|
Single commit | The title of the commit message for the single commit, followed by the pull request number | The body text of the commit message for the single commit |
More than one commit | The pull request title, followed by the pull request number | A list of the commit messages for all of the squashed commits, in date order |
You can read more about this in the official GitHub docs. This plugin hijacks semantic-release flow and replaces the commits list with the one that respects these rules into the mix.
{strategy: 'strict-github'}
)
Strict GitHub strategy (The same as the GitHub strategy, but it will throw an error if the first commit title is not equal to the pull request title.
{strategy: 'pull-request'}
)
Pull Request strategy (Always analyzes the pull request title and description as a commit.
{strategy: 'strict-pull-request'}
)
Strict Pull Request strategy (The same as the Pull Request strategy, but it will throw an error if the first commit body is not equal to the pull request description.
Environment variables
env.GITHUB_TOKEN
GitHub token to access your repository. Using the secrets.GITHUB_TOKEN
value should be enough.
env.GITHUB_PR_NUMBER
The pull request number. In the context of GitHub actions, it is achievable as github.event.pull_request.number
env.GITHUB_REPOSITORY
Repository path, for example n0th1ng-else/semantic-release-pr-analyzer
. For GitHub actions workflow it is
set automatically.