mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
ece68f0efd
Summary: This change removes the need for the trigger-react-native-release.js script. Thanks to the migration to Github Actions, we can now leverage the GHA workflow UI to trigger a Prepare Release job that creates a github tag that will spin a new release. The pro of this approach are: - less code to maintain: instead of a complex trigger release scripts, we only have to maintain two very straightforward scripts for the CI - easier to trigger a release: instead of running a script, we can now just use the GH UI The `trigger-react-native-release` script was doing the following steps: - check that we are in the release branch ==> Already implemented in the GHA workflow - Gets the branch name (not needed) ==> the job will automatically run on the stable branch - Check for unsent changes (not needed) ==> we are not in a local environment - get the gh token (not needed) ==> You need to be logged in GH and have write access to the repo - get the version ==> provided as a parameter - fails if the tag is already there ==> Functionality added in the workflow - Parse and validate the version ==> Functionality added to the action prepare-release action + the JS Script - Compute the npmTag ==> Functionality added to the action prepare-release action + the JS Script - trigger the release workflow ==> The GH UI does that for us ## Changelog: [Internal] - Remove the trigger-react-native-release.js Pull Request resolved: https://github.com/facebook/react-native/pull/44898 Test Plan: Testing in Production! Reviewed By: cortinico, huntie Differential Revision: D58461470 Pulled By: cipolleschi fbshipit-source-id: 32bb0ee91370c9483a29e2ca2e18e24557d5fd53
73 lines
2.1 KiB
JavaScript
73 lines
2.1 KiB
JavaScript
/**
|
|
* 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
|
|
*/
|
|
|
|
const setVersion = require('../releases/set-version');
|
|
const {getBranchName} = require('../scm-utils');
|
|
const {parseVersion} = require('./utils/version-utils');
|
|
const {execSync} = require('child_process');
|
|
const yargs = require('yargs');
|
|
|
|
async function main() {
|
|
const argv = await yargs
|
|
.option('reactNativeVersion', {
|
|
describe: 'The new React Native version.',
|
|
type: 'string',
|
|
required: true,
|
|
})
|
|
.option('tagAsLatestRelease', {
|
|
describe:
|
|
'Whether the version should be published as the latest version on npm.',
|
|
type: 'boolean',
|
|
default: false,
|
|
})
|
|
.option('dryRun', {
|
|
description: 'Whether we should push the commit to github or not',
|
|
type: 'boolean',
|
|
default: true,
|
|
}).argv;
|
|
|
|
const buildType = 'release';
|
|
const version = argv.reactNativeVersion;
|
|
const latest = argv.tagAsLatestRelease;
|
|
const dryRun = argv.dryRun;
|
|
const branch = getBranchName();
|
|
console.info(`Running on branch: ${branch}`);
|
|
|
|
console.info('Validating version', version);
|
|
const {prerelease} = parseVersion(version, buildType);
|
|
|
|
const npmTag = latest ? 'latest' : prerelease ? 'next' : branch;
|
|
console.info('NPM tag:', npmTag);
|
|
|
|
console.info('Setting version for monorepo packages and react-native');
|
|
await setVersion(version, false); // version, skip-react-native
|
|
|
|
if (dryRun) {
|
|
console.info('Running in dry-run mode, skipping git commit');
|
|
console.info(
|
|
`git commit -a -m "Release ${version}" -m "#publish-packages-to-npm&${npmTag}"`,
|
|
);
|
|
console.info(`git tag -a v${version} -m "v${version}"`);
|
|
return;
|
|
}
|
|
|
|
console.info('Committing to git');
|
|
execSync(
|
|
`git commit -a -m "Release ${version}" -m "#publish-packages-to-npm&${npmTag}"`,
|
|
);
|
|
execSync(`git tag -a v${version} -m "v${version}"`);
|
|
}
|
|
|
|
if (require.main === module) {
|
|
// eslint-disable-next-line no-void
|
|
void main();
|
|
}
|