1.6.0 • Published 2 years ago

semantic-release-pr-analyzer v1.6.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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

OptionDescriptionDefault
strategyanalyzing strategygithub
commitAnalyzerConfigstandard commit-analyzer plugin configurationdefault one for commit-analyzer
notesGeneratorConfigstandard release-notes-generator plugin configurationdefault one for release-notes-generator

Strategy

GitHub strategy ({strategy: 'github'})

Once PR is merged, GitHib creates a squash commit in the main branch following the rules below:

Number of commits in the pull requestMain Branch Commit TitleMain Branch Commit Description
Single commitThe title of the commit message for the single commit, followed by the pull request numberThe body text of the commit message for the single commit
More than one commitThe pull request title, followed by the pull request numberA 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.

Strict GitHub strategy ({strategy: 'strict-github'})

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.

Pull Request strategy ({strategy: 'pull-request'})

Always analyzes the pull request title and description as a commit.

Strict Pull Request strategy ({strategy: 'strict-pull-request'})

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.

Examples

You can see the sample configuration in the examples folder.