Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions schemas/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@
"description": "When tagging a release, include `v` in the tag. Defaults to `false`.",
"type": "boolean"
},
"include-v-in-release-name": {
"description": "Include `v` in the GitHub release name. Defaults to `true`.",
"type": "boolean"
},
"changelog-type": {
"description": "The type of changelog to use. Defaults to `default`.",
"type": "string",
Expand Down Expand Up @@ -471,6 +475,7 @@
"extra-label": true,
"include-component-in-tag": true,
"include-v-in-tag": true,
"include-v-in-release-name": true,
"changelog-type": true,
"changelog-host": true,
"changelog-path": true,
Expand Down
5 changes: 5 additions & 0 deletions src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export interface ReleaserConfig {
packageName?: string;
includeComponentInTag?: boolean;
includeVInTag?: boolean;
includeVInReleaseName?: boolean;
pullRequestTitlePattern?: string;
pullRequestHeader?: string;
pullRequestFooter?: string;
Expand Down Expand Up @@ -172,6 +173,7 @@ interface ReleaserConfigJson {
'extra-label'?: string;
'include-component-in-tag'?: boolean;
'include-v-in-tag'?: boolean;
'include-v-in-release-name'?: boolean;
'changelog-type'?: ChangelogNotesType;
'changelog-host'?: string;
'pull-request-title-pattern'?: string;
Expand Down Expand Up @@ -1393,6 +1395,7 @@ function extractReleaserConfig(
extraFiles: config['extra-files'],
includeComponentInTag: config['include-component-in-tag'],
includeVInTag: config['include-v-in-tag'],
includeVInReleaseName: config['include-v-in-release-name'],
changelogType: config['changelog-type'],
pullRequestTitlePattern: config['pull-request-title-pattern'],
pullRequestHeader: config['pull-request-header'],
Expand Down Expand Up @@ -1750,6 +1753,8 @@ function mergeReleaserConfig(
includeComponentInTag:
pathConfig.includeComponentInTag ?? defaultConfig.includeComponentInTag,
includeVInTag: pathConfig.includeVInTag ?? defaultConfig.includeVInTag,
includeVInReleaseName:
pathConfig.includeVInReleaseName ?? defaultConfig.includeVInReleaseName,
tagSeparator: pathConfig.tagSeparator ?? defaultConfig.tagSeparator,
pullRequestTitlePattern:
pathConfig.pullRequestTitlePattern ??
Expand Down
8 changes: 6 additions & 2 deletions src/strategies/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export interface BaseStrategyOptions {
changelogNotes?: ChangelogNotes;
includeComponentInTag?: boolean;
includeVInTag?: boolean;
includeVInReleaseName?: boolean;
pullRequestTitlePattern?: string;
pullRequestHeader?: string;
pullRequestFooter?: string;
Expand Down Expand Up @@ -110,6 +111,7 @@ export abstract class BaseStrategy implements Strategy {
private releaseAs?: string;
protected includeComponentInTag: boolean;
protected includeVInTag: boolean;
protected includeVInReleaseName: boolean;
protected initialVersion?: string;
readonly pullRequestTitlePattern?: string;
readonly pullRequestHeader?: string;
Expand Down Expand Up @@ -147,6 +149,7 @@ export abstract class BaseStrategy implements Strategy {
options.changelogNotes || new DefaultChangelogNotes(options);
this.includeComponentInTag = options.includeComponentInTag ?? true;
this.includeVInTag = options.includeVInTag ?? true;
this.includeVInReleaseName = options.includeVInReleaseName ?? true;
this.pullRequestTitlePattern = options.pullRequestTitlePattern;
this.pullRequestHeader = options.pullRequestHeader;
this.pullRequestFooter = options.pullRequestFooter;
Expand Down Expand Up @@ -698,10 +701,11 @@ export abstract class BaseStrategy implements Strategy {
this.tagSeparator,
this.includeVInTag
);
const versionPrefix = this.includeVInReleaseName ? 'v' : '';
const releaseName =
component && this.includeComponentInTag
? `${component}: v${version.toString()}`
: `v${version.toString()}`;
? `${component}: ${versionPrefix}${version.toString()}`
: `${versionPrefix}${version.toString()}`;
return {
name: releaseName,
tag,
Expand Down
1 change: 1 addition & 0 deletions src/updaters/release-please-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ function releaserConfigToJsonConfig(
'release-label': config.releaseLabels?.join(','),
'include-component-in-tag': config.includeComponentInTag,
'include-v-in-tag': config.includeVInTag,
'include-v-in-release-name': config.includeVInReleaseName,
'changelog-type': config.changelogType,
'changelog-host': config.changelogHost,
'pull-request-title-pattern': config.pullRequestTitlePattern,
Expand Down
62 changes: 62 additions & 0 deletions test/strategies/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,5 +452,67 @@ describe('Strategy', () => {
expect(release, 'Release').to.not.be.undefined;
expect(release!.tag.toString()).to.eql('1.2.3');
});
it('skips v in release name', async () => {
const strategy = new TestStrategy({
targetBranch: 'main',
github,
component: 'google-cloud-automl',
includeComponentInTag: false,
includeVInReleaseName: false,
});
const release = await strategy.buildRelease({
title: 'chore(main): release v1.2.3',
headBranchName: 'release-please/branches/main',
baseBranchName: 'main',
number: 1234,
body: new PullRequestBody([]).toString(),
labels: [],
files: [],
sha: 'abc123',
});
expect(release, 'Release').to.not.be.undefined;
expect(release!.name).to.eql('1.2.3');
});
it('skips v in release name with component', async () => {
const strategy = new TestStrategy({
targetBranch: 'main',
github,
component: 'google-cloud-automl',
includeComponentInTag: true,
includeVInReleaseName: false,
});
const release = await strategy.buildRelease({
title: 'chore(main): release v1.2.3',
headBranchName: 'release-please/branches/main',
baseBranchName: 'main',
number: 1234,
body: new PullRequestBody([]).toString(),
labels: [],
files: [],
sha: 'abc123',
});
expect(release, 'Release').to.not.be.undefined;
expect(release!.name).to.eql('google-cloud-automl: 1.2.3');
});
it('includes v in release name by default', async () => {
const strategy = new TestStrategy({
targetBranch: 'main',
github,
component: 'google-cloud-automl',
includeComponentInTag: false,
});
const release = await strategy.buildRelease({
title: 'chore(main): release v1.2.3',
headBranchName: 'release-please/branches/main',
baseBranchName: 'main',
number: 1234,
body: new PullRequestBody([]).toString(),
labels: [],
files: [],
sha: 'abc123',
});
expect(release, 'Release').to.not.be.undefined;
expect(release!.name).to.eql('v1.2.3');
});
});
});
Loading