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 */