Skip to content

Node.js Package Information

Actions
Retrieve information from a package.json file
v1.0.0
Latest
Star (1)

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. 💙

Node.js Package Information is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.

About

Retrieve information from a package.json file
v1.0.0
Latest

Node.js Package Information is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.