Release Process
Note: You will need to login to private Banno registry (npm login) to be able to publish to it. See the instructions at the top of the https://npm.banno-internal.com/ page. (Use your Banno LDAP credentials.)
Recommended Method
It is recommended to use a tool such as np, publish-please, or release-it when releasing a new version of a project. They ensure that necessary steps are taken, and avoid the gotchas of npm publish. The following process assumes you are using np:
Make sure the distribution files have been built (if applicable) and that tests are passing.
Run the
nptool and answer the interactive questions.Very important: If it is a prerelease, or an older version, or anything other than what should be the new default version of a project, you must specify a tag: e.g.
np --tag nextfor a prerelease, ornp --tag olderfor an old version that was never published. More info: https://docs.npmjs.com/cli/dist-tag
Manual Method
- Make sure you are in the
masterbranch and have pulled the latest commits. - Increment the version in the
package.jsonto the new version. Be sure to follow semantic versioning. - Run all unit and E2E tests.
- Build the distribution files. This will depend on the project – check the docs and code. Older projects use
grunt dist/gruntorgulp; newer projects will probably use npm scripts. - Stage and commit your changes with a message like “Release vX.X.X”.
- Create a new tag:
git tag vX.X.X -a -m 'Tagging vX.X.X' - Push everything to the remote repository:
git push && git push --tags - If releasing the “latest” version of a project, publish it to the registry:
npm publish
- Very important: If it is a prerelease, or an older version, or anything other than what should be the new default version of a project, you must specify a tag: e.g.
npm publish --tag nextfor a prerelease, ornpm publish --tag olderfor an old version that was never published. More info: https://docs.npmjs.com/cli/dist-tag
Note that if you have git-extras installed, you can perform steps 5-7 (after you stage your changes) with a single command: git release vX.X.X
Proposed Build Process
The process that follows has been discussed but has not yet been decided on.
This document contains recommendations/guidelines on how to construct a build process and how github repositories are organized for JS projects.
Following this process ensures that releases only contain the output of the dist task. It also ensures the source branch (master) does not include distributables. Doing it this provides the following benefits:
- Fewer files in the release branch means that environments that don’t need the source code (production deploys and higher-level projects) are faster – They don’t need to download or store the source, or rebuild the distributables.
- The separation of files and history between source and distribution makes it cleaner to look at and work with. The release branch can be distributed as-is (through links, Bower, zipped packages, etc), and developers can ignore those files during development.
Prepare a Repository
In order to prepare a repository for distributable releases, create a release branch and a snapshot branch, both with an empty initial commit. You can do this by using the –orphan flag with git checkout.
Assumptions
Each project has a package.json file with a version, name, homepage URL, and repository URL.
The grunt dist task should prepend the application code with the version number from package.json (using grunt-banner or similar tool). It should create all the release code (including mock services) in a .gitignored dist folder.
Each project should have a README that describes the build process (or points to this documentation).
Build Process
Decide on the new version number. It should follow semantic versioning.
Switch to the
masterbranch and ensure it is up to date and the working directory is clean.Run tests (and make sure it’s working in the browser too).
Add gulp-banno-release (if not installed) and run
gulp release --setversion=X.X.X. This task will do the following:- Update the version number across the codebase: README, docs,
package.jsonandbower.json, etc. - Build the distribution. This is usually done with
grunt dist. Ensure the distributables have been built correctly. (For libraries: Copy/build a Bower manifest for the distribution.) - Commit the changes. Use a commit message like “Release vX.X.X”.
- Copy the current commit hash to clipboard for later (
git rev-parse HEAD). - Switch to the
snapshotbranch and make sure it is up to date and the working directory is clean. - Merge
masterintosnapshotwith the version number as the commit message. - Switch to the
releasebranch and make sure it is up to date and the working directory is clean. - Copy files from the .gitignored
distfolder to the project’s root directory. - Commit and push new dist files to
releasebranch with version and commit hash (from your clipboard from step 2) as the message (e.g.v0.0.1 e2bc44fa491706d9bd0f3ccb3f3011e6b98b9108). - Create an annotated tag based off the latest commit to the
releasebranch with the same commit message as the previous step.
git tag v0.0.1 -a -m 'v0.0.1 e2bc44fa491706d9bd0f3ccb3f3011e6b98b9108'- Push the changes (with tags) to GitHub:
git push --tags origin master snapshot release
- Update the version number across the codebase: README, docs,
Note
Commits should never otherwise be pushed to the snapshot or release branches.
Examples
(link to some of our projects that follow this)
References
This process is loosely based on the release process of angular-ui/bootstrap. They put all versions of their build files in a separate branch, and keep a separate repository up to date with release files, which is what their bower registry is linked to. Rather than using a separate repository for release files, this process just uses another branch.