You can publish manually to any registry, or automatically to the default NPM registry as the Form Builder Team user.
You will need to be a member of the Ministry of Justice organisation on NPM. You can get access from the Digital Service Desk. (They're on Slack.)
Once you are a member of the organisation you can publish from the command line.
CircleCI is configured to publish to NPM when two conditions are met:
- A change is made to master
- The change has Git tag with the version number
The first condition is met whenever a PR is merged to master.
To meet the second condition, at the root of your package and on the branch you want to merge, at the command line execute:
npm version patch
git push
This will increment the version number in package.json
and package-lock.json
(for instance, from 1.0.1
to 1.0.2
), and it will create a Git tag with the same information. When the PR is merged CircleCI will checkout the package from Git, interrogate the tags, and publish the package to NPM. (It won't try to publish if the tag isn't present -- so if you need to make a change to master without publishing, don't execute npm version patch
.)
To simplify the process -- and any confusion about when to tag -- you can get a PR approved and execute these commands as the very last thing before you merge.
You can also increment the minor or major versions with a similar command:
npm version minor
Or:
npm version major
Of course, you can add tags without changing the package version, but you should try to keep them syncronised.
The Form Builder Team user is able to publish because CircleCI is configured with an environment variable containing a token from NPM. You can revoke that token at any time.