Increase Angular6 Library version automatically in DevOps

1.9k views Asked by At

I am building an Angular Library to be used in other Angular Applications. I want to create a build pipeline in DevOps (VSTS) so after each commit to git, the library will be built and published as Artefacts to be used.

Till now everything works fine, my problem is with Angular Library version. If I tried to publish the Library with the same version, I receive this error:

Forbidden The feed already contains the package 'my-lib' at version '0.0.1': my-lib

My build pipeline:

enter image description here

To solve this problem, I have either to change the Version in the package.json before every builds enter image description here

Or through the cli: npm version 0.0.2

Can I do it automatically? which means, no need for extra actions except commit/push? I had searched for a long time, but couldn't find a solution. Thanks

1

There are 1 answers

0
Mac_W On BEST ANSWER

To update your version you need to run npm version command by passing one of the following: patch, minor or major ->

  • npm version patch would update your package version from 1.3.0 to 1.3.1
  • npm version minor would update your package version from 1.3.0 to 1.4.0
  • npm version major would update your package version from 1.3.0 to 2.3.0

You can add this command to your pipeline to be run when you merge to master or however you pipeline is set up.

Please see: https://docs.npmjs.com/cli/version