Skip to content

Commit 19c5917

Browse files
committed
Add step for updating packages in the release guide
1 parent 80ee7b3 commit 19c5917

3 files changed

Lines changed: 109 additions & 1 deletion

File tree

website/contributing/release-branch-cut-and-rc0.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ Documents in this section go over steps to run different types of React Native r
3939

4040
- Add and commit the extra file that got created at `sdks/hermes/.hermesversion`.
4141

42+
- Update packages in the monorepo by running `yarn bump-all-updated-packages`. Bear in mind that all the package bumps must be on patch level, and be on the minor you are working on. We need to publish the latest package changes so they will be included in RC0. Read more about the script and how they work [here](./release-updating-packages).
43+
44+
- Push the commit created by the previous command to the `0.XX-stable` branch so that CI will take care of releasing the new versions on npm.
45+
4246
### 2. Push the branch and test the current changes
4347

4448
You can now push the branch you created so that others can also start testing:
@@ -78,6 +82,8 @@ Once you're done with the testing, you can kick-off the bump and publishing of R
7882
latest: 0.68.1 next: 0.69.0-rc.0 nightly: 0.0.0-f617e022c
7983
```
8084

85+
- Hermes artifacts will be uploaded to the [Maven repository](https://repo1.maven.org/maven2/com/facebook/react/react-native-artifacts/). It might take ~20 minutes for Maven to process them.
86+
8187
### 4. Create a PR of the changelog using the generator
8288

8389
To generate the changelog, we rely on a dedicated tool called [`@rnx-kit/rn-changelog-generator`](https://github.com/microsoft/rnx-kit/tree/main/incubator/rn-changelog-generator) that will parse the custom changelog messages that contributors write in their PRs.
@@ -139,3 +145,11 @@ Once all the steps above have been completed, it's time to signal to the communi
139145

140146
- [@reactnative](https://twitter.com/reactnative) on twitter
141147
- RN Discord `#releases-coordination`
148+
149+
### 10. Bump minor version of all monorepo packages in `main`
150+
151+
The packages in the `react-native` monorepo must always be one minor version ahead of the latest or RC version (ex. if you have just cut `0.72-stable`, main needs to be in `0.73.x`. Once you're done with releasing the initial RC0, you should:
152+
153+
- Create a new branch in `react-native` from `main` in your own fork.
154+
- Run `yarn bump-all-updated-packages --release-branch-cutoff` to bump the minor versions of all packages.
155+
- Create a PR targeting `main` in `react-native` with the commit created by the previous command.
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
---
2+
id: release-updating-packages
3+
title: Updating monorepo packages
4+
---
5+
6+
This page contains relevant information about how to update packages in the `react-native` [monorepo](https://github.com/react-native-community/discussions-and-proposals/pull/480).
7+
8+
## Finding all packages that have unpublished changes
9+
10+
#### Use case
11+
12+
1. You want to identify each package with unpublished (on npm) changes and update its version. This can be used in release cycle if you have merged some fixes to `*-stable` branch.
13+
2. You want to force-bump each public package to the next minor version. This happens usually before release branch cutoff. In this case, please specify `release-branch-cutoff` argument before executing the script.
14+
15+
#### How to execute
16+
17+
`yarn bump-all-updated-packages` or `yarn bump-all-updated-packages --release-branch-cutoff`
18+
19+
#### Pseudocode
20+
21+
```
22+
check that no git changes are present
23+
24+
for each package:
25+
if package is private -> skip
26+
27+
if release-branch-cutoff argument is provided:
28+
bump package version to the next minor
29+
return
30+
31+
grep id of the last commit that changed package
32+
grep id of the last commit that changed version of the package
33+
34+
if these ids are different:
35+
bump package version (minor or patch)
36+
37+
align packages versions across whole monorepo
38+
commit changes if required
39+
```
40+
41+
### Notes
42+
43+
At the final step you will be asked if you want to commit all these changes. Always confirm committing if you want these packages to be published then on CircleCI, because the workflow that does this [will check that commit has a tag inside its message](https://github.com/facebook/react-native/wiki/Release-and-its-automated-processes#notes-1).
44+
45+
Updated versions will also be updated in packages consumers. This means if `@react-native/x` has `@react-native/y` as a dependency and we bump version of `@react-native/y`, then `@react-native/x` will have updated version of `@react-native/y` specified.
46+
47+
## Publishing an updated package to npm
48+
49+
We have a [CircleCI workflow](https://github.com/facebook/react-native/blob/292268ea3fa429cd1a1245b6239e0a85b59da02a/.circleci/config.yml#L1801-L1804), which runs **only on main or stable-\* branches**.
50+
51+
#### Pseudocode
52+
53+
```
54+
for each package:
55+
if last commit contains version change:
56+
if this commit has specific message:
57+
publish package to npm
58+
```
59+
60+
#### Notes
61+
62+
This workflow explicitly checks that commit has a specific [tag](https://github.com/facebook/react-native/blob/main/scripts/monorepo/constants.js#L11) inside its message. This is used to prevent accidental publishes. To create such specific commit you should use [script from above](https://github.com/facebook/react-native/wiki/Release-and-its-automated-processes#finding-all-packages-that-have-unpublished-changes).
63+
64+
If you want to bump package version and publish it to npm registry, your version change should be exactly in the last commit. This is because of two things:
65+
66+
1. If multiple commits are merged to `main` branch at the same time, CircleCI will execute workflows only once on top of the latest commit.
67+
2. To determine that version was changed we [evaluate the difference between HEAD and HEAD~1](https://github.com/facebook/react-native/blob/daeee2a6619db59391de3b7c6e08db0dbe2331aa/scripts/monorepo/find-and-publish-all-bumped-packages.js#L32-L35).
68+
69+
Example script output, where no package versions were changed:
70+
<img width="800" alt="Screenshot 2023-01-03 at 12 21 01" src="https://user-images.githubusercontent.com/28902667/210362611-97530b4d-0405-499c-9a3c-5542e069e929.png" />
71+
72+
## Align package versions across monorepo
73+
74+
> Side note: We do not anticipate that this script might be useful in future. With current monorepo setup, all packages versions should be updated and aligned by using `bump-all-updated-packages` script, both in `main` and `*-stable` branches.
75+
76+
#### Use case
77+
78+
You (or someone from release cycle team) want to verify that the latest versions of @react-native/\* packages are specified across monorepo, including `template`.
79+
80+
#### How to execute
81+
82+
`yarn align-package-versions`
83+
84+
#### Pseudocode
85+
86+
```
87+
check that no git changes are present
88+
89+
for each package x:
90+
for each package y:
91+
if y has x as dependency:
92+
validate that y uses the latest version of x
93+
```

website/sidebarsContributing.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@
4949
"release-candidate-patch",
5050
"release-stable-minor",
5151
"release-stable-patch",
52-
"release-troubleshooting"
52+
"release-troubleshooting",
53+
"release-updating-packages"
5354
]
5455
}
5556
]

0 commit comments

Comments
 (0)