Skip to content
activity

GitHub Action

package.json version reader

v1.0.0 Latest version

package.json version reader

activity

package.json version reader

outputs the package.json version

Installation

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

              

- name: package.json version reader

uses: krstphrrr/[email protected]

Learn more about this action in krstphrrr/package-json-version-reader

Choose a version

Read package version actions

Read your version in package.json

Example workflow

package.json

{
  "name": "your-package",
  "version": "1.0.0",
}

.github/workflow/test.yml

name: Get version from package.json

on: push

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v1

      - name: Read package.json
        uses: krstphrrr/package-json-version-reader@v1
        id: package-version

      - name: Show version number
        run: echo "Version is ${{ steps.package-version.outputs.version }}"
        # Version is 1.0.0

Inputs

path

Path of package.json, ./ by default.

path/to/package.json

{
  "name": "your-package",
  "version": "0.5.0",
}
name: Get version from package.json

on: push

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v1

      - name: Read package.json
        uses: krstphrrr/package-json-version-reader@v1
        with: 
          path: "./path/to/package.json"
        id: package-version

      - name: Show version number
        run: echo "Version is ${{ steps.package-version.outputs.version }}"
        # Version is 0.5.0

License

MIT