react/scripts/release/shared-commands/parse-params.js
Andrew Clark bf3a29d097
Update build script to automatically generate RCs (#29736)
RC releases are a special kind of prerelease build because unlike
canaries we shouldn't publish new RCs from any commit on `main`, only
when we intentionally bump the RC number. But they are still prerelases
— like canary and experimental releases, they should use exact version
numbers in their dependencies (no ^).

We only need to generate these builds during the RC phase, i.e. when the
canary channel label is set to "rc".

Example of resulting package.json output:

```json
{
  "name": "react-dom",
  "version": "19.0.0-rc.0",
  "dependencies": {
    "scheduler": "0.25.0-rc.0"
  },
  "peerDependencies": {
    "react": "19.0.0-rc.0"
  }
}
```


https://react-builds.vercel.app/prs/29736/files/oss-stable-rc/react-dom/package.json
2024-06-03 12:21:21 -04:00

83 lines
1.9 KiB
JavaScript

#!/usr/bin/env node
'use strict';
const commandLineArgs = require('command-line-args');
const getBuildIdForCommit = require('./get-build-id-for-commit');
const theme = require('../theme');
const {logPromise} = require('../utils');
const paramDefinitions = [
{
name: 'build',
type: String,
description:
'CI build ID corresponding to the "process_artifacts_combined" task.',
defaultValue: null,
},
{
name: 'commit',
type: String,
description:
'GitHub commit SHA. When provided, automatically finds corresponding CI build.',
defaultValue: null,
},
{
name: 'skipTests',
type: Boolean,
description: 'Skip automated fixture tests.',
defaultValue: false,
},
{
name: 'releaseChannel',
alias: 'r',
type: String,
description: 'Release channel (stable, experimental, or latest)',
},
{
name: 'allowBrokenCI',
type: Boolean,
description:
'Continue even if CI is failing. Useful if you need to debug a broken build.',
defaultValue: false,
},
];
module.exports = async () => {
const params = commandLineArgs(paramDefinitions);
const channel = params.releaseChannel;
if (
channel !== 'experimental' &&
channel !== 'stable' &&
channel !== 'rc' &&
channel !== 'latest'
) {
console.error(
theme.error`Invalid release channel (-r) "${channel}". Must be "stable", "experimental", "rc", or "latest".`
);
process.exit(1);
}
if (params.build === null && params.commit === null) {
console.error(
theme.error`Either a --commit or --build param must be specified.`
);
process.exit(1);
}
try {
if (params.build === null) {
params.build = await logPromise(
getBuildIdForCommit(params.commit, params.allowBrokenCI),
theme`Getting build ID for commit "${params.commit}"`
);
}
} catch (error) {
console.error(theme.error(error));
process.exit(1);
}
return params;
};