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 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..82a455372bce49 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`, );