forked from novuhq/novu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease.mjs
93 lines (83 loc) · 2.25 KB
/
release.mjs
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/**
* Release all packages in the monorepo.
*
* Usage: pnpm release <version>
*
* Known issues:
* - nx release with independent versioning and updateDependents: "auto" increases patch by the amount of dependencies updated (https://github.com/nrwl/nx/issues/27823)
*/
import { hideBin } from 'yargs/helpers';
import { releaseChangelog, releasePublish, releaseVersion } from 'nx/release/index.js';
import inquirer from 'inquirer';
import yargs from 'yargs/yargs';
import { execa } from 'execa';
const groups = ['packages'];
(async () => {
const { dryRun, verbose, from, firstRelease, ...rest } = yargs(hideBin(process.argv))
.version(false)
.option('dryRun', {
alias: 'd',
description: 'Whether or not 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,
})
.option('from', {
description:
'The git reference to use as the start of the changelog. If not set it will attempt to resolve the latest tag and use that.',
type: 'string',
})
.option('first-release', {
description: 'Whether or not this is the first release, defaults to false',
type: 'boolean',
default: false,
})
.help()
.parse();
const specifier = rest._[0];
if (!specifier) {
console.error('Missing version! Usage: pnpm release <version>');
process.exit(1);
}
const { workspaceVersion, projectsVersionData } = await releaseVersion({
groups,
specifier,
dryRun,
verbose,
firstRelease,
});
await releaseChangelog({
groups,
specifier,
versionData: projectsVersionData,
version: workspaceVersion,
dryRun,
verbose,
from,
interactive: 'projects',
firstRelease,
});
await execa({
stdout: process.stdout,
stderr: process.stderr,
})`pnpm run build:packages --skip-nx-cache`;
const answers = await inquirer.prompt([
{
type: 'input',
name: 'otp',
message: 'Enter NPM OTP:',
},
]);
await releasePublish({
groups,
specifier: 'patch',
dryRun,
verbose,
otp: answers.otp,
firstRelease,
});
})();