|
1 | 1 | # Release process of `design-system` |
2 | 2 |
|
3 | | -## Releasing package to `npm` registry |
| 3 | +## Overview |
| 4 | + |
| 5 | +The release process follows the git-flow branching model and consists of three phases: |
| 6 | +1. **Start Release** - Create a release branch and bump package versions |
| 7 | +2. **Finish Release** - Merge to `main` (production) and create a GitHub release |
| 8 | +3. **Publish Release** - Publish packages to `npm` registry |
| 9 | + |
| 10 | +## Branch Structure |
| 11 | + |
| 12 | +This workflow uses git-flow conventions: |
| 13 | +- `main` - Production-ready code (stable releases) |
| 14 | +- `release/<DATE>` - Release branch named by date (e.g., `release/2024-01-15`) for preparing a new production release |
| 15 | +- Feature branches should be merged to `main` via PRs |
| 16 | + |
| 17 | +## Step 1: Start Release (Version Bumping) |
4 | 18 |
|
5 | 19 | To deploy a package to the `npm` you need to be logged in as a `LiveChat` organization member. To confirm that you are logged in, you can use `npm whoami`. If you are not, use `npm login` and follow the instructions. |
6 | 20 |
|
7 | | -The deployment process consists of only single command: `npm run deploy`. It will execute several sub-commands and you can run them separately if you wish, namely: |
| 21 | +### 1.1 Create release branch |
8 | 22 |
|
9 | | -- `predeploy` - execute predeploy script |
10 | | - - `check` - fire up linter and unit tests that are provided per package |
11 | | - - `prettier` - format the code across the packages |
12 | | - - `build` - build the packages |
13 | | -- `lerna version` - create a new version of the packages based on the conventional commits |
14 | | -- `lerna publish` - publish the packages to `npm` registry |
| 23 | +Create a new release branch from the latest `main` branch with a date-based name: |
15 | 24 |
|
16 | | -During the build phase, |
17 | | -Lerna will ask you to confirm the version of the packages which Lerna chooses based on the conventional commits. |
18 | | -You will need to confirm the version if everything is correct. |
| 25 | +```bash |
| 26 | +git checkout main |
| 27 | +git pull origin main |
| 28 | +git checkout -b release/2024-01-15 |
| 29 | +``` |
19 | 30 |
|
20 | | - |
| 31 | +Replace `2024-01-15` with your current date in `YYYY-MM-DD` format. |
21 | 32 |
|
22 | | -### Disclamer |
| 33 | +### 1.2 Prepare release (bump versions) |
23 | 34 |
|
24 | | -Keep in mind that a package won't be versioned if it has not changed. In the future a changed package will catch up with other packages in versioning. For example, assuming that version of package `react-components` is `1.1.3` but `icons` lag behind a bit and are at `1.1.0` because no changes has been made since two deploys. If you make some changes in `react-components` and in `icons` both packages will get `1.1.4` version. |
| 35 | +Run the prepare-release script to bump package versions: |
| 36 | + |
| 37 | +```bash |
| 38 | +npm run prepare-release |
| 39 | +``` |
| 40 | + |
| 41 | +This command will: |
| 42 | +- Run `check` - execute linter and unit tests |
| 43 | +- Run `prettier` - format the code across packages |
| 44 | +- Run `build` - build the packages |
| 45 | +- Run `lerna version --conventional-commits --no-changelog --no-push` - create new package versions based on conventional commits |
| 46 | + |
| 47 | +During this phase, Lerna prompts to confirm the versions. |
| 48 | + |
| 49 | +Lerna creates the version commit and tags locally, but doesn't push. |
| 50 | + |
| 51 | +### 1.3 Commit and push version changes |
| 52 | + |
| 53 | +After Lerna determines the version, commit and push the version changes: |
| 54 | + |
| 55 | +```bash |
| 56 | +git add . |
| 57 | +git commit -m "chore(release): bump version to v<VERSION>" |
| 58 | +git push origin release/<DATE> |
| 59 | +git push origin --tags |
| 60 | +``` |
| 61 | + |
| 62 | +Replace `<VERSION>` with the actual version proposed by Lerna (you'll see it in the commit) and `<DATE>` with your date-based branch name. Tags must be pushed explicitly with `git push origin --tags`. |
| 63 | + |
| 64 | +### 1.4 Create Pull Request |
| 65 | + |
| 66 | +Open a PR from your `release/<DATE>` branch to `main`: |
| 67 | + |
| 68 | +- **PR Title**: `chore(release): release v<VERSION>` (e.g., `chore(release): release v1.2.3`) |
| 69 | +- **PR Description**: Reference the actual version determined by Lerna and summarize the changes |
| 70 | + |
| 71 | +### 1.5 Get approvals and merge |
25 | 72 |
|
26 | | -If you want to force versioning of a package you can use `--force-publish` flag with `lerna version` command instead of our `deploy` script. This will force Lerna to always version all packages, regardless of if they have changed since the previous release. Then they will all be published to the registry by `lerna publish from-git`. |
| 73 | +Get approvals and merge the PR to `main`. After merge, proceed to Step 2. |
27 | 74 |
|
28 | | -## Updating documentation |
| 75 | +## Step 2: Finish Release (Publish to npm) |
| 76 | + |
| 77 | +After the release PR has been merged to `main`: |
| 78 | + |
| 79 | +### 2.1 Pull latest main and fetch tags |
| 80 | + |
| 81 | +```bash |
| 82 | +git checkout main |
| 83 | +git pull origin main |
| 84 | +git fetch --tags |
| 85 | +``` |
| 86 | + |
| 87 | +### 2.2 Publish packages to npm |
| 88 | + |
| 89 | +Publish the packages to npm registry: |
| 90 | + |
| 91 | +```bash |
| 92 | +npm run deploy |
| 93 | +``` |
| 94 | + |
| 95 | +This runs `lerna publish from-package`, which: |
| 96 | +- Reads versions from `package.json` files |
| 97 | +- Publishes packages with bumped versions to npm |
| 98 | +- Does not create or push tags (already on remote from Step 1) |
| 99 | + |
| 100 | +### 2.3 Create GitHub Release |
| 101 | + |
| 102 | +On GitHub, add the release with the correct version and changelog: |
| 103 | + |
| 104 | +- The release should reference the tag created in Step 1 (e.g., `v1.2.3`) |
| 105 | +- Tag is already on `main` from Step 1 |
| 106 | +- Use the tag as the release name (e.g., `v1.2.3`) |
| 107 | +- Title: "What's Changed" or "Release v<VERSION>" |
| 108 | +- In the changelog, include: |
| 109 | + - Packages changed |
| 110 | + - Pull request links |
| 111 | + - Issue references |
| 112 | + - Author information |
| 113 | + - Follow the style used in previous releases |
| 114 | + |
| 115 | + |
| 116 | +## Important Notes |
| 117 | + |
| 118 | +### Branch naming |
| 119 | + |
| 120 | +Release branches are named with the current date (e.g., `release/2024-01-15`) in `YYYY-MM-DD` format since the actual version is determined later by Lerna based on conventional commits. |
| 121 | + |
| 122 | +### Package versioning behavior |
| 123 | + |
| 124 | +Keep in mind that a package won't be versioned if it has not changed. In the future a changed package will catch up with other packages in versioning. For example, assuming that version of package `react-components` is `1.1.3` but `icons` lag behind a bit and are at `1.1.0` because no changes has been made since two deploys. If you make some changes in `react-components` and in `icons` both packages will get `1.1.4` version. |
29 | 125 |
|
30 | | -On `Github` add the release with correct version and change-log. |
| 126 | +If you want to force versioning of a package you can use `--force-publish` flag when running the prepare-release script. This will force Lerna to always version all packages, regardless of if they have changed since the previous release. |
31 | 127 |
|
32 | | -- Tag is added automatically by [lerna](https://github.com/lerna/lerna), remember to target `main` branch. |
33 | | -- The name of the release is the name of the version/tag (eg. `v1.1.0`) |
34 | | -- First paragraph title can be set to `What's Changed`. |
35 | | -- In the change-log mention packages changed, link the pull requests and respective issues that are part of a release. Please follow the style used for previous releases (including author, PR, issue, and title info). |
36 | | - Example of correctly filled release note: |
37 | | - <img width="894" alt="example of release docs in GitHub" src="https://user-images.githubusercontent.com/7773964/182624431-232d6cea-9d0c-4455-afd9-365c88a1ab57.png"> |
|
0 commit comments