Skip to content
package

GitHub Action

Node.js Package Information

v1.0.0 Latest version

Node.js Package Information

package

Node.js Package Information

Retrieve information from a package.json file

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Node.js Package Information

uses: GeekyEggo/[email protected]

Learn more about this action in GeekyEggo/npm-pkg

Choose a version

Build

Node.js Package Information

A GitHub Action for retrieving information from a package.json file, similar to npm pkg get, with some extra ✨.

📖 Use Case

Publishing a prerelease version of a package can be tricky. By default, npm publish ignores the prerelease identifier, and doesn't take into consideration the tag defined in the package's version field.

Using @geekyeggo/npm-pkg solves this by parsing the version.tag from the package.json file; for example, given a version of 1.2.3-beta.0, a workflow can access the tag directly:

npm publish --tag {{ steps.pkg.outputs.version-tag }}

⚡ Usage

See action.yml

steps:
  - uses: actions/checkout@v4

  - uses: geekyeggo/npm-pkg@v1
    id: pkg

  # When version is "1.0.0-rc.1", the tag output will be "rc".
  - run: echo ${{ steps.pkg.outputs.version-tag }}

📥 Inputs

Name Description
path Optional path to the package.json file; default "./package.json".

📤 Outputs

Name Description
version-major Major version number
version-minor Minor version number
version-patch Patch version number
version-tag Tag parsed from the prerelease identifier, for example "beta"; default "latest".

Interested in more outputs? Consider creating a pull request. 💙