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

node-package-release-action

v2.1.19

Published

A template to create custom GitHub Action with TypeScript/JavaScript.

Downloads

19

Readme

node-package-release-action

Build Test ESLint CodeQL

Stop running npm version patch manually to release a new version of your NPM package. Let this Action automate for you. Trigger it on GitHub or schedule a weekly or monthly release.

Examples

name: Release

on:
  schedule:
    - cron: '0 12 * * 0' # every sunday noon

jobs:
  release:
    name: Release
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - id: release
        uses: CatChen/node-package-release-action@v2
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }} # optional
          directory: './' #optional
          release-type: prerelease # optional
          prerelease: false # optional
          update-shorthand-release: false
          skip-if-no-diff: false
          dry-run: false # optional

      - env:
          TAG: ${{ steps.release.outputs.tag }}
          SKIPPED: ${{ steps.release.outputs.skipped }}
        run: |
          if [[ "$SKIPPED"='true' ]]
          then
            echo 'Release is skipped.'
          else
            echo "Release $TAG successfully."
          fi

Options

github-token

The default value is ${{ github.token }}, which is the GitHub token generated for this workflow. You can create a different token with a different set of permissions and use it here as well.

directory

The default value is "./". It's where the package.json locates.

release-type

Which part of the semver should be increased for the next release. Valid inputs are major, premajor, minor, preminor, patch, prepatch and prerelease. The list of valid inputs is from semver.inc, which is used by the npm version command. The default value is prerelease. This is independent from the prerelease input.

prerelease

This controls whether the GitHub Release should be marked as a prerelease. The default value is false. This is independent from the release-type input.

update-shorthand-release

GitHub Action documentation recommends updating shorthand releases like v1 and v1.2 when releasing the latest v1.2.*. Set this to true when using this Action to release other Actions. The default value is false.

skip-if-no-diff

This controls whether this action should do nothing if there's no changes since last release of the same release type. If we release a minor upgrade to 1.2.3 or 1.2.4-0 it should be 1.2.4. If 1.2.4 and 1.2.3 are the same and if skip-if-no-diff is set to true, 1.2.4 won't be created. 1.2.4-* won't be used in the comparison. The default value is false.

diff-targets

This controls the diff targets used with skip-if-no-diff. The default value is ".". For example, it could be "{package.json,lib/**/*}" for a typical TypeScript project with compiled files in the lib directory. Use glob pattern to match multiple directories if necessary, for example "{src,lib}" instead of "src lib" or "{src, lib}" to match both the src directory and the lib directory.

dry-run

This controls whether this is a dry run. The default value is false. It's used for debugging only.

FAQ

How do all the release-type options work?

Let's start with the easy ones. major, minor and patch increase their corresponding part and reset the parts behind them to zero.

  • 2.3.4 + major => 3.0.0
  • 2.3.4 + minor => 2.4.0
  • 2.3.4 + patch => 2.3.5

prerelease is an interesting one. It increases the prerelease part if it exists. Otherwise, it increases the patch part and append a prerelease zero suffix.

  • 2.3.4-0 + prerelease => 2.3.4-1
  • 2.3.4 + prerelease => 2.3.5-0

premajor, preminor and prepatch are like major, minor and patch with a prerelease zero suffix, regardless of whether the original version has a prerelease part.

  • 2.3.4 + premajor => 3.0.0-0
  • 2.3.4-5 + premajor => 3.0.0-0
  • 2.3.4 + preminor => 2.4.0-0
  • 2.3.4-5 + preminor => 2.4.0-0
  • 2.3.4 + prepatch => 2.3.5-0
  • 2.3.4-5 + prepatch => 2.3.5-0

Can I create a Workflow to manually release with any release type I want at the time?

Yes! You can provide inputs in the Action web interface before manually triggering a Workflow. GitHub Action documentation describes how to do this. Below is an example.

name: Release

on:
  workflow_dispatch:
    inputs:
      release-type:
        description: 'Release Type'
        required: true
        default: 'patch'
        type: choice
        options:
          - major
          - minor
          - patch
          - premajor
          - preminor
          - prepatch
          - prerelease
      prerelease:
        description: 'Prerelease'
        required: true
        default: false
        type: boolean
      dry-run:
        description: 'Dry run'
        required: true
        default: false
        type: boolean

  release:
    name: Release
    concurrency: release
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          ref: 'main'

      - uses: CatChen/node-package-release-action@v2
        with:
          release-type: ${{ inputs.release-type || 'patch' }}
          prerelease: ${{ inputs.prerelease || false }}
          dry-run: ${{ inputs.dry-run || false }}

How do I know if skip-if-no-diff took effect?

Use an output called skipped. See the first code example as a reference.

What does "last release of the same release type" mean for skip-if-no-diff?

Let's say these are the releases returned from git tag:

  • v1.0.0
  • v1.1.0
  • v1.2.0
  • v1.2.1
  • v1.2.2
  • v1.2.3
  • v1.2.4-0
  • v1.2.4-1

We are going to make a patch release. The release version will be 1.2.4. 1.2.4's last release of the same type (patch) is 1.2.3.

Before 1.2.3 there is 1.2.2, but 1.2.2 + patch doesn't equal to 1.2.4. 1.2.2 isn't the last release of the same release type.

After 1.2.3 there is 1.2.4-0 and 1.2.4-0 + patch equals to 1.2.4. However, we should pick 1.2.3. If there's any diff since 1.2.3 we should make the 1.2.4 release. When we say "release 1.2.4 as a patch if this patch contains any change", we mean changes since 1.2.3. Even if there's no change since 1.2.4-0 we should still make the release. That's because 1.2.4-0 as a prepatch release may already contains all the changes we want so there's no change since 1.2.4-0.