npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

semantic-release-github-pr

v6.0.3

Published

A `semantic-release` plugin that creates a changelog comment on Github PRs.

Downloads

1,215

Readme

semantic-release-github-pr

Tests workflow npm semantic-release

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

image

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 semantic-release-github-pr

Usage

npx semantic-release-github-pr

It helps to think about semantic-release-github-pr as a variation on semantic-release's default behavior, using the latter's plugin system to modify some behaviors:

  • If a new release would result from running semantic-release, instead of publishing a new release of a package, it posts a comment with the changelog to matching Github PRs.

  • It posts a static message when there's no release (for clarity).

  • It cleans up any PR comments it previously made (to keep from flooding PRs or leaving outdated information).

Which PRs get a comment?

A PR gets a comment if:

  1. The PR's from branch matches the current branch (that this plugin is being run on).

    To cover multiple CI scenarios (see below), either of:

    1. The PR's test merge commit matches the current branch's git HEAD.
    2. The PR and the current branch have the same git HEAD.
  2. The PR's base branch matches master (default) unless otherwise configured via the baseBranch option.

Configuration

It is assumed the user is already fully familiar with semantic-release and its workflow.

Github

Github authentication must be configured, exactly the same as for semantic-relase's default @semantic-release/github plugin. PR comments will be posted by the associated GitHub user.

Release config

It's possible to configure the expected base branch when matching a PR via a baseBranch option set in the release config.

E.g., in a package.json release config:

{
  "release": {
    "baseBranch": "staging"
  }
}

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.

GitHub Actions

This plugin relies on semantic-release's dry-run feature. Unfortunately, that feature is gated by strict run-time checks, including one that ensures that the branch semantic-release runs on is in the release configuration. It depends on env-ci to enforce the checks in CI environments, which doesn't properly resolve the branch name when running in GitHub Actions, requiring a workaround:

    - run: git checkout -b ${{ github.head_ref }}
    - run: unset GITHUB_ACTIONS && npx semantic-release-github-pr

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 || exit 0"

CircleCI

To run only 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.

post:
  - "[[ $CI_PULL_REQUEST != '' ]] && npx semantic-release-github-pr || exit 0"