forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add prepare_release_new workflow, enable via flag (facebook#43518)
Summary: This is a minimum approach to achieve a **single-command publish flow** for React Native, unifying the previous `yarn bump-all-updated-packages` and `yarn trigger-react-native-release` workflow entry points. This diff aims to change as little as possible to achieve the above — introducing a new job that merges operations to create the versioning commit. The triggered publish jobs are unchanged. In future, we may follow this change with further simplifications down the workflow tree. **Key changes** - Adds a new CircleCI workflow, `prepare_release_new`, which versions **all packages** and writes a single release commit. - This replaces `yarn bump-all-updated-packages`, now implemented with the newer `set-version` script. - Wires this up as an experiment within `trigger-react-native-release.js`, conditionally running the new workflow when `--use-new-workflow` is passed. **Not changed** - The single release commit written will continue to trigger both of the existing CI workflows on push (`publish_release` and `publish_bumped_packages`), which are unchanged. - The commit summary now includes the `#publish-packages-to-npm` marker, in order to trigger `publish_bumped_packages`. - Usage: Release Crew members will continue to use the existing local script entry point (as [documented in the releases repo](https://github.com/reactwg/react-native-releases/blob/main/docs/guide-release-process.md#step-7-publish-react-native)), with the opt in flag. ``` yarn trigger-react-native-release --use-new-workflow [...args] ``` After we're happy with the E2E behaviour of this workflow in the next 0.74 RC, I will follow up by dropping the `--use-new-workflow` flag and removing the old scripts (T182533699). Changelog: [Internal] Reviewed By: cortinico Differential Revision: D54956345
- Loading branch information
1 parent
0277871
commit d6a20ee
Showing
5 changed files
with
197 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,16 @@ let argv = yargs | |
describe: 'Version you aim to release, ex. 0.67.0-rc.1, 0.66.3', | ||
required: true, | ||
}) | ||
.option('dry-run', { | ||
type: 'boolean', | ||
default: false, | ||
}) | ||
// TODO(T182533699): Remove arg once new workflow is default | ||
.option('use-new-workflow', { | ||
describe: 'When set, triggers the experimental unified release workflow.', | ||
type: 'boolean', | ||
default: false, | ||
}) | ||
.check(() => { | ||
const branch = exitIfNotOnGit( | ||
() => getBranchName(), | ||
|
@@ -78,7 +88,6 @@ const buildExecutor = | |
if (packageManifest.private) { | ||
return; | ||
} | ||
|
||
if ( | ||
detectPackageUnreleasedChanges( | ||
packageRelativePathFromRoot, | ||
|
@@ -117,6 +126,36 @@ async function exitIfUnreleasedPackages() { | |
} | ||
} | ||
|
||
/** | ||
* Get the next version that all workspace packages will be set to. | ||
* | ||
* This approach is specific to the 0.74 release. For 0.75, the `--to-version` | ||
* value will be used instead, setting all packages to a single version. | ||
*/ | ||
async function getNextMonorepoPackagesVersion() /*: Promise<string | null> */ { | ||
// Based on @react-native/[email protected] | ||
const _0_74_MIN_PATCH = 6; | ||
|
||
const packages = await getPackages({ | ||
includeReactNative: false, | ||
}); | ||
|
||
let patchVersion = _0_74_MIN_PATCH; | ||
|
||
for (const pkg of Object.values(packages)) { | ||
const {version} = pkg.packageJson; | ||
|
||
if (!version.startsWith('0.74.') || version.endsWith('-main')) { | ||
return null; | ||
} | ||
|
||
const {minor} = parseVersion(version, 'release'); | ||
patchVersion = Math.max(patchVersion, parseInt(minor, 10) + 1); | ||
} | ||
|
||
return '0.74.' + patchVersion; | ||
} | ||
|
||
function triggerReleaseWorkflow(options /*: $FlowFixMe */) { | ||
return new Promise((resolve, reject) => { | ||
request(options, function (error, response, body) { | ||
|
@@ -145,11 +184,16 @@ async function main() { | |
exit(1); | ||
} | ||
|
||
// $FlowFixMe[prop-missing] | ||
const useNewWorkflow: boolean = argv.useNewWorkflow; | ||
|
||
// now check for unreleased packages | ||
try { | ||
await exitIfUnreleasedPackages(); | ||
} catch (error) { | ||
exit(1); | ||
if (!useNewWorkflow) { | ||
try { | ||
await exitIfUnreleasedPackages(); | ||
} catch (error) { | ||
exit(1); | ||
} | ||
} | ||
|
||
// $FlowFixMe[prop-missing] | ||
|
@@ -194,11 +238,39 @@ async function main() { | |
return; | ||
} | ||
|
||
const parameters = { | ||
release_version: version, | ||
release_latest: latest, | ||
run_release_workflow: true, | ||
}; | ||
let nextMonorepoPackagesVersion; | ||
|
||
if (useNewWorkflow) { | ||
nextMonorepoPackagesVersion = await getNextMonorepoPackagesVersion(); | ||
|
||
if (nextMonorepoPackagesVersion == null) { | ||
// TODO(T182538198): Once this warning is hit, we can remove the | ||
// `release_monorepo_packages_version` logic from here and the CI jobs, | ||
// see other TODOs. | ||
console.warn( | ||
'Warning: No longer on the 0.74-stable branch, meaning we will ' + | ||
'write all package versions identically. Please double-check the ' + | ||
'generated diff to see if this is correct.', | ||
); | ||
nextMonorepoPackagesVersion = version; | ||
} | ||
} | ||
|
||
const parameters = useNewWorkflow | ||
? { | ||
release_version: version, | ||
release_latest: latest, | ||
run_release_workflow: true, | ||
} | ||
: { | ||
run_new_release_workflow: true, | ||
release_version: version, | ||
release_tag: npmTag, | ||
// NOTE: Necessary for 0.74, should be dropped for 0.75+ | ||
release_monorepo_packages_version: nextMonorepoPackagesVersion, | ||
// $FlowFixMe[prop-missing] | ||
release_dry_run: argv.dryRun, | ||
}; | ||
|
||
const options = { | ||
method: 'POST', | ||
|