From d08397a8625a545b780ff7b1aa39df9d2e9147fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ramos?= Date: Wed, 29 Sep 2021 00:09:53 -0700 Subject: [PATCH] bump-oss-version: Add -v / --to-version argument and use it when bumping nightly releases (now at 20:00 UTC) Summary: Add a new -v or --to-version argument to the bump-oss-version script. When the bump-oss-version script runs, it will use the version string that is passed in, instead of trying to infer it from the current commit. This fixes a bug in the last nightly release where the bump script used a different version string than what the publish script expected. Nightlies now run at 20:00 hours UTC. Changelog: [Internal] Reviewed By: fkgozali, TheSavior Differential Revision: D31261829 fbshipit-source-id: a9341f93c3c7bf0379aa3c5e7f345182df70f846 --- .circleci/config.yml | 2 +- Releases.md | 14 +++++++------- scripts/bump-oss-version.js | 28 +++++++++++++++++----------- scripts/publish-npm.js | 10 ++++++---- 4 files changed, 31 insertions(+), 23 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d876cd99b02..72c5abec171 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -896,7 +896,7 @@ workflows: nightly: triggers: - schedule: - cron: "0 0 * * *" + cron: "0 20 * * *" filters: branches: only: diff --git a/Releases.md b/Releases.md index 16d88ba146b..b76de5877ae 100644 --- a/Releases.md +++ b/Releases.md @@ -56,9 +56,9 @@ Run: git checkout -b -stable # e.g. git checkout -b 0.57-stable -./scripts/bump-oss-version.js -# e.g. ./scripts/bump-oss-version.js 0.57.0-rc.0 -# or ./scripts/bump-oss-version.js 0.58.0 +./scripts/bump-oss-version.js -v +# e.g. ./scripts/bump-oss-version.js -v 0.57.0-rc.0 +# or ./scripts/bump-oss-version.js -v 0.58.0 ``` Circle CI will automatically run the tests and publish to npm with the version you have specified (e.g `0.57.0-rc.0`) and tag `next` meaning that this version will not be installed for users by default. @@ -147,8 +147,8 @@ Go through the same process as earlier to test the release: If everything worked, run the following to bump the version number: ```bash -./scripts/bump-oss-version.js -# e.g. ./scripts/bump-oss-version.js 0.57.0-rc.1 +./scripts/bump-oss-version.js -v +# e.g. ./scripts/bump-oss-version.js -v 0.57.0-rc.1 ``` Again, Circle CI will automatically run the tests and publish to npm with the version you have specified (e.g `0.57.0-rc.1`). @@ -191,8 +191,8 @@ It's **important** to test everything again: you don't want to cut a release wit If everything worked: ```bash -./scripts/bump-oss-version.js -# e.g. ./scripts/bump-oss-version.js 0.57.0 +./scripts/bump-oss-version.js -v +# e.g. ./scripts/bump-oss-version.js -v 0.57.0 ``` As with the release candidate, Circle CI will automatically run the tests and publish to npm with the version you have specified (e.g `0.57.0`). diff --git a/scripts/bump-oss-version.js b/scripts/bump-oss-version.js index 055daf4777b..465f4b241f6 100755 --- a/scripts/bump-oss-version.js +++ b/scripts/bump-oss-version.js @@ -29,17 +29,24 @@ let argv = yargs alias: 'nightly', type: 'boolean', default: false, + }) + .option('v', { + alias: 'to-version', + type: 'string', }).argv; const nightlyBuild = argv.nightly; +const version = argv.toVersion; -let version, branch; -if (nightlyBuild) { - const currentCommit = exec('git rev-parse HEAD', { - silent: true, - }).stdout.trim(); - version = `0.0.0-${currentCommit.slice(0, 9)}`; -} else { +if (!version) { + echo( + 'You must specify a version using -v', + ); + exit(1); +} + +let branch; +if (!nightlyBuild) { // Check we are in release branch, e.g. 0.33-stable branch = exec('git symbolic-ref --short HEAD', { silent: true, @@ -55,10 +62,9 @@ if (nightlyBuild) { // - check that argument version matches branch // e.g. 0.33.1 or 0.33.0-rc4 - version = argv._[0]; - if (!version || version.indexOf(versionMajor) !== 0) { + if (version.indexOf(versionMajor) !== 0) { echo( - `You must pass a tag like 0.${versionMajor}.[X]-rc[Y] to bump a version`, + `You must specify a version tag like 0.${versionMajor}.[X]-rc[Y] to bump a version`, ); exit(1); } @@ -175,7 +181,7 @@ if (!nightlyBuild) { exit(1); } - // Update Podfile.lock only on release builds, not nightly. + // Update Podfile.lock only on release builds, not nightlies. // Nightly builds don't need it as the main branch will already be up-to-date. echo('Updating RNTester Podfile.lock...'); if (exec('source scripts/update_podfile_lock.sh && update_pods').code) { diff --git a/scripts/publish-npm.js b/scripts/publish-npm.js index 954eaaf7c77..143676fc166 100644 --- a/scripts/publish-npm.js +++ b/scripts/publish-npm.js @@ -18,21 +18,21 @@ * * To cut a branch (and release RC): * - Developer: `git checkout -b 0.XY-stable` - * - Developer: `./scripts/bump-oss-version.js v0.XY.0-rc.0` + * - Developer: `./scripts/bump-oss-version.js -v v0.XY.0-rc.0` * - CI: test and deploy to npm (run this script) with version `0.XY.0-rc.0` * with tag "next" * * To update RC release: * - Developer: `git checkout 0.XY-stable` * - Developer: cherry-pick whatever changes needed - * - Developer: `./scripts/bump-oss-version.js v0.XY.0-rc.1` + * - Developer: `./scripts/bump-oss-version.js -v v0.XY.0-rc.1` * - CI: test and deploy to npm (run this script) with version `0.XY.0-rc.1` * with tag "next" * * To publish a release: * - Developer: `git checkout 0.XY-stable` * - Developer: cherry-pick whatever changes needed - * - Developer: `./scripts/bump-oss-version.js v0.XY.0` + * - Developer: `./scripts/bump-oss-version.js -v v0.XY.0` * - CI: test and deploy to npm (run this script) with version `0.XY.0` * and no tag ("latest" is implied by npm) * @@ -111,7 +111,9 @@ if (nightlyBuild) { // Bump version number in various files (package.json, gradle.properties etc) if ( - exec(`node scripts/bump-oss-version.js --nightly ${releaseVersion}`).code + exec( + `node scripts/bump-oss-version.js --nightly --to-version ${releaseVersion}`, + ).code ) { echo('Failed to bump version number'); exit(1);