|
| 1 | +# How To Cut a Pattern Lab Release |
| 2 | + |
| 3 | +We use a handful of tools to help automate and simplify the process of cutting a new Pattern Lab release. Namely: [Lerna](https://github.com/lerna/lerna) and [Auto](https://intuit.github.io/auto/) |
| 4 | + |
| 5 | +## Release Prep |
| 6 | + |
| 7 | +1. Make sure any/all the code ready to get released is merged down to the `dev` branch and all CI checks, etc are passing as expected |
| 8 | + |
| 9 | +2. Git checkout the `dev` branch locally and make sure: |
| 10 | +- You've run `yarn` to install the latest dependencies |
| 11 | +- You don't have any local changes pending |
| 12 | + |
| 13 | +``` |
| 14 | +git checkout dev |
| 15 | +git pull |
| 16 | +yarn |
| 17 | +git status # confirm no pending changes |
| 18 | +``` |
| 19 | + |
| 20 | +3. Before running the publish command, I also like to run the `build` command to be extra sure everything compiles fine locally (ex. Node.js version matches with the version of Sass that's installed, gotchas like that) |
| 21 | + |
| 22 | +``` |
| 23 | +yarn build |
| 24 | +``` |
| 25 | + |
| 26 | +4. You'll also want to make sure you have a `.env` file in your PL Node repo root (and create one if you don't) |
| 27 | + |
| 28 | +You can grab the NPM + Github tokens needed here by heading to https://github.com/settings/tokens/new (grant repo access) and https://www.npmjs.com/settings/NPM_USER/tokens |
| 29 | + |
| 30 | +``` |
| 31 | +## .env |
| 32 | +export GH_TOKEN=PASTE_GITHUB_TOKEN_HERE |
| 33 | +export NPM_TOKEN=PASTE_NPM_TOKEN_HERE |
| 34 | +``` |
| 35 | + |
| 36 | +I personally like to use zsh's `env` plugin (already installed with Oh My ZSH) which has instructions for enabling here https://github.com/johnhamelink/env-zsh |
| 37 | + |
| 38 | +> Pro tip: you can quickly check to see if your env variable tokens are available for these CLI commands by running `npx auto release --dry-run` which will throw an error if the tokens above can't be found! |
| 39 | +
|
| 40 | +5. Finally you'll also want to confirm that you're logged into your NPM account with access to publish to the Pattern Lab NPM org by running `npm login` and following the prompts. |
| 41 | + |
| 42 | +## Cutting The Release |
| 43 | + |
| 44 | +6. Run the `publish` command |
| 45 | + |
| 46 | +Ok - with all that prep out of the way, the actual release process is pretty quick and should be super straightforward. |
| 47 | + |
| 48 | +Simply run the `yarn run publish` command and include the type of SEMVER release you want to cut. |
| 49 | + |
| 50 | +So for example: |
| 51 | + |
| 52 | +``` |
| 53 | +yarn run publish minor |
| 54 | +
|
| 55 | +## alternatively you can include the exact version you want to publish |
| 56 | +yarn run publish v5.14.0 |
| 57 | +``` |
| 58 | + |
| 59 | +Lerna should prompt you with a confirmation that the version about to get released matches up with what you expect ^ |
| 60 | + |
| 61 | +7. Manually (re)run the `auto release` command? |
| 62 | + |
| 63 | +Ok, if everything built and published successfully, this final step may or may not be required... |
| 64 | + |
| 65 | +Normally the `auto release` command should run automatically after Lerna finishes publishing to NPM. This command will create the Github release associated with the latest Git tag, add any relevant release notes, and comment on related PRs, however the last couple of releases required this last step to get re-run manually. |
| 66 | + |
| 67 | +Note that you'll need to replace the `from` and `use-version` version numbers to match the last previous Git tag and this next release getting cut. |
| 68 | + |
| 69 | +``` |
| 70 | +npx auto release --from v5.11.1 --use-version v5.12.0 |
| 71 | +``` |
| 72 | + |
| 73 | +8. Confirm the [Github release](https://github.com/pattern-lab/patternlab-node/releases) was added and manually tweak any release notes as needed. |
0 commit comments