To release to the npm registry, a travis job to deploy is setup to occur
on a tag being pushed to the GitHub repo. We can use
the lerna version
command that will increment the version in package.json
in each package and
add a git tag. To handle this, there is a release
script (that uses the release.sh
script).
By default, this will increment the patch version:
yarn release
If you want to define which version to increment, you can pass in an argument:
yarn release major
If you wanted to take over exactly which version, you can use specify a semver:
yarn release 1.1.1
This should automatically push the new tag to GitHub and a Travis build will get triggered.
This will also use the NPM_API_KEY
environment variable.
To publish all the modules to the npm registry, a travis job can be used
to react to a git tag being pushed to the GitHub repo from
the release section. This will execute the yarn do:publish
command which will in turn
execute the lerna publish --contents dist from-git
. The from-git
part tells lerna to use the
git tag that was push. The --contents dist
is used since we have to compile from TypeScript. This
also requires that each package has a dist
directory to be published with.
Also note, it may be a good idea to copy a README over to the dist
directory so npm will show this.
The reason of yarn do:publish
and not just yarn publish
is due to this
yarn issue.