From 5bc9d91b10a33ed4184693a69ecbdcaebe59011e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ramos?= Date: Sat, 25 Sep 2021 10:04:47 -0700 Subject: [PATCH] Circle CI: (FIX) Build release package outside of publish-npm.js Summary: The version of npm available in Circle CI is 6.x, which does not support the `--pack-destination` argument. As a result, `npm pack --pack-destination build` was interpreted as a request to package the 'build' directory for distribution. Since we need to make sure the output of `npm pack` is consumed by Circle CI's `store_artifacts` directive, we move the commitlies release packing logic to the Circle CI job config itself as to reduce coupling between `publish-npm.js` and the Circle CI config. Changelog: [Internal] Reviewed By: sota000 Differential Revision: D31183635 fbshipit-source-id: f0e0baae4ae31941dbb78dd1fec689f0f3398b52 --- .circleci/config.yml | 8 +++++++- scripts/publish-npm.js | 42 ++++++++++++++++++------------------------ 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5fe63799a72..eb0a6e853c1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -738,8 +738,14 @@ jobs: condition: equal: [ --dry-run, << parameters.publish_npm_args >> ] steps: + - run: + name: Build release package as a job artifact + command: | + mkdir -p build + FILENAME=$(npm pack) + mv $FILENAME build/ - store_artifacts: - path: ~/react-native/react-native-1000.0.0.tgz + path: ~/react-native/build/ destination: build # ------------------------- diff --git a/scripts/publish-npm.js b/scripts/publish-npm.js index 5f95f99465e..d9c4d211681 100644 --- a/scripts/publish-npm.js +++ b/scripts/publish-npm.js @@ -163,30 +163,24 @@ artifacts.forEach(name => { if (dryRunBuild) { echo('Skipping `npm publish` because --dry-run is set.'); - if (exec('mkdir -p build && npm pack --pack-destination build').code) { - echo('Failed to build release package.'); - exit(1); - } else { - echo('The release was built successfully.'); - exit(0); - } + exit(0); +} + +// if version contains -rc, tag as prerelease +const tagFlag = nightlyBuild + ? '--tag nightly' + : releaseVersion.indexOf('-rc') === -1 + ? '' + : '--tag next'; + +// use otp from envvars if available +const otpFlag = otp ? `--otp ${otp}` : ''; + +if (exec(`npm publish ${tagFlag} ${otpFlag}`).code) { + echo('Failed to publish package to npm'); + exit(1); } else { - // if version contains -rc, tag as prerelease - const tagFlag = nightlyBuild - ? '--tag nightly' - : releaseVersion.indexOf('-rc') === -1 - ? '' - : '--tag next'; - - // use otp from envvars if available - const otpFlag = otp ? `--otp ${otp}` : ''; - - if (exec(`npm publish ${tagFlag} ${otpFlag}`).code) { - echo('Failed to publish package to npm'); - exit(1); - } else { - echo(`Published to npm ${releaseVersion}`); - exit(0); - } + echo(`Published to npm ${releaseVersion}`); + exit(0); } /*eslint-enable no-undef */