Deploy to npm

You can use Bitbucket Pipelines to build, test and publish your npm package.

You can use the feature of pushing back to your repository from within your pipeline to update the tag.

Be sure to include [skip ci] in the commit message of your version bump to avoid an infinite loop of builds.

Use the npm publish pipe to publish the package to the npm registry. To publish to a private npm package, edit your package.json to add a section like the example below.

1 2 3 4 5 6 7 8 package.json { "name": "package", "version": "1.0.11", "description": "Description", "publishConfig":{"registry":"my-internal-registry.local"} }

There are even more examples in the pipe repository of how to use the pipe with npm.

For this example, we need to add the $NPM_TOKEN variable in Bitbucket.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 bitbucket-pipelines.yml image: node:10.15.1 pipelines: default: - step: name: Build and Test script: - npm install - npm test - step: name: Publish deployment: production script: - npm version minor -m "Upgrade to %s [skip ci]" - git push && git push --tags - pipe: atlassian/npm-publish:0.2.0 variables: NPM_TOKEN: $NPM_TOKEN

Additional Help