Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
alert-circle

GitHub Action

Extract Package Version

v1.2.1

Extract Package Version

alert-circle

Extract Package Version

Extract Package Version for npm packages

Installation

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

              

- name: Extract Package Version

uses: saionaro/extract-package-version@v1.2.1

Learn more about this action in saionaro/extract-package-version

Choose a version

extract-package-version

Allows you to get the npm version of the package in your Github Actions workflow

Usage

Inputs

  • path: The directory where package.json can be found (defaults to root of repo)

Outputs

  • version: The version of current NPM package

Example workflow - get NPM version

on: push

name: Create Build

jobs:
  build:
    name: Create Build
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@master

      - name: Extract version
        id: extract_version
        uses: Saionaro/extract-package-version@v1.1.1
      # From now you can access the version
      - name: Print version
        run: echo ${{ steps.extract_version.outputs.version }}

Example workflow - get NPM version of subdirectory (useful in monorepos)

on: push

name: Create Build

jobs:
  build:
    name: Create Build
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@master

      - name: Extract version
        id: extract_version
        uses: Saionaro/extract-package-version@v1.1.1
        with:
          path: mysubdir
      # From now you can access the version
      - name: Print version
        run: echo ${{ steps.extract_version.outputs.version }}