-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
/
Copy pathrelease.mts
65 lines (60 loc) · 1.93 KB
/
release.mts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { execaSync } from 'execa';
import { releaseChangelog, releasePublish, releaseVersion } from 'nx/release';
import yargs from 'yargs';
const options = await yargs(process.argv.slice(2))
.version(false)
.option('version', {
description:
'Explicit version specifier to use, if overriding conventional commits',
type: 'string',
})
.option('dryRun', {
alias: 'd',
description:
'Whether to perform a dry-run of the release process, defaults to true',
type: 'boolean',
default: true,
})
.option('verbose', {
description: 'Whether or not to enable verbose logging, defaults to false',
type: 'boolean',
default: false,
})
.parseAsync();
const { workspaceVersion, projectsVersionData } = await releaseVersion({
specifier: options.version,
// stage package.json updates to be committed later by the changelog command
stageChanges: true,
dryRun: options.dryRun,
verbose: options.verbose,
});
// Update the lock file after the version bumps and stage it ready to be committed by the changelog step
if (!options.dryRun) {
console.log('⏳ Updating yarn.lock...');
execaSync(`yarn`, [`install`], {
env: { ...process.env, SKIP_POSTINSTALL: 'true' },
});
execaSync(`git`, [`add`, `yarn.lock`]);
console.log('✅ Updated and staged yarn.lock\n');
}
// This will create a release on GitHub
await releaseChangelog({
versionData: projectsVersionData,
version: workspaceVersion,
dryRun: options.dryRun,
verbose: options.verbose,
});
// An explicit null value here means that no changes were detected across any package
// eslint-disable-next-line eqeqeq
if (workspaceVersion === null) {
console.log(
'⏭️ No changes detected across any package, skipping publish step altogether',
);
} else {
const publishStatus = await releasePublish({
dryRun: options.dryRun,
verbose: options.verbose,
});
// eslint-disable-next-line no-process-exit
process.exit(publishStatus);
}