NPM-Version allows you to change the version of your projects package.json file in a simple GitHub action.
It is based on the NPM version cli command.
GitHub actions are a flexible way to automatically build your node project. I have found working on several projects the need to change the version of the package json, especially on a mono repo with multiple node projects.
Make sure that you have
- a GitHub account with Actions enabled
- an npm project
The command npm version
is ran with the parameters specified, this in turn will change the version stored in the package.json
An example of workflow
name: run npm-version pipeline
on: push
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master
- name: 'change version'
uses: reedyuk/npm-version@1.1.1
with:
version: '1.0.1'
package: 'subproject-directory/'
git-tag-version: 'true'
- version: The version you want to change your package json to.
- package(optional): defaults to current directory, but you can specify a location otherwise.
- git-tag-version(optional): defaults to false, if true, it will tag and commit the version - the same behaviour as git-tag-version in npm.
If using git-tag-version, it is recommended you do something as mentioned in this blog post. https://wildwolf.name/github-actions-how-to-avoid-running-the-same-workflow-multiple-times/