Skip to content

A github action that reads and extracts your node and npm versions from your package.json

License

Notifications You must be signed in to change notification settings

skjnldsv/read-package-engines-version-actions

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

Read node and npm versions from engines field in package.json

Output node and npm version numbers from package.json

Example workflow

package.json

{
  "name": "your-package",
  "engines": {
    "node": "12.13.x",
    "npm": "^6.1.3"
  }
}

.github/workflow/test.yml

name: Get node and npm versions from package.json

on: push

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: Read node and npm versions from package.json
        uses: skjnldsv/read-package-engines-version-actions@v2
        id: package-engines-versions

      - name: Show node version number
        run: echo "Node version is ${{ steps.package-engines-versions.outputs.nodeVersion }}"
        # Version is 12.13.x

      - name: Show npm version number
        run: echo "Npm version is ${{ steps.package-engines-versions.outputs.npmVersion }}"
        # Version is ^6.1.3

Inputs

path

Path of package.json, ./ by default.

path/to/package.json

{
  "name": "your-package",
  "engines": {
    "node": "12.13.x",
    "npm": "^6.1.3"
  }
}
name: Get node and npm versions from package.json

on: push

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: Read node and npm versions from package.json
        uses: skjnldsv/read-package-engines-version-actions@v2
        with: 
          path: "./path/to/package.json"
        id: package-engines-versions

      - name: Show node version number
        run: echo "Node version is ${{ steps.package-engines-versions.outputs.nodeVersion }}"
        # Version is 12.13.x

      - name: Show npm version number
        run: echo "Npm version is ${{ steps.package-engines-versions.outputs.npmVersion }}"
        # Version is ^6.1.3

fallbackNode, fallbackNpm

fallbackNode and fallbackNpm allows you to define a fallback value if not defined

{
  "name": "your-package",
  "engines": {
  }
}
name: Get node and npm versions from package.json

on: push

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: Read node and npm versions from package.json
        uses: skjnldsv/read-package-engines-version-actions@v2
        with: 
          fallbackNode: '^14'
          fallbackNpm: '^6'
        id: package-engines-versions

      - name: Show node version number
        run: echo "Node version is ${{ steps.package-engines-versions.outputs.nodeVersion }}"
        # Version is ^14

      - name: Show npm version number
        run: echo "Npm version is ${{ steps.package-engines-versions.outputs.npmVersion }}"
        # Version is ^6

License

MIT

About

A github action that reads and extracts your node and npm versions from your package.json

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 84.2%
  • JavaScript 15.8%