Skip to content

Commit

Permalink
Don't release canary on skip-release by default, add force flag
Browse files Browse the repository at this point in the history
  • Loading branch information
zephraph committed Feb 26, 2020
1 parent 16e936b commit 14d433d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
11 changes: 10 additions & 1 deletion packages/cli/src/parse-args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
};

Expand Down Expand Up @@ -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'
Expand All @@ -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'
}
]
},
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/auto-args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
18 changes: 14 additions & 4 deletions packages/core/src/auto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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!);
Expand Down Expand Up @@ -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 = '';

Expand Down

0 comments on commit 14d433d

Please sign in to comment.