Skip to content

Publish Release on NPM

James Thompson edited this page Oct 22, 2020 · 4 revisions

Preparation

Stop Local Dev Servers

Stop all yarn start or yarn serve commands.

Update working copy to latest changes in master

To release the latest code, you'll need the latest code ✅😅.

$ git checkout master
$ git pull

Clean up generated assets

To ensure a clean release, you'll want to make sure that generated assets are created as cleanly as possible.

  • The npm publish command will package up everything in dist/ and publish to NPM.
# Clean up generated files
$ rm -rf dist

Install fresh dependencies

Development dependencies should be reinstalled to minimize the chances for unexpected errors.

$ yarn install:clean

Releasing to NPM

Prerequisites

Public NPM Registry

The npm get registry command should respond with the public NPM registry (https://registry.npmjs.org/ at the time of writing this document).

$ npm get registry
https://registry.npmjs.org/

This should be handled by the project .npmrc configuration, but different versions of the npm command may respond differently.

NPM Authentication

The npm whoami command should respond with "helix-ui".

$ npm whoami
helix-ui

If npm whoami returns a different value or no value, STOP!

Ask a HelixUI dev for help, before you continue.

1. Create Release Branch

Given that the release tasks will update package.json, we want to make sure we stick to a feature branch workflow so that we can merge the version changes back into master.

The name of this branch doesn't matter, but it does need to be based off master.

A good naming convention to follow is release-{VERSION} (e.g., release-Helix-React-v1.3.0-alpha)

$ git checkout -t -b release-{VERSION}

2. ❗IMPORTANT❗- Build Distro

Since we are currently in alpha, we do not have an automated build pipeline. So, the following manual step MUST be completed before publishing the release onto NPM.

$ yarn build

3. Bump Version

npm already has logic built-in to bump the version number. Run npm help version for more information.

WARNING: npm currently does not have a dry run option. Start with premajor, preminor, or prepatch to make sure everything is running smoothly before you publish.

$ npm version (major | minor | patch | premajor | preminor | prepatch | prerelease)

Version Example

Say we're currently at 0.0.1 of Helix-React.

npm version prepatch   # 0.0.2-rc.0
npm version prerelease # 0.0.2-rc.1
npm version patch      # 0.0.2

npm version preminor   # 0.1.0-rc.0
npm version prerelease # 0.1.0-rc.1
npm version minor      # 0.1.0

npm version premajor   # 1.0.0-rc.0
npm version prerelease # 1.0.0-rc.1
npm version major      # 1.0.0

4. Publish Assets

NOTE: This step requires npm whoami to be set up correctly.

To publish new assets to NPM, just run:

$ npm publish

Verify via Browser

Check the version displayed for the helix-react package on npmjs.com.

Verify via CLI

Check the output of:

$ npm view @helix-design-system/helix-react version versions

5. Update Master

Because npm version uses and modifies package.json, you'll need to merge changes back into master so that future releases will start with the correct version.

  1. Push your branch to github
  2. Submit a PR against the master branch
  3. Merge the PR
  4. Delete version branch