diff --git a/packages/cli/src/parse-args.ts b/packages/cli/src/parse-args.ts index 1f439d8654..8aa0286241 100644 --- a/packages/cli/src/parse-args.ts +++ b/packages/cli/src/parse-args.ts @@ -131,7 +131,8 @@ const url: Option = { const noVersionPrefix: Option = { name: 'no-version-prefix', type: Boolean, - description: "Use the version as the tag without the 'v' prefix. WARNING: some plugins might need extra config to use this option (ex: npm)", + description: + "Use the version as the tag without the 'v' prefix. WARNING: some plugins might need extra config to use this option (ex: npm)", group: 'main' }; @@ -455,6 +456,7 @@ export const commands: Command[] = [ `, examples: [ '{green $} auto canary', + '{green $} auto canary --force', '{green $} auto canary --pr 123 --build 5', '{green $} auto canary --message "Install PR version: `yarn add -D my-project@%v`"', '{green $} auto canary --message false' @@ -477,6 +479,13 @@ export const commands: Command[] = [ ...message, description: "Message to comment on PR with. Defaults to 'Published PR with canary version: %v'. Pass false to disable the comment" + }, + { + name: 'force', + type: Boolean, + group: 'main', + description: + 'Force a canary release, even if the PR is marked to skip the release' } ] }, diff --git a/packages/core/src/auto-args.ts b/packages/core/src/auto-args.ts index 74019e44d0..9bc216cec2 100644 --- a/packages/core/src/auto-args.ts +++ b/packages/core/src/auto-args.ts @@ -126,6 +126,8 @@ export interface ICanaryOptions { build?: number; /** The message used when attaching the canary version to a PR */ message?: string | 'false'; + /** Always deploy a canary, even if the PR is marked as skip release */ + force?: boolean; } export interface INextOptions { diff --git a/packages/core/src/auto.ts b/packages/core/src/auto.ts index 54c402a59e..6ef8d2e7cd 100644 --- a/packages/core/src/auto.ts +++ b/packages/core/src/auto.ts @@ -521,7 +521,7 @@ export default class Auto { return { hasError: false }; } - const [, gitVersion = ''] = await on(execPromise('git', ['--version'])) + const [, gitVersion = ''] = await on(execPromise('git', ['--version'])); const [noProject, project] = await on(this.git.getProject()); const repo = (await this.getRepo(this.config!)) || {}; const repoLink = link(`${repo.owner}/${repo.repo}`, project?.html_url!); @@ -981,9 +981,19 @@ export default class Auto { const from = (await this.git.shaExists('HEAD^')) ? 'HEAD^' : 'HEAD'; const head = await this.release.getCommitsInRelease(from); const labels = head.map(commit => commit.labels); - const version = - calculateSemVerBump(labels, this.semVerLabels!, this.config) || - SEMVER.patch; + const version = calculateSemVerBump( + labels, + this.semVerLabels!, + this.config + ); + + if (version === SEMVER.noVersion && !options.force) { + this.logger.log.info( + 'Skipping canary release due to PR being specifying no release. Use `auto canary --force` to override this setting' + ); + return; + } + let canaryVersion = ''; let newVersion = '';