Skip to content

Commit e1935cb

Browse files
committed
feat: 增加 --only-publish 参数用于仅发布当前版本
1 parent f0ff7aa commit e1935cb

File tree

4 files changed

+34
-2
lines changed

4 files changed

+34
-2
lines changed

index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ export interface ReleaseCLIOptions {
2525
releaseDraft?: boolean;
2626
dryRun?: boolean;
2727
strict?: boolean;
28+
onlyPublish?: boolean;
2829
verbose?: boolean;
2930
}

src/cli.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ Options
4848
--otp This is a one-time password from a two-factor authenticator
4949
--no-release-draft Skips opening a GitHub release draft
5050
--dry-run Don't actually release, just simulate the process
51+
--only-publish Only publish the current package
5152
--verbose Display verbose output
5253
-h, --help Display this message
5354
-v, --version Display version number
@@ -133,6 +134,9 @@ Options
133134
strict: {
134135
type: 'boolean',
135136
},
137+
onlyPublish: {
138+
type: 'boolean',
139+
},
136140
verbose: {
137141
type: 'boolean',
138142
// default: isDev,
@@ -176,11 +180,18 @@ else {
176180
publish: true,
177181
build: false,
178182
tagMerge: true,
183+
onlyPublish: false,
179184
verbose: isDev,
180185
} as ReleaseCLIOptions,
181186
config,
182187
cliOpts,
183188
) as ReleaseCLIOptions;
189+
190+
if (releaseOpts.onlyPublish) {
191+
releaseOpts.strict ??= false;
192+
releaseOpts.anyBranch ??= true;
193+
}
194+
184195
logger.enableDebug(!!releaseOpts.verbose);
185196
logger.debug('merged options:', releaseOpts);
186197

@@ -189,8 +200,12 @@ else {
189200
try {
190201
const opts = await getReleaseOptions(releaseOpts);
191202
logger.debug(opts);
192-
await runGenerateChangelog(opts);
193-
logger.debug(opts);
203+
204+
if (!opts?.onlyPublish) {
205+
await runGenerateChangelog(opts);
206+
logger.debug(opts);
207+
}
208+
194209
await runPublish(opts);
195210
}
196211
catch (e: any) {

src/options.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@ export async function getReleaseOptions(options: ReleaseCLIOptions) {
6464
await selectTypeVersion(opts);
6565
await selectVersion(opts);
6666

67+
// new version
68+
if (opts.onlyPublish) {
69+
opts.pkgs.forEach((pkg) => {
70+
pkg.newVersion = pkg.version;
71+
});
72+
}
73+
6774
return opts;
6875
}
6976

src/publish.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ import { getNpmEnv, getOtpCode, getTwoFactorState, updatePackageVersion } from '
1616
import { run } from './utils';
1717

1818
export async function runPublish(opts: ReleaseOptions) {
19+
if (opts.onlyPublish) {
20+
await runPublishPackages(opts);
21+
return;
22+
}
23+
1924
await bumpVersionAndTag(opts);
2025
await runPublishPackages(opts);
2126
await runGithubRelease(opts);
@@ -64,6 +69,10 @@ async function runPublishPackages(opts: ReleaseOptions) {
6469
}
6570
}
6671

72+
if (opts.onlyPublish) {
73+
return;
74+
}
75+
6776
const gitUrl = await getRepositoryUrl();
6877
if (gitUrl) {
6978
await run(`git push`, { dryRun });

0 commit comments

Comments
 (0)