forked from strapi/strapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease.js
96 lines (91 loc) · 2.73 KB
/
release.js
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
94
95
96
const { releaseChangelog, releasePublish, releaseVersion } = require('nx/release');
const yargs = require('yargs');
(async () => {
const options = await yargs
.version(false)
.option('version', {
description:
'Explicit version specifier to use, overriding conventional commits if provided.',
type: 'string',
})
.option('preid', {
description:
'Specify the prerelease identifier (e.g., beta, alpha, rc) to append to the version when creating a prerelease.',
type: 'string',
})
.option('dryRun', {
alias: 'd',
description: 'Run the release process in dry-run mode, defaults to true.',
type: 'boolean',
default: true,
})
.option('verbose', {
description: 'Enable verbose logging for debugging, defaults to false.',
type: 'boolean',
default: false,
})
.option('publish', {
description: 'Control whether the packages should be published, defaults to true.',
type: 'boolean',
default: true,
})
.option('changelog', {
description:
'Control whether a GitHub release and changelog should be generated, defaults to true.',
type: 'boolean',
default: true,
})
.options('onlyPublish', {
description: 'Publish packages without performing other release steps.',
type: 'boolean',
default: false,
})
.option('tag', {
description: 'Specify a custom tag for the release.',
type: 'string',
})
.option('opt', {
description: 'npm one time password',
type: 'string',
})
.option('gitCommit', {
description: 'Control whether to commit or not. (default to true)',
type: 'boolean',
default: true,
})
.option('gitTag', {
description: 'Control whether to add git tag or not. (default to true)',
type: 'boolean',
default: true,
})
.parseAsync();
if (!options.onlyPublish) {
const { workspaceVersion, projectsVersionData } = await releaseVersion({
specifier: options.version,
dryRun: options.dryRun,
verbose: options.verbose,
gitCommit: options.gitCommit,
preid: options.preid,
});
if (options.changelog) {
await releaseChangelog({
versionData: projectsVersionData,
version: workspaceVersion,
dryRun: options.dryRun,
verbose: options.verbose,
gitCommit: false,
gitTag: options.gitTag,
});
}
}
if (options.publish) {
const publishResults = await releasePublish({
dryRun: options.dryRun,
verbose: options.verbose,
tag: options.tag,
otp: options.otp,
});
process.exit(Object.values(publishResults).every((result) => result.code === 0) ? 0 : 1);
}
process.exit();
})();