From 411491e2c09242881ff686f68f33db4fdc967d2d Mon Sep 17 00:00:00 2001 From: Ruslan Lesiutin Date: Tue, 14 Feb 2023 04:18:13 -0800 Subject: [PATCH 1/3] fix: update executor for packages publishing workflow Summary: Changelog: [Internal] - While working on 0.71.3, it was discovered that `react-native-codegen` package is being published almost empty (without `lib` folder) - The reason for it is that `prepare` script is not being executed - The main reason for it is npm v6, which requires adding `unsafe-perm` flag for it: https://www.vinayraghu.com/blog/npm-unsafe-perm - Instead of using this flag, changing executor to `nodelts`, which has node v18 and npm v8 - Also adding `run_yarn` before running the script, because `react-native/codegen` uses external dependencies (such as rimraf) for its build scripts Differential Revision: D43248175 fbshipit-source-id: ea696aae5b75cb284db380d2040e678bb24a0eb4 --- .circleci/config.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d6a04aa3fdd613..b7c3d002e4d324 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1547,9 +1547,10 @@ jobs: echo "Nightly build run" find_and_publish_bumped_packages: - executor: reactnativeandroid + executor: nodelts steps: - checkout + - run_yarn - run: name: Set NPM auth token command: echo "//registry.npmjs.org/:_authToken=${CIRCLE_NPM_TOKEN}" > ~/.npmrc From ac635f96eee63a6610bd293c12ed379305b66048 Mon Sep 17 00:00:00 2001 From: Ruslan Lesiutin Date: Mon, 20 Feb 2023 16:46:58 +0000 Subject: [PATCH 2/3] refactor(bump-all-updated-packages): use tag instead of custom commit name --- ...nd-and-publish-all-bumped-packages-test.js | 4 ++-- .../bump-all-updated-packages/index.js | 19 +++++++++++++++++-- scripts/monorepo/constants.js | 4 ++-- .../find-and-publish-all-bumped-packages.js | 8 ++++---- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/scripts/monorepo/__tests__/find-and-publish-all-bumped-packages-test.js b/scripts/monorepo/__tests__/find-and-publish-all-bumped-packages-test.js index 0a50307646d6b7..7ef3f9ca0de7e4 100644 --- a/scripts/monorepo/__tests__/find-and-publish-all-bumped-packages-test.js +++ b/scripts/monorepo/__tests__/find-and-publish-all-bumped-packages-test.js @@ -9,7 +9,7 @@ const {spawnSync} = require('child_process'); -const {BUMP_COMMIT_MESSAGE} = require('../constants'); +const {PUBLISH_PACKAGES_TAG} = require('../constants'); const forEachPackage = require('../for-each-package'); const findAndPublishAllBumpedPackages = require('../find-and-publish-all-bumped-packages'); @@ -31,7 +31,7 @@ describe('findAndPublishAllBumpedPackages', () => { })); spawnSync.mockImplementationOnce(() => ({ - stdout: BUMP_COMMIT_MESSAGE, + stdout: `This is my commit message\n\n${PUBLISH_PACKAGES_TAG}`, })); expect(() => findAndPublishAllBumpedPackages()).toThrow( diff --git a/scripts/monorepo/bump-all-updated-packages/index.js b/scripts/monorepo/bump-all-updated-packages/index.js index 953851d7db1d5f..f3569660a99638 100644 --- a/scripts/monorepo/bump-all-updated-packages/index.js +++ b/scripts/monorepo/bump-all-updated-packages/index.js @@ -8,12 +8,13 @@ */ const chalk = require('chalk'); +const {execSync} = require('child_process'); const inquirer = require('inquirer'); const path = require('path'); const {echo, exec, exit} = require('shelljs'); const yargs = require('yargs'); -const {BUMP_COMMIT_MESSAGE} = require('../constants'); +const {PUBLISH_PACKAGES_TAG} = require('../constants'); const forEachPackage = require('../for-each-package'); const checkForGitChanges = require('../check-for-git-changes'); const bumpPackageVersion = require('./bump-package-version'); @@ -167,7 +168,21 @@ const main = async () => { return; } - exec(`git commit -a -m "${BUMP_COMMIT_MESSAGE}"`, {cwd: ROOT_LOCATION}); + // exec from shelljs currently does not support interactive input + // https://github.com/shelljs/shelljs/wiki/FAQ#running-interactive-programs-with-exec + execSync('git commit -a', {cwd: ROOT_LOCATION, stdio: 'inherit'}); + + const enteredCommitMessage = exec('git log -n 1 --format=format:%B', { + cwd: ROOT_LOCATION, + silent: true, + }).stdout.trim(); + const commitMessageWithTag = + enteredCommitMessage + `\n\n${PUBLISH_PACKAGES_TAG}`; + + exec(`git commit --amend -m "${commitMessageWithTag}"`, { + cwd: ROOT_LOCATION, + silent: true, + }); }) .then(() => echo()); } diff --git a/scripts/monorepo/constants.js b/scripts/monorepo/constants.js index fcbc5c51e3c16d..bc6188600cee5a 100644 --- a/scripts/monorepo/constants.js +++ b/scripts/monorepo/constants.js @@ -8,6 +8,6 @@ * @format */ -const BUMP_COMMIT_MESSAGE = '[ci][monorepo] bump package versions'; +const PUBLISH_PACKAGES_TAG = '@publish-packages-to-npm'; -module.exports = {BUMP_COMMIT_MESSAGE}; +module.exports = {PUBLISH_PACKAGES_TAG}; diff --git a/scripts/monorepo/find-and-publish-all-bumped-packages.js b/scripts/monorepo/find-and-publish-all-bumped-packages.js index f700f5c9c9889d..51d782d5c269a3 100644 --- a/scripts/monorepo/find-and-publish-all-bumped-packages.js +++ b/scripts/monorepo/find-and-publish-all-bumped-packages.js @@ -10,7 +10,7 @@ const path = require('path'); const {spawnSync} = require('child_process'); -const {BUMP_COMMIT_MESSAGE} = require('./constants'); +const {PUBLISH_PACKAGES_TAG} = require('./constants'); const forEachPackage = require('./for-each-package'); const ROOT_LOCATION = path.join(__dirname, '..', '..'); @@ -79,10 +79,10 @@ const findAndPublishAllBumpedPackages = () => { process.exit(1); } - const hasSpecificCommitMessage = - commitMessage.startsWith(BUMP_COMMIT_MESSAGE); + const hasSpecificPublishTag = + commitMessage.includes(PUBLISH_PACKAGES_TAG); - if (!hasSpecificCommitMessage) { + if (!hasSpecificPublishTag) { throw new Error( `Package ${packageManifest.name} was updated, but not through CI script`, ); From 9c4d0a8695789588cb352165a299509385338dff Mon Sep 17 00:00:00 2001 From: Ruslan Lesiutin Date: Thu, 2 Mar 2023 03:55:51 -0800 Subject: [PATCH 3/3] fix: update publishing packages tag message prefix (#36348) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/36348 Changelog: [Internal] Turns out that Phabricator strips `@` symbol from `@...` tags when exports commits to GitHub. Proposing to use `#` instead. #publish-packages-to-npm Reviewed By: cortinico Differential Revision: D43712415 fbshipit-source-id: 86fc728eb0cb63afb6a9fe592a9ae998da2ce2e4 --- scripts/monorepo/constants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/monorepo/constants.js b/scripts/monorepo/constants.js index bc6188600cee5a..82a455372bce49 100644 --- a/scripts/monorepo/constants.js +++ b/scripts/monorepo/constants.js @@ -8,6 +8,6 @@ * @format */ -const PUBLISH_PACKAGES_TAG = '@publish-packages-to-npm'; +const PUBLISH_PACKAGES_TAG = '#publish-packages-to-npm'; module.exports = {PUBLISH_PACKAGES_TAG};