Skip to content

Commit 5897bef

Browse files
authored
Add step for updating packages in the release guide (#3645)
1 parent ddde01f commit 5897bef

3 files changed

Lines changed: 123 additions & 11 deletions

File tree

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

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,26 @@ Documents in this section go over steps to run different types of React Native r
2828
git checkout -b 0.69-stable
2929
```
3030

31+
### 2. Update the Hermes version
32+
3133
- Head to the [Publish Tag](https://github.com/facebook/hermes/actions/workflows/create-tag.yml) workflow in the Hermes repo. Click the "Run Workflow" button and input the RN stable version you are targeting (e.g. 0.69.0). You need to have write access to the facebook/hermes repo to do so or ask a Meta employee to help you on this step.
3234

3335
- Bump the Hermes version on the release branch using this command:
3436

3537
```bash
3638
# Replace <the_hermes_tag> with the tag that will look like 'hermes-2022-07-20-RNv0.70.0-bc97c5399e0789c0a323f8e1431986e207a9e8ba'
37-
./scripts/hermes/bump-hermes-version.js -t <the_hermes_tag>
39+
./packages/react-native/scripts/hermes/bump-hermes-version.js -t <the_hermes_tag>
3840
```
3941

40-
- Add and commit the extra file that got created at `sdks/hermes/.hermesversion`.
42+
- Add and commit the extra file that got created at `packages/react-native/sdks/hermes/.hermesversion`.
43+
44+
### 3. Bump monorepo packages
45+
46+
- 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).
47+
48+
- CI will take care of releasing the new versions on npm once you push the changes to the `0.XX-stable` branch.
4149

42-
### 2. Push the branch and test the current changes
50+
### 4. Push the branch and test the current changes
4351

4452
You can now push the branch you created so that others can also start testing:
4553

@@ -51,7 +59,7 @@ Before continuing further, follow the [testing guide](/contributing/release-test
5159

5260
<AsyncTestingNote/>
5361

54-
### 3. Kick off the build of 0.{minor}.0-rc.0
62+
### 5. Kick off the build of 0.{minor}.0-rc.0
5563

5664
Once you're done with the testing, you can kick-off the bump and publishing of RC0:
5765

@@ -78,7 +86,9 @@ Once you're done with the testing, you can kick-off the bump and publishing of R
7886
latest: 0.68.1 next: 0.69.0-rc.0 nightly: 0.0.0-f617e022c
7987
```
8088

81-
### 4. Create a PR of the changelog using the generator
89+
- 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.
90+
91+
### 6. Create a PR of the changelog using the generator
8292

8393
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.
8494

@@ -109,33 +119,41 @@ For both these categories, we have to manually go through the listed commits and
109119
- Commit which bumps dependencies should be **moved to the `Changed`** section
110120
- For each dependency, there should be a single entry with the most recent bump. Commits that bumps the dependencies to lower versions can be **removed**
111121

112-
### 5. Create a GitHub Release
122+
### 7. Create a GitHub Release
113123

114124
- Create a [GitHub Release](https://github.com/facebook/react-native/releases) with this template and **check "Pre-Release" checkbox**.
115125

116126
<GHReleasesNotesPrerelease />
117127

118-
### 6. Upload prebuilt Hermes binary
128+
### 8. Upload prebuilt Hermes binary
119129

120130
In the `publish_release` CI workflow, the `build_hermes_macos` step produces a `tmp/hermes/output/hermes-runtime-darwin-vx.y.z.tar.gz` artifact, for example [here](https://app.circleci.com/pipelines/github/facebook/react-native/13933/workflows/5f2ad198-2264-4e7e-8c62-7b28e97532d8/jobs/262322/artifacts) are the artifacts for `0.69.0` release. Download it and attach it to the GitHub release.
121131

122-
### 7. Create a tracking discussion post
132+
### 9. Create a tracking discussion post
123133

124134
Create a "Road to <YOUR_MINOR_VERSION>" discussion post in the [`react-native-releases`](https://github.com/reactwg/react-native-releases/discussions) working group:
125135

126136
<RoadToReleaseTemplate />
127137

128138
After creating it, make sure to link it in the relevant GitHub Release you created above, and to pin it in the discussion repo.
129139

130-
### 8. Verify that Upgrade Helper GitHub action has fired
140+
### 10. Verify that Upgrade Helper GitHub action has fired
131141

132142
- You should see a [new publish job here](https://github.com/react-native-community/rn-diff-purge/actions).
133143
- Once it has finished, you should be able to see that the [Upgrade Helper](https://react-native-community.github.io/upgrade-helper/) presents the option to target the new RC0.
134144
- If not, check out the guide on [how to update Upgrade Helper](/contributing/updating-upgrade-helper).
135145

136-
### 9. Broadcast that release candidate is out
146+
### 11. Broadcast that release candidate is out
137147

138148
Once all the steps above have been completed, it's time to signal to the community that RC0 is available for testing! Do so in the following channels:
139149

140150
- [@reactnative](https://twitter.com/reactnative) on twitter
141151
- RN Discord `#releases-coordination`
152+
153+
### 12. Bump minor version of all monorepo packages in `main`
154+
155+
The packages in the `react-native` monorepo must always be one minor version ahead of the latest or RC version (e.g. if you have cut `0.72-stable`, main needs to be in `0.73.x`. Once you're done with releasing the initial RC0, you should:
156+
157+
- Create a new branch in `react-native` from `main` in your own fork.
158+
- Run `yarn bump-all-updated-packages --release-branch-cutoff` to bump the minor versions of all packages.
159+
- 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)