mirror of
https://github.com/facebook/react-native.git
synced 2024-11-21 22:10:14 +00:00
Switch to new release workflow as default (#43533)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/43533 Switch to the new unified release workflow by default, now that this has been validated on the `0.74-stable` branch. - Remove `--use-new-workflow` flag and remove legacy logic. - Remove legacy `prepare_package_for_release` CI job, and use `run_new_release_workflow` -> `run_release_workflow` as new workflow condition match. Changelog: [Internal] Reviewed By: cortinico Differential Revision: D55027120 fbshipit-source-id: 7c05cdff95ac369ce6cd1201ccfc5718798c4da6
This commit is contained in:
parent
7e6ca59e82
commit
bb4d13e80c
@ -12,19 +12,10 @@ parameters:
|
||||
default: false
|
||||
type: boolean
|
||||
|
||||
# Experimental unified release workflow
|
||||
run_new_release_workflow:
|
||||
default: false
|
||||
type: boolean
|
||||
|
||||
run_nightly_workflow:
|
||||
default: false
|
||||
type: boolean
|
||||
|
||||
release_latest:
|
||||
default: false
|
||||
type: boolean
|
||||
|
||||
release_version:
|
||||
default: ""
|
||||
type: string
|
||||
|
@ -1076,43 +1076,10 @@ jobs:
|
||||
# -------------------------
|
||||
# JOBS: Releases
|
||||
# -------------------------
|
||||
prepare_package_for_release:
|
||||
parameters:
|
||||
version:
|
||||
type: string
|
||||
latest:
|
||||
type: boolean
|
||||
default: false
|
||||
dryrun:
|
||||
type: boolean
|
||||
default: false
|
||||
executor: reactnativeios
|
||||
steps:
|
||||
- checkout_code_with_cache
|
||||
- run_yarn
|
||||
- add_ssh_keys:
|
||||
fingerprints:
|
||||
- "1f:c7:61:c4:e2:ff:77:e3:cc:ca:a7:34:c2:79:e3:3c"
|
||||
- brew_install:
|
||||
package: cmake
|
||||
- run:
|
||||
name: "Set new react-native version and commit changes"
|
||||
command: |
|
||||
VERSION=<< parameters.version >>
|
||||
|
||||
if [[ -z "$VERSION" ]]; then
|
||||
VERSION=$(grep '"version"' package.json | cut -d '"' -f 4 | head -1)
|
||||
echo "Using the version from the package.json: $VERSION"
|
||||
fi
|
||||
|
||||
node ./scripts/releases-ci/prepare-package-for-release.js -v "$VERSION" -l << parameters.latest >> --dry-run << parameters.dryrun >>
|
||||
|
||||
# Experimental unified release workflow
|
||||
# Replaces `prepare_package_for_release`
|
||||
#
|
||||
# Writes a new commit and tag(s), which will trigger the `publish_release`
|
||||
# and `publish_bumped_packages` workflows.
|
||||
prepare_release_new:
|
||||
prepare_release:
|
||||
parameters:
|
||||
version:
|
||||
type: string
|
||||
|
@ -4,11 +4,12 @@
|
||||
- equal: [ false, << pipeline.parameters.run_release_workflow >> ]
|
||||
- equal: [ false, << pipeline.parameters.run_nightly_workflow >> ]
|
||||
jobs:
|
||||
- prepare_package_for_release:
|
||||
name: prepare_package_for_release
|
||||
version: ''
|
||||
latest : false
|
||||
dryrun: true
|
||||
- prepare_release:
|
||||
name: "prepare_release (dry run test)"
|
||||
version: "0.0.0"
|
||||
monorepo_packages_version: "0.0.0"
|
||||
tag: latest
|
||||
dry_run: true
|
||||
- prepare_hermes_workspace
|
||||
- build_android:
|
||||
release_type: "dry-run"
|
||||
|
@ -4,11 +4,12 @@
|
||||
- equal: [ false, << pipeline.parameters.run_release_workflow >> ]
|
||||
- equal: [ false, << pipeline.parameters.run_nightly_workflow >> ]
|
||||
jobs:
|
||||
- prepare_package_for_release:
|
||||
name: prepare_package_for_release
|
||||
version: ''
|
||||
latest : false
|
||||
dryrun: true
|
||||
- prepare_release:
|
||||
name: "prepare_release (dry run test)"
|
||||
version: "0.0.0"
|
||||
monorepo_packages_version: "0.0.0"
|
||||
tag: latest
|
||||
dry_run: true
|
||||
- prepare_hermes_workspace
|
||||
- build_android:
|
||||
release_type: "dry-run"
|
||||
|
@ -4,11 +4,12 @@
|
||||
- equal: [ false, << pipeline.parameters.run_release_workflow >> ]
|
||||
- equal: [ false, << pipeline.parameters.run_nightly_workflow >> ]
|
||||
jobs:
|
||||
- prepare_package_for_release:
|
||||
name: prepare_package_for_release
|
||||
version: ''
|
||||
latest : false
|
||||
dryrun: true
|
||||
- prepare_release:
|
||||
name: "prepare_release (dry run test)"
|
||||
version: "0.0.0"
|
||||
monorepo_packages_version: "0.0.0"
|
||||
tag: latest
|
||||
dry_run: true
|
||||
- prepare_hermes_workspace
|
||||
- build_android:
|
||||
release_type: "dry-run"
|
||||
|
@ -129,18 +129,10 @@ parameters:
|
||||
default: false
|
||||
type: boolean
|
||||
|
||||
run_new_release_workflow:
|
||||
default: false
|
||||
type: boolean
|
||||
|
||||
run_nightly_workflow:
|
||||
default: false
|
||||
type: boolean
|
||||
|
||||
release_latest:
|
||||
default: false
|
||||
type: boolean
|
||||
|
||||
release_version:
|
||||
default: ""
|
||||
type: string
|
||||
|
@ -6,7 +6,6 @@
|
||||
# when:
|
||||
# and:
|
||||
# - equal: [ false, << pipeline.parameters.run_release_workflow >> ]
|
||||
# - equal: [ false, << pipeline.parameters.run_new_release_workflow >> ]
|
||||
# - equal: [ false, << pipeline.parameters.run_nightly_workflow >> ]
|
||||
#
|
||||
# It's setup this way so we can trigger a release via a POST
|
||||
@ -16,22 +15,12 @@
|
||||
workflows:
|
||||
version: 2
|
||||
|
||||
# This workflow should only be triggered by release script
|
||||
package_release:
|
||||
# Release workflow, triggered by `yarn trigger-react-native-release`
|
||||
create_release:
|
||||
when: << pipeline.parameters.run_release_workflow >>
|
||||
jobs:
|
||||
# This job will push a tag that will trigger the publish_release workflow
|
||||
- prepare_package_for_release:
|
||||
name: prepare_package_for_release
|
||||
version: << pipeline.parameters.release_version >>
|
||||
latest : << pipeline.parameters.release_latest >>
|
||||
|
||||
# Experimental unified release workflow
|
||||
create_release_new:
|
||||
when: << pipeline.parameters.run_new_release_workflow >>
|
||||
jobs:
|
||||
- prepare_release_new:
|
||||
name: prepare_release_new
|
||||
- prepare_release:
|
||||
name: prepare_release
|
||||
version: << pipeline.parameters.release_version >>
|
||||
monorepo_packages_version: << pipeline.parameters.release_monorepo_packages_version >>
|
||||
tag: << pipeline.parameters.release_tag >>
|
||||
@ -91,7 +80,6 @@ workflows:
|
||||
when:
|
||||
and:
|
||||
- equal: [ false, << pipeline.parameters.run_release_workflow >> ]
|
||||
- equal: [ false, << pipeline.parameters.run_new_release_workflow >> ]
|
||||
- equal: [ false, << pipeline.parameters.run_nightly_workflow >> ]
|
||||
jobs:
|
||||
# Run lints on every commit
|
||||
@ -141,7 +129,6 @@ workflows:
|
||||
when:
|
||||
and:
|
||||
- equal: [ false, << pipeline.parameters.run_release_workflow >> ]
|
||||
- equal: [ false, << pipeline.parameters.run_new_release_workflow >> ]
|
||||
- equal: [ false, << pipeline.parameters.run_nightly_workflow >> ]
|
||||
jobs:
|
||||
- find_and_publish_bumped_packages:
|
||||
|
@ -1,154 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @flow
|
||||
* @format
|
||||
* @oncall react_native
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const {RN_TESTER_DIR} = require('../consts');
|
||||
const {setReactNativeVersion} = require('../releases/set-rn-version');
|
||||
const {failIfTagExists} = require('../releases/utils/release-utils');
|
||||
const {
|
||||
isReleaseBranch,
|
||||
parseVersion,
|
||||
} = require('../releases/utils/version-utils');
|
||||
const {execSync} = require('child_process');
|
||||
const {echo, exec, exit} = require('shelljs');
|
||||
const yargs = require('yargs');
|
||||
|
||||
/**
|
||||
* This script prepares a release package to be pushed to npm
|
||||
* It is triggered to run on CircleCI
|
||||
* It will:
|
||||
* * It updates the version in json/gradle files and makes sure they are consistent between each other (set-rn-version)
|
||||
* * Updates podfile for RNTester
|
||||
* * Commits changes and tags with the next version based off of last version tag.
|
||||
* This in turn will trigger another CircleCI job to publish to npm
|
||||
*/
|
||||
async function main() {
|
||||
const argv = yargs
|
||||
.option('r', {
|
||||
alias: 'remote',
|
||||
default: 'origin',
|
||||
})
|
||||
.option('v', {
|
||||
alias: 'to-version',
|
||||
type: 'string',
|
||||
required: true,
|
||||
})
|
||||
.option('l', {
|
||||
alias: 'latest',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
})
|
||||
.option('d', {
|
||||
alias: 'dry-run',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
}).argv;
|
||||
|
||||
const branch = process.env.CIRCLE_BRANCH;
|
||||
// $FlowFixMe[prop-missing]
|
||||
const remote = argv.remote;
|
||||
// $FlowFixMe[prop-missing]
|
||||
const releaseVersion = argv.toVersion;
|
||||
// $FlowFixMe[prop-missing]
|
||||
const isLatest = argv.latest;
|
||||
// $FlowFixMe[prop-missing]
|
||||
const isDryRun = argv.dryRun;
|
||||
|
||||
if (branch == null) {
|
||||
throw new Error('process.env.CIRCLE_BRANCH is not set');
|
||||
}
|
||||
|
||||
const buildType = isDryRun
|
||||
? 'dry-run'
|
||||
: isReleaseBranch(branch)
|
||||
? 'release'
|
||||
: 'nightly';
|
||||
|
||||
failIfTagExists(releaseVersion, buildType);
|
||||
|
||||
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, buildType);
|
||||
if (version == null) {
|
||||
console.error(`Invalid version provided: ${releaseVersion}`);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
try {
|
||||
await setReactNativeVersion(version, null, buildType);
|
||||
} catch (e) {
|
||||
echo(`Failed to set React Native version to ${version}`);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Release builds should commit the version bumps, and create tags.
|
||||
try {
|
||||
console.log('Updating RNTester Podfile.lock');
|
||||
execSync(
|
||||
`
|
||||
bundle install;
|
||||
bundle exec pod install;
|
||||
`,
|
||||
{cwd: RN_TESTER_DIR, stdio: 'inherit'},
|
||||
);
|
||||
} catch (e) {
|
||||
console.error('Failed to update RNTester Podfile.lock.');
|
||||
console.error('Fix the issue, revert and try again.');
|
||||
|
||||
process.exitCode = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
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');
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Add tag v0.21.0-rc.1
|
||||
if (exec(`git tag -a v${version} -m "v${version}"`).code) {
|
||||
echo(
|
||||
`failed to tag the commit with v${version}, are you sure this release wasn't made earlier?`,
|
||||
);
|
||||
echo('You may want to rollback the last commit');
|
||||
echo('git reset --hard HEAD~1');
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// If `isLatest`, this git tag will also set npm release as `latest`
|
||||
if (isLatest) {
|
||||
exec('git tag -d latest');
|
||||
exec(`git push ${remote} :latest`);
|
||||
|
||||
// This will be pushed with the `--follow-tags`
|
||||
exec('git tag -a latest -m "latest"');
|
||||
}
|
||||
|
||||
exec(`git push ${remote} ${branch} --follow-tags`);
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
// eslint-disable-next-line no-void
|
||||
void main();
|
||||
}
|
@ -11,8 +11,6 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const {REPO_ROOT} = require('../consts');
|
||||
const detectPackageUnreleasedChanges = require('../monorepo/bump-all-updated-packages/bump-utils.js');
|
||||
const checkForGitChanges = require('../monorepo/check-for-git-changes');
|
||||
const {failIfTagExists} = require('../releases/utils/release-utils');
|
||||
const {
|
||||
@ -23,7 +21,6 @@ const {exitIfNotOnGit, getBranchName} = require('../scm-utils');
|
||||
const {getPackages} = require('../utils/monorepo');
|
||||
const chalk = require('chalk');
|
||||
const inquirer = require('inquirer');
|
||||
const path = require('path');
|
||||
const request = require('request');
|
||||
const {echo, exit} = require('shelljs');
|
||||
const yargs = require('yargs');
|
||||
@ -53,12 +50,6 @@ let argv = yargs
|
||||
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(),
|
||||
@ -77,55 +68,6 @@ function exitIfNotOnReleaseBranch(branch /*: string */) {
|
||||
}
|
||||
}
|
||||
|
||||
const buildExecutor =
|
||||
(
|
||||
packageAbsolutePath /*: string */,
|
||||
packageRelativePathFromRoot /*: string */,
|
||||
packageManifest /*: $FlowFixMe */,
|
||||
) =>
|
||||
async () => {
|
||||
const {name: packageName} = packageManifest;
|
||||
if (packageManifest.private) {
|
||||
return;
|
||||
}
|
||||
if (
|
||||
detectPackageUnreleasedChanges(
|
||||
packageRelativePathFromRoot,
|
||||
packageName,
|
||||
REPO_ROOT,
|
||||
)
|
||||
) {
|
||||
// if I enter here, I want to throw an error upward
|
||||
throw new Error(
|
||||
`Package ${packageName} has unreleased changes. Please release it first.`,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
async function exitIfUnreleasedPackages() {
|
||||
// use the other script to verify that there's no packages in the monorepo
|
||||
// that have changes that haven't been released
|
||||
|
||||
const packages = await getPackages({
|
||||
includeReactNative: false,
|
||||
includePrivate: true,
|
||||
});
|
||||
|
||||
for (const pkg of Object.values(packages)) {
|
||||
const executor = buildExecutor(
|
||||
pkg.path,
|
||||
path.relative(REPO_ROOT, pkg.path),
|
||||
pkg.packageJson,
|
||||
);
|
||||
|
||||
await executor().catch(error => {
|
||||
echo(chalk.red(error));
|
||||
// need to throw upward
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next version that all workspace packages will be set to.
|
||||
*
|
||||
@ -184,18 +126,6 @@ async function main() {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// $FlowFixMe[prop-missing]
|
||||
const useNewWorkflow /*: boolean */ = argv.useNewWorkflow;
|
||||
|
||||
// now check for unreleased packages
|
||||
if (!useNewWorkflow) {
|
||||
try {
|
||||
await exitIfUnreleasedPackages();
|
||||
} catch (error) {
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
// $FlowFixMe[prop-missing]
|
||||
const token = argv.token;
|
||||
// $FlowFixMe[prop-missing]
|
||||
@ -238,39 +168,29 @@ async function main() {
|
||||
return;
|
||||
}
|
||||
|
||||
let nextMonorepoPackagesVersion;
|
||||
let nextMonorepoPackagesVersion = await getNextMonorepoPackagesVersion();
|
||||
|
||||
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;
|
||||
}
|
||||
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
|
||||
? {
|
||||
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,
|
||||
}
|
||||
: {
|
||||
release_version: version,
|
||||
release_latest: latest,
|
||||
run_release_workflow: true,
|
||||
};
|
||||
const parameters = {
|
||||
run_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',
|
||||
|
Loading…
Reference in New Issue
Block a user