Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update build script to automatically generate RCs #29736

Merged
merged 1 commit into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ReactVersions.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ const ReactVersion = '19.0.0';
// npm dist tags used during publish, refer to .circleci/config.yml.
const canaryChannelLabel = 'rc';

// If the canaryChannelLabel is "rc", the build pipeline will use this to build
// an RC version of the packages.
const rcNumber = 0;

const stablePackages = {
'eslint-plugin-react-hooks': '5.1.0',
'jest-react': '0.16.0',
Expand All @@ -53,6 +57,7 @@ const experimentalPackages = [];
module.exports = {
ReactVersion,
canaryChannelLabel,
rcNumber,
stablePackages,
experimentalPackages,
};
2 changes: 2 additions & 0 deletions scripts/release/shared-commands/download-build-artifacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ const run = async ({build, cwd, releaseChannel}) => {
sourceDir = 'oss-stable';
} else if (releaseChannel === 'experimental') {
sourceDir = 'oss-experimental';
} else if (releaseChannel === 'rc') {
sourceDir = 'oss-stable-rc';
} else if (releaseChannel === 'latest') {
sourceDir = 'oss-stable-semver';
} else {
Expand Down
3 changes: 2 additions & 1 deletion scripts/release/shared-commands/parse-params.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,11 @@ module.exports = async () => {
if (
channel !== 'experimental' &&
channel !== 'stable' &&
channel !== 'rc' &&
channel !== 'latest'
) {
console.error(
theme.error`Invalid release channel (-r) "${channel}". Must be "stable", "experimental", or "latest".`
theme.error`Invalid release channel (-r) "${channel}". Must be "stable", "experimental", "rc", or "latest".`
);
process.exit(1);
}
Expand Down
28 changes: 28 additions & 0 deletions scripts/rollup/build-all-release-channels.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const {
stablePackages,
experimentalPackages,
canaryChannelLabel,
rcNumber,
} = require('../../ReactVersions');

// Runs the build script for both stable and experimental release channels,
Expand Down Expand Up @@ -118,6 +119,13 @@ function processStable(buildDir) {
// Identical to `oss-stable` but with real, semver versions. This is what
// will get published to @latest.
shell.cp('-r', buildDir + '/node_modules', buildDir + '/oss-stable-semver');
if (canaryChannelLabel === 'rc') {
// During the RC phase, we also generate an RC build that pins to exact
// versions but does not include a SHA, e.g. `19.0.0-rc.0`. This is purely
// for signaling purposes — aside from the version, it's no different from
// the corresponding canary.
shell.cp('-r', buildDir + '/node_modules', buildDir + '/oss-stable-rc');
}

const defaultVersionIfNotFound = '0.0.0' + '-' + sha + '-' + dateString;
const versionsMap = new Map();
Expand All @@ -141,6 +149,25 @@ function processStable(buildDir) {
ReactVersion + '-' + canaryChannelLabel + '-' + sha + '-' + dateString
);

if (canaryChannelLabel === 'rc') {
const rcVersionsMap = new Map();
for (const moduleName in stablePackages) {
const version = stablePackages[moduleName];
rcVersionsMap.set(moduleName, version + `-rc.${rcNumber}`);
}
updatePackageVersions(
buildDir + '/oss-stable-rc',
rcVersionsMap,
defaultVersionIfNotFound,
// For RCs, we pin to exact versions, like we do for canaries.
true
);
updatePlaceholderReactVersionInCompiledArtifacts(
buildDir + '/oss-stable-rc',
ReactVersion
);
}

// Now do the semver ones
const semverVersionsMap = new Map();
for (const moduleName in stablePackages) {
Expand All @@ -151,6 +178,7 @@ function processStable(buildDir) {
buildDir + '/oss-stable-semver',
semverVersionsMap,
defaultVersionIfNotFound,
// Use ^ only for non-prerelease versions
false
);
updatePlaceholderReactVersionInCompiledArtifacts(
Expand Down