Skip to content

📬 An action that wraps the npm-publish command

Notifications You must be signed in to change notification settings

matt-usurp/npm-publish

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Publish to Node Package Manager (NPM)

An action that wraps the npm-publish command. Also optionally calling the npm-version command before hand to allow for manual version publishing (see the version input parameter).

Example

Here is an example usage that publishes the version 2.3.12 once checked out:

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          registry-url: registry-url-here

      - uses: matt-usurp/npm-publish@v2
        with:
          version: '2.3.12'
          tag: 'next'
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

This essentially runs the following commands:

npm version 1.0.0 --force --allow-same-version --no-git-tag-version
npm publish --access public --tag next

Note We use --no-git-tag-version because this action is not intended to have side effects.

Inputs

You can configure the action with the following input parameters:

Name Type Required Default Description
version string false [current] A valid semantic version to use when publishing
tag string false latest The npm-dist-tag to be used when publishing
access string false public The npm-access to be used when publishing
dry-run boolean false false If the publish command should be dry ran
directory string false cwd The directory to execute commands from
silent boolean false false Should command output be silenced

Note The boolean type represents a value that is boolean truthy when evaluated. For a true value, use the string "true" or 1, all other values will represent false.

Outputs

This action has no outputs.