Skip to content

Commit b9c4b29

Browse files
committed
Update release branch cut guide
1 parent 8aa46d7 commit b9c4b29

2 files changed

Lines changed: 103 additions & 0 deletions

File tree

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ 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 – read more about the individual scripts and what they do [here](/contributing/updating-packages).
43+
- Update all packages in the monorepo by running `npm run bump-all-updated-packages`. All the package bumps should be a patch.
44+
- Commit and push those changes in your `stable` branch.
45+
- Wait for the bumped packages to be published as part of the `publish_bumped_packages` CircleCI job.
46+
- Once published, run `npm run align-package-versions` to align these versions across packages inside the monorepo.
47+
4248
### 2. Push the branch and test the current changes
4349

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

87+
- Hermes artifacts should have been 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.
88+
8189
### 4. Create a PR of the changelog using the generator
8290

8391
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 +147,11 @@ Once all the steps above have been completed, it's time to signal to the communi
139147

140148
- [@reactnative](https://twitter.com/reactnative) on twitter
141149
- RN Discord `#releases-coordination`
150+
151+
### 10. Bump minor versions of all monorepo packages
152+
153+
The packages in the `react-native` monorepo should be always one minor version ahead of the current release number or the current RC minor version. Once you're done with releasing the initial RC0, you should:
154+
- Create a new branch in `react-native` from `main` in your own fork.
155+
- Run `npm run bump-all-updated-packages --release-branch-cutoff` to bump the minor versions of all packages.
156+
- Run `npm run align-package-version` to update align the package versions across the monorepo.
157+
- Create a PR targeting `main` in `react-native` with the two commits creates by the two previous commands.
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
---
2+
id: Updating packages
3+
title: Updating 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+
#### Use case
10+
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.
11+
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.
12+
13+
#### How to execute
14+
`npm run bump-all-updated-packages` or `npm run bump-all-updated-packages --release-branch-cutoff`
15+
16+
#### Pseudocode
17+
```
18+
check that no git changes are present
19+
20+
for each package:
21+
if package is private -> skip
22+
23+
if release-branch-cutoff argument is provided:
24+
bump package version to the next minor
25+
return
26+
27+
grep id of the last commit that changed package
28+
grep id of the last commit that changed version of the package
29+
30+
if these ids are different:
31+
bump package version (minor or patch)
32+
33+
commit changes if required
34+
```
35+
36+
### Notes
37+
At the final step you will be asked if you want to commit all these changes. Always select `Yes` 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).
38+
39+
## Publishing an updated package to npm
40+
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**.
41+
42+
#### Pseudocode
43+
```
44+
for each package:
45+
if last commit contains version change:
46+
if this commit has specific message:
47+
publish package to npm
48+
```
49+
50+
#### Notes
51+
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).
52+
53+
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:
54+
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.
55+
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).
56+
57+
Example script output, where no package versions were changed:
58+
<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">
59+
60+
## Align package versions across monorepo
61+
#### Use case
62+
You (or someone from release cycle team) have recently used a script to bump versions of updated packages and now these versions are available on npm. You want to align these versions across every package inside monorepo including `repo-config` and `template`.
63+
64+
#### How to execute
65+
`npm run align-package-versions`
66+
67+
#### Pseudocode
68+
```
69+
check that no git changes are present
70+
71+
for each package x:
72+
for each package y:
73+
if y has x as dependency:
74+
validate that y uses the latest version of x
75+
76+
if some changes were made:
77+
run yarn
78+
```
79+
80+
#### Notes
81+
Usually, if this script is executed on `main` branch, a pull request with the changes should be imported by an engineer from Meta to update yarn lockfiles. This is only if you merging these changes to `main` branch.
82+
83+
## Q&A
84+
#### Why there are two different scripts to update versions everywhere?
85+
For `*-stable` branches, there are no yarn workspaces and all packages are specified as direct dependencies, so for instance, if we update `@react-native/assets-registry` to the next version, we won't be able to run yarn for react-native root package, because updated version is not yet published to npm. This is caused by the nature of the repository and the code structure, which is currently getting reworked as per [this RFC](https://github.com/react-native-community/discussions-and-proposals/pull/480).
86+
87+
To avoid this, we first need publish new versions and then update them in consumer packages.

0 commit comments

Comments
 (0)