Skip to content

Commit

Permalink
Circle CI: Build a release on pull-request commits
Browse files Browse the repository at this point in the history
Summary:
Package a npm tarball for react-native on pull-request commits, for ease of testing during development.

Ensure npm/github secrets are not exposed on pull-request builds (e.g. Circle CI will only grab the CIRCLE_NPM_TOKEN and GITHUB_TOKEN on jobs triggered by tagged commits or commits on main)

Renames Circle CI `publish_npm_package` job to `build_and_release_npm_package`, and uses `build_npm_package` for dry runs (e.g. commitlies).

Changelog: [internal]

Reviewed By: fkgozali

Differential Revision: D31243726

fbshipit-source-id: 2907febac3286a1504984c2f14e84dec1d819858
  • Loading branch information
hramos authored and facebook-github-bot committed Sep 28, 2021
1 parent 3db4046 commit 6b86c83
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -710,12 +710,11 @@ jobs:
# -------------------------
# JOBS: Releases
# -------------------------
# Publishes a new version onto npm
publish_npm_package:
build_npm_package:
parameters:
publish_npm_args:
type: string
default: --nonightly
default: --dry-run
executor: reactnativeandroid
steps:
- run:
Expand All @@ -728,11 +727,18 @@ jobs:
- install_buck_tooling
- download_buck_dependencies
- download_gradle_dependencies
- run: echo "//registry.npmjs.org/:_authToken=${CIRCLE_NPM_TOKEN}" > ~/.npmrc
- run: |
git config --global user.email "react-native-bot@users.noreply.github.com"
git config --global user.name "npm Deployment Script"
echo "machine github.com login react-native-bot password $GITHUB_TOKEN" > ~/.netrc
# Only tagged releases and nightlies should be able to publish to npm
- when:
condition:
or:
- equal: [ --release, << parameters.publish_npm_args >> ]
- equal: [ --nightly, << parameters.publish_npm_args >> ]
steps:
- run: echo "//registry.npmjs.org/:_authToken=${CIRCLE_NPM_TOKEN}" > ~/.npmrc
- run: |
git config --global user.email "react-native-bot@users.noreply.github.com"
git config --global user.name "npm Deployment Script"
echo "machine github.com login react-native-bot password $GITHUB_TOKEN" > ~/.netrc
- run: node ./scripts/publish-npm.js << parameters.publish_npm_args >>
- when:
condition:
Expand Down Expand Up @@ -832,7 +838,9 @@ workflows:

releases:
jobs:
- publish_npm_package:
- build_npm_package:
name: build_and_publish_npm_package
publish_npm_args: --release
filters:
# Both of the following conditions must be included!
# Ignore any commit on any branch by default.
Expand All @@ -841,14 +849,14 @@ workflows:
# Only act on version tags.
tags:
only: /v[0-9]+(\.[0-9]+)*(\-rc(\.[0-9]+)?)?/
- publish_npm_package:
- build_npm_package:
# Build a release package on every untagged commit, but do not publish to npm.
name: build_commit_package
publish_npm_args: --dry-run
filters:
branches:
only:
- main
- /^pull\/.*$/
tags:
ignore: /v[0-9]+(\.[0-9]+)*(\-rc(\.[0-9]+)?)?/

Expand Down Expand Up @@ -883,5 +891,5 @@ workflows:
jobs:
- nightly_job

- publish_npm_package:
- build_npm_package:
publish_npm_args: --nightly

0 comments on commit 6b86c83

Please sign in to comment.