Uploading a package by hand is not a convenient solution if you need to do it more than once. In cases where you want to frequently generate and publish a new version of a library, you can use an Azure pipeline. As well as to the automation that this gives you, it is also a great way to introduce repeatability and reliability, since you can now use all of the benefits that pipelines offer you.
As an example, you can find a possible build definition for creating an npm package and publishing that as follows. The sources for this build are from an open source Microsoft GitHub repository called tfs-cli.
In this pipeline, there are three usages of the built-in npm task:
- The first occurrence is an npm install command. This command is used for installing the dependencies for this package:
- The second occurrence is running a custom command, build. This command is defined in the source code itself using package.json and is used for transpiling the sources from TypeScript to JavaScript:
- The final and third task is running the npm publish command to publish the generated package to an npm feed. In this instance, there is no external feed selected but a built-in target registry: the Azure Artifacts feed:
After running this build, your package is available in your feed.