Skip to content

Commit a034d08

Browse files
committed
ci(release): Use release flag to determine dryRun for release script
1 parent c1cd87c commit a034d08

File tree

2 files changed

+30
-27
lines changed

2 files changed

+30
-27
lines changed

tools/scripts/release/cli.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export function parseReleaseCliOptions() {
1919
alias: 'd',
2020
description: 'Whether or not to perform a dry-run of the release process, defaults to true',
2121
type: 'boolean',
22-
default: true,
22+
default: false,
2323
})
2424
.option('verbose', {
2525
description: 'Whether or not to enable verbose logging, defaults to false',
@@ -44,10 +44,11 @@ export function parseReleaseCliOptions() {
4444
.parseAsync();
4545
}
4646

47-
export function parseReleaseOptions({ channel }: { channel?: ReleaseChannel }): {
47+
export function parseReleaseOptions({ channel, dryRun }: Awaited<ReturnType<typeof parseReleaseCliOptions>>): {
4848
isPrerelease: boolean;
4949
preid?: string;
5050
tag: ReleaseChannel;
51+
dryRun?: boolean;
5152
} {
5253
let isPrerelease: boolean;
5354
let preid: ReleasePreidValue;
@@ -81,9 +82,19 @@ export function parseReleaseOptions({ channel }: { channel?: ReleaseChannel }):
8182
preid = releaseChannelPreid[selectedChannel];
8283
tag = selectedChannel;
8384

85+
const releaseEnabled = process.env.RELEASE_ENABLED === '1' || process.env.RELEASE_ENABLED === 'true';
86+
87+
console.info(
88+
printHeader('release', 'yellow'),
89+
`Live release enabled? ${releaseEnabled ? chalk.green('Yes') : chalk.red('No')} (RELEASE_ENABLED=${
90+
process.env.RELEASE_ENABLED
91+
})\n`
92+
);
93+
8494
return {
8595
isPrerelease,
8696
preid,
8797
tag,
98+
dryRun: dryRun || !releaseEnabled,
8899
};
89100
}

tools/scripts/release/release.ts

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,47 +11,39 @@ import { handlePrereleaseChangelog, handleRegularReleaseChangelog } from './chan
1111
(async () => {
1212
const options = await parseReleaseCliOptions();
1313
const graph = await createProjectGraphAsync({ exitOnError: true });
14-
const { tag, preid, isPrerelease } = parseReleaseOptions(options);
14+
const { publishOnly, projects, verbose, otp } = options;
15+
const { tag, preid, isPrerelease, dryRun } = parseReleaseOptions(options);
1516

16-
const releaseEnabled = process.env.RELEASE_ENABLED === '1' || process.env.RELEASE_ENABLED === 'true';
17-
18-
console.info(
19-
printHeader('release', 'yellow'),
20-
`Live release enabled? ${releaseEnabled ? chalk.green('Yes') : chalk.red('No')} (RELEASE_ENABLED=${
21-
process.env.RELEASE_ENABLED
22-
})\n`
23-
);
24-
25-
let projectsList: string[] = options.projects ?? [];
17+
let projectsList: string[] = projects ?? [];
2618

2719
// Create new version and update changelog if not only publishing
28-
if (options.publishOnly) {
20+
if (publishOnly) {
2921
console.log(printHeader('mode', 'cyanBright'), `Publish only, skipping version and changelog\n`);
3022
} else {
3123
if (isPrerelease) {
3224
const versionData = await handlePrereleaseVersioning({
3325
preid,
34-
projects: options.projects,
35-
dryRun: options.dryRun,
36-
verbose: options.verbose,
26+
projects,
27+
dryRun,
28+
verbose,
3729
});
3830
await handlePrereleaseChangelog({
3931
versionData,
40-
dryRun: options.dryRun,
41-
verbose: options.verbose,
32+
dryRun,
33+
verbose,
4234
});
4335
} else {
4436
const versionData = await handleRegularReleaseVersioning({
4537
preid,
46-
projects: options.projects,
47-
dryRun: options.dryRun,
48-
verbose: options.verbose,
38+
projects: projects,
39+
dryRun,
40+
verbose,
4941
});
5042

5143
await handleRegularReleaseChangelog({
5244
versionData,
53-
dryRun: options.dryRun,
54-
verbose: options.verbose,
45+
dryRun,
46+
verbose,
5547
});
5648
}
5749
}
@@ -61,12 +53,12 @@ import { handlePrereleaseChangelog, handleRegularReleaseChangelog } from './chan
6153

6254
// The returned number value from releasePublish will be zero if all projects are published successfully, non-zero if not
6355
const publishProjectsResult = await releasePublish({
64-
dryRun: options.dryRun,
65-
verbose: options.verbose,
56+
dryRun,
57+
verbose,
6658
projects: projectsList,
6759
tag,
6860
registry: 'https://registry.npmjs.org/',
69-
otp: options.otp,
61+
otp,
7062
});
7163

7264
const publishStatus = Object.values(publishProjectsResult).reduce((sum, { code }) => sum + code, 0);

0 commit comments

Comments
 (0)