NPM publishing setup
We have to create an easy pipeline with which we can easily publish new NPM package versions. We should aim for a fully automated pipeline on master.
Current suggestion:
TL;DR
In my (@leipert) private projects I started using semantic-release together with commitizen. See for example here: cache-service-file-cache:/.gitlab-ci.yml#L27-32.
Workflow
It works like this:
-
During your work you adhere to a parseable commit message format. I have chosen to stick with the default "angular" style. They support a lot more styles, we could pick the one that fits our workflows. I am using commitizen to write the commit messages.
-
Once you merge to master, they read the commits since the last tag and find out whether the next release will be major, minor or patch. Then they tag the commit and publish the changelog to the release page (e.g. v2.0.0). Of course the package get's published to npm as well.
It really feels like magic and the only thing you need to do is define two env variables:
GITLAB_TOKEN
and NPM_TOKEN
Caveats
-
I'd like the CI to do a commit where they append the changelog to a file, bump the version number and tag that commit. There is probably a plugin for semantic-release out there, but I haven't had the time to configure it.
-
The gitlab-plugin for semantic release is missing two cool things the GH plugin supports:
- The ability to create issues if something goes wrong during publishing.
- Writing comments under the relevant issue numbers mentioned in commit messages.