Skip to content

Commit

Permalink
[0.73-stable] Cherry-pick improvements to monorepo publish script (#4…
Browse files Browse the repository at this point in the history
…2991)

* Add Flow, add positive test case for monorepo publish step (#42936)

Summary:
Pull Request resolved: #42936

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D53607809

fbshipit-source-id: 990826fda5538af9a13e3f24978295a2f3b0c8c3

# Conflicts:
#	scripts/monorepo/__tests__/find-and-publish-all-bumped-packages-test.js
#	scripts/monorepo/find-and-publish-all-bumped-packages.js

* Update exit cases for monorepo publish script (#42937)

Summary:
Pull Request resolved: #42937

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D53607810

fbshipit-source-id: 18e79f23060ee70e96bd8ac6e9995b0a8ba300b3

# Conflicts:
#	scripts/monorepo/__tests__/find-and-publish-all-bumped-packages-test.js
#	scripts/monorepo/find-and-publish-all-bumped-packages.js

* Refactor package discovery in publish script (#42938)

Summary:
Pull Request resolved: #42938

Substitutes the `forEachPackage` util with a replacement async `getPackages` function. This will be used further in the next diff.

The new function aims to be more erganomic/versatile than `forEachPackage` by returning a package mapping (see updated test mock). The API aligns roughly with `yarn workspaces list` and [Lerna's `detectProjects`](https://lerna.js.org/docs/api-reference/utilities#detectprojects).

This also aligns with / replaces similar attempts in our existing scripts:
- [`getPackagesToPublish`](https://github.com/facebook/react-native/blob/2ca7bec0c2a7d821ceaaf39840a6cdc5eceb8678/scripts/monorepo/get-and-update-packages.js#L56)
- [`getPublicPackages`](https://github.com/facebook/react-native/blob/2ca7bec0c2a7d821ceaaf39840a6cdc5eceb8678/scripts/releases/set-version/index.js#L19)

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D53607806

fbshipit-source-id: 00ec34edadab863dc8f2f0c7852f6e835a5dddf5

# Conflicts:
#	scripts/monorepo.js
#	scripts/monorepo/find-and-publish-all-bumped-packages.js
#	scripts/monorepo/for-each-package.js

* Use npm as source of truth for updated packages (make publish script rerunnable) (#42944)

Summary:
Pull Request resolved: #42944

Updates `find-and-publish-all-bumped-packages` to use the npm registry as the source of truth, similar to tools like Lerna (`lerna publish from-package`). **This enables safe reruns of the publish script**, and replaces the previous Git-diff-detection implementation.

Changelog: [Internal]

Reviewed By: lunaleaps

Differential Revision: D53607807

fbshipit-source-id: 135808b7ce36cf463c9f53a8059500b83f8b6679

# Conflicts:
#	scripts/monorepo/find-and-publish-all-bumped-packages.js

* Add retry to monorepo publish script (#42964)

Summary:
Pull Request resolved: #42964

We've seen npm publishes fail occasionally in CI as part of this script, most recently in S391653. This change adds a single retry, per package, during the execution of this script, in an attempt to reduce the chance of manual interventions after a broken pipeline.

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D53607808

fbshipit-source-id: 526d9c33d51ec57702efba3c199bad313c1bf2d4

# Conflicts:
#	scripts/monorepo/find-and-publish-all-bumped-packages.js

* Rename and document monorepo publish script (#42989)

Summary: Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D53607805

fbshipit-source-id: babe9bbd7fb5e7016b567193727c6a441bee60a3

# Conflicts:
#	scripts/__tests__/publish-updated-packages-test.js
#	scripts/publish-updated-packages.js
#	scripts/releases-ci/README.md
  • Loading branch information
huntie authored Feb 19, 2024
1 parent 67e2bb4 commit 62c4664
Show file tree
Hide file tree
Showing 8 changed files with 523 additions and 166 deletions.
2 changes: 1 addition & 1 deletion .circleci/configurations/jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1321,4 +1321,4 @@ jobs:
command: echo "//registry.npmjs.org/:_authToken=${CIRCLE_NPM_TOKEN}" > ~/.npmrc
- run:
name: Find and publish all bumped packages
command: node ./scripts/monorepo/find-and-publish-all-bumped-packages.js
command: node ./scripts/releases-ci/publish-updated-packages.js

This file was deleted.

124 changes: 0 additions & 124 deletions scripts/monorepo/find-and-publish-all-bumped-packages.js

This file was deleted.

2 changes: 2 additions & 0 deletions scripts/monorepo/for-each-package.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ const getDirectories = source =>
*
* @param {forEachPackageCallback} callback The callback which will be called for each package
* @param {{includeReactNative: (boolean|undefined)}} [options={}] description
*
* @deprecated Use scripts/releases/utils/monorepo.js#getPackages instead
*/
const forEachPackage = (callback, options = DEFAULT_OPTIONS) => {
const {includeReactNative} = options;
Expand Down
11 changes: 11 additions & 0 deletions scripts/releases-ci/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# scripts/releases-ci

CI-only release scripts — intended to run from a CI workflow (CircleCI or GitHub Actions).

## Commands

For information on command arguments, run `node <command> --help`.

### `publish-updated-packages`

Publishes all updated packages (excluding `react-native`) to npm. Triggered when a commit on a release branch contains `#publish-packages-to-npm`.
Loading

0 comments on commit 62c4664

Please sign in to comment.