Skip to content

Commit

Permalink
Circle CI: Dry-run the release workflow on every commit (facebook#35015)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#35015

Changelog: [internal]

Differential Revision: D40483764

fbshipit-source-id: 24883ff7a96afccece99c351391936092c2ee7db
  • Loading branch information
hramos authored and facebook-github-bot committed Oct 18, 2022
1 parent b51a350 commit 4c69139
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 13 deletions.
60 changes: 48 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1361,6 +1361,9 @@ jobs:
latest:
type: boolean
default: false
dryrun:
type: boolean
default: false
executor: reactnativeios
steps:
- checkout_code_with_cache
Expand All @@ -1373,13 +1376,15 @@ jobs:
- run:
name: "Set new react-native version and commit changes"
command: |
node ./scripts/prepare-package-for-release.js -v << parameters.version >> -l << parameters.latest >>
node ./scripts/prepare-package-for-release.js -v << parameters.version >> -l << parameters.latest >> --dry-run << parameters.dryrun >>
build_npm_package:
parameters:
publish_npm_args:
type: string
default: --dry-run
release_type:
description: The type of release to build. Must be one of "nightly", "release", "dry-run".
type: enum
enum: ["nightly", "release", "dry-run"]
default: "dry-run"
executor: reactnativeandroid
environment:
- HERMES_WS_DIR: *hermes_workspace_root
Expand Down Expand Up @@ -1421,8 +1426,8 @@ jobs:
- when:
condition:
or:
- equal: [ --release, << parameters.publish_npm_args >> ]
- equal: [ --nightly, << parameters.publish_npm_args >> ]
- equal: [ "release", << parameters.release_type >> ]
- equal: [ "nightly", << parameters.release_type >> ]
steps:
- run: echo "//registry.npmjs.org/:_authToken=${CIRCLE_NPM_TOKEN}" > ~/.npmrc
- run: |
Expand All @@ -1431,7 +1436,7 @@ jobs:
echo "machine github.com login react-native-bot password $GITHUB_TOKEN" > ~/.netrc
# END: Stables and nightlies

- run: node ./scripts/publish-npm.js << parameters.publish_npm_args >>
- run: node ./scripts/publish-npm.js --<< parameters.release_type >>
- run:
name: Zip Hermes Native Symbols
command: zip -r /tmp/hermes-native-symbols.zip ~/react-native/ReactAndroid/hermes-engine/build/intermediates/cmake/
Expand All @@ -1442,7 +1447,7 @@ jobs:
# Provide a react-native package for this commit as a Circle CI release artifact.
- when:
condition:
equal: [ --dry-run, << parameters.publish_npm_args >> ]
equal: [ "dry-run", << parameters.release_type >> ]
steps:
- run:
name: Build release package as a job artifact
Expand Down Expand Up @@ -1474,7 +1479,7 @@ jobs:
# START: Stable releases
- when:
condition:
equal: [ --release, << parameters.publish_npm_args >> ]
equal: [ "release", << parameters.release_type >> ]
steps:
- run:
name: Update rn-diff-purge to generate upgrade-support diff
Expand Down Expand Up @@ -1550,7 +1555,7 @@ workflows:
- prepare_hermes_workspace
- build_npm_package:
# Build a release package on every untagged commit, but do not publish to npm.
publish_npm_args: --dry-run
release_type: "dry-run"
requires:
- build_hermesc_linux
- build_hermes_macos
Expand Down Expand Up @@ -1638,13 +1643,44 @@ workflows:
- build_npm_package:
name: build_and_publish_npm_package
context: react-native-bot
publish_npm_args: --release
release_type: "release"
filters: *only_release_tags
requires:
- build_hermesc_linux
- build_hermes_macos
- build_hermesc_windows

package_and_publish_release_dryrun:
jobs:
- prepare_package_for_release:
name: prepare_package_for_release
version: 'v1000.0.1'
latest : false
dryrun: true
- prepare_hermes_workspace:
requires:
- prepare_package_for_release
- build_hermesc_linux:
requires:
- prepare_hermes_workspace
- build_hermes_macos:
requires:
- prepare_hermes_workspace
matrix:
parameters:
flavor: ["Debug", "Release"]
- build_hermesc_windows:
requires:
- prepare_hermes_workspace
- build_npm_package:
name: build_and_publish_npm_package
context: react-native-bot
release_type: "dry-run"
requires:
- build_hermesc_linux
- build_hermes_macos
- build_hermesc_windows

analysis:
unless: << pipeline.parameters.run_package_release_workflow_only >>
jobs:
Expand Down Expand Up @@ -1683,7 +1719,7 @@ workflows:
requires:
- prepare_hermes_workspace
- build_npm_package:
publish_npm_args: --nightly
release_type: "nightly"
requires:
- build_hermesc_linux
- build_hermes_macos
Expand Down
17 changes: 16 additions & 1 deletion scripts/prepare-package-for-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,25 @@ const argv = yargs
alias: 'latest',
type: 'boolean',
default: false,
})
.option('d', {
alias: 'dry-run',
type: 'boolean',
default: false,
}).argv;

const branch = process.env.CIRCLE_BRANCH;
const remote = argv.remote;
const releaseVersion = argv.toVersion;
const isLatest = argv.latest;
const isDryRun = argv.dryRun;

if (!isReleaseBranch(branch)) {
if (branch && !isReleaseBranch(branch) && !isDryRun) {
console.error(`This needs to be on a release branch. On branch: ${branch}`);
exit(1);
} else if (!branch && !isDryRun) {
console.error('This needs to be on a release branch.');
exit(1);
}

const {version} = parseVersion(releaseVersion);
Expand All @@ -67,6 +76,12 @@ if (exec('source scripts/update_podfile_lock.sh && update_pods').code) {
exit(1);
}

echo(`Local checkout has been prepared for release version ${version}.`);
if (isDryRun) {
echo('Changes will not be committed because --dry-run was set to true.');
exit(0);
}

// Make commit [0.21.0-rc] Bump version numbers
if (exec(`git commit -a -m "[${version}] Bump version numbers"`).code) {
echo('failed to commit');
Expand Down

0 comments on commit 4c69139

Please sign in to comment.