release-please 13.0.0-candidate.3 → 13.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +59 -0
- package/README.md +33 -131
- package/build/src/bin/release-please.d.ts +0 -1
- package/build/src/bin/release-please.js +24 -6
- package/build/src/changelog-notes/default.d.ts +1 -3
- package/build/src/changelog-notes/default.js +2 -3
- package/build/src/changelog-notes/github.d.ts +8 -0
- package/build/src/changelog-notes/github.js +26 -0
- package/build/src/changelog-notes.d.ts +3 -0
- package/build/src/changelog-notes.js +24 -0
- package/build/src/commit.d.ts +1 -1
- package/build/src/commit.js +14 -1
- package/build/src/factory.d.ts +13 -0
- package/build/src/factory.js +26 -1
- package/build/src/github.d.ts +48 -7
- package/build/src/github.js +73 -19
- package/build/src/index.d.ts +5 -0
- package/build/src/index.js +27 -0
- package/build/src/manifest.d.ts +7 -3
- package/build/src/manifest.js +93 -24
- package/build/src/plugins/cargo-workspace.js +2 -2
- package/build/src/plugins/merge.js +4 -1
- package/build/src/plugins/node-workspace.js +2 -2
- package/build/src/pull-request.d.ts +8 -8
- package/build/src/release-pull-request.d.ts +6 -6
- package/build/src/strategies/base.d.ts +108 -0
- package/build/src/strategies/base.js +253 -0
- package/build/src/strategies/dart.d.ts +2 -2
- package/build/src/strategies/dart.js +2 -2
- package/build/src/strategies/elixir.d.ts +2 -2
- package/build/src/strategies/elixir.js +2 -2
- package/build/src/strategies/go-yoshi.d.ts +3 -3
- package/build/src/strategies/go-yoshi.js +10 -2
- package/build/src/strategies/go.d.ts +2 -2
- package/build/src/strategies/go.js +2 -2
- package/build/src/strategies/helm.d.ts +2 -2
- package/build/src/strategies/helm.js +2 -2
- package/build/src/strategies/java-yoshi.d.ts +5 -4
- package/build/src/strategies/java-yoshi.js +58 -2
- package/build/src/strategies/krm-blueprint.d.ts +2 -2
- package/build/src/strategies/krm-blueprint.js +3 -3
- package/build/src/strategies/node.d.ts +2 -2
- package/build/src/strategies/node.js +2 -2
- package/build/src/strategies/ocaml.d.ts +2 -2
- package/build/src/strategies/ocaml.js +2 -2
- package/build/src/strategies/php-yoshi.d.ts +3 -3
- package/build/src/strategies/php-yoshi.js +3 -2
- package/build/src/strategies/php.d.ts +3 -3
- package/build/src/strategies/php.js +2 -2
- package/build/src/strategies/python.d.ts +2 -2
- package/build/src/strategies/python.js +2 -2
- package/build/src/strategies/ruby-yoshi.d.ts +3 -3
- package/build/src/strategies/ruby-yoshi.js +7 -2
- package/build/src/strategies/ruby.d.ts +3 -3
- package/build/src/strategies/ruby.js +2 -2
- package/build/src/strategies/rust.d.ts +2 -2
- package/build/src/strategies/rust.js +2 -2
- package/build/src/strategies/simple.d.ts +2 -2
- package/build/src/strategies/simple.js +2 -2
- package/build/src/strategies/terraform-module.d.ts +2 -2
- package/build/src/strategies/terraform-module.js +2 -2
- package/build/src/strategy.d.ts +8 -70
- package/build/src/strategy.js +0 -226
- package/build/src/updaters/go/version-go.d.ts +4 -0
- package/build/src/updaters/go/version-go.js +24 -0
- package/build/src/updaters/rust/cargo-toml.js +5 -1
- package/build/src/util/branch-name.js +65 -7
- package/build/src/util/commit-split.js +3 -0
- package/build/src/util/pull-request-title.js +1 -0
- package/build/src/version.d.ts +28 -5
- package/build/src/version.js +26 -0
- package/build/src/versioning-strategies/always-bump-patch.d.ts +4 -0
- package/build/src/versioning-strategies/always-bump-patch.js +4 -0
- package/build/src/versioning-strategies/default.d.ts +31 -0
- package/build/src/versioning-strategies/default.js +31 -0
- package/build/src/versioning-strategies/dependency-manifest.d.ts +8 -0
- package/build/src/versioning-strategies/dependency-manifest.js +8 -0
- package/build/src/versioning-strategies/java-add-snapshot.d.ts +4 -0
- package/build/src/versioning-strategies/java-add-snapshot.js +6 -5
- package/build/src/versioning-strategies/java-snapshot.d.ts +4 -0
- package/build/src/versioning-strategies/java-snapshot.js +4 -1
- package/build/src/versioning-strategies/service-pack.d.ts +5 -0
- package/build/src/versioning-strategies/service-pack.js +10 -3
- package/build/src/versioning-strategy.d.ts +67 -5
- package/build/src/versioning-strategy.js +37 -10
- package/package.json +4 -4
- package/build/src/release-notes.d.ts +0 -29
- package/build/src/release-notes.js +0 -71
|
@@ -3,11 +3,11 @@ import { Version } from './version';
|
|
|
3
3
|
import { PullRequestBody } from './util/pull-request-body';
|
|
4
4
|
import { PullRequestTitle } from './util/pull-request-title';
|
|
5
5
|
export interface ReleasePullRequest {
|
|
6
|
-
title: PullRequestTitle;
|
|
7
|
-
body: PullRequestBody;
|
|
6
|
+
readonly title: PullRequestTitle;
|
|
7
|
+
readonly body: PullRequestBody;
|
|
8
|
+
readonly labels: string[];
|
|
9
|
+
readonly headRefName: string;
|
|
10
|
+
readonly version?: Version;
|
|
11
|
+
readonly draft: boolean;
|
|
8
12
|
updates: Update[];
|
|
9
|
-
labels: string[];
|
|
10
|
-
headRefName: string;
|
|
11
|
-
version?: Version;
|
|
12
|
-
draft: boolean;
|
|
13
13
|
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { Strategy } from '../strategy';
|
|
2
|
+
import { GitHub } from '../github';
|
|
3
|
+
import { VersioningStrategy } from '../versioning-strategy';
|
|
4
|
+
import { Repository } from '../repository';
|
|
5
|
+
import { ChangelogNotes, ChangelogSection } from '../changelog-notes';
|
|
6
|
+
import { Update } from '../update';
|
|
7
|
+
import { ConventionalCommit, Commit } from '../commit';
|
|
8
|
+
import { Version, VersionsMap } from '../version';
|
|
9
|
+
import { TagName } from '../util/tag-name';
|
|
10
|
+
import { Release } from '../release';
|
|
11
|
+
import { ReleasePullRequest } from '../release-pull-request';
|
|
12
|
+
import { PullRequest } from '../pull-request';
|
|
13
|
+
export interface BuildUpdatesOptions {
|
|
14
|
+
changelogEntry: string;
|
|
15
|
+
newVersion: Version;
|
|
16
|
+
versionsMap: VersionsMap;
|
|
17
|
+
latestVersion?: Version;
|
|
18
|
+
}
|
|
19
|
+
export interface BaseStrategyOptions {
|
|
20
|
+
path?: string;
|
|
21
|
+
bumpMinorPreMajor?: boolean;
|
|
22
|
+
bumpPatchForMinorPreMajor?: boolean;
|
|
23
|
+
github: GitHub;
|
|
24
|
+
component?: string;
|
|
25
|
+
packageName?: string;
|
|
26
|
+
versioningStrategy?: VersioningStrategy;
|
|
27
|
+
targetBranch: string;
|
|
28
|
+
changelogPath?: string;
|
|
29
|
+
changelogSections?: ChangelogSection[];
|
|
30
|
+
commitPartial?: string;
|
|
31
|
+
headerPartial?: string;
|
|
32
|
+
mainTemplate?: string;
|
|
33
|
+
tagSeparator?: string;
|
|
34
|
+
skipGitHubRelease?: boolean;
|
|
35
|
+
releaseAs?: string;
|
|
36
|
+
changelogNotes?: ChangelogNotes;
|
|
37
|
+
includeComponentInTag?: boolean;
|
|
38
|
+
pullRequestTitlePattern?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A strategy is responsible for determining which files are
|
|
42
|
+
* necessary to update in a release pull request.
|
|
43
|
+
*/
|
|
44
|
+
export declare abstract class BaseStrategy implements Strategy {
|
|
45
|
+
readonly path: string;
|
|
46
|
+
protected github: GitHub;
|
|
47
|
+
protected component?: string;
|
|
48
|
+
protected packageName?: string;
|
|
49
|
+
readonly versioningStrategy: VersioningStrategy;
|
|
50
|
+
protected targetBranch: string;
|
|
51
|
+
protected repository: Repository;
|
|
52
|
+
protected changelogPath: string;
|
|
53
|
+
protected tagSeparator?: string;
|
|
54
|
+
private skipGitHubRelease;
|
|
55
|
+
private releaseAs?;
|
|
56
|
+
private includeComponentInTag;
|
|
57
|
+
private pullRequestTitlePattern?;
|
|
58
|
+
readonly changelogNotes: ChangelogNotes;
|
|
59
|
+
protected changelogSections?: ChangelogSection[];
|
|
60
|
+
constructor(options: BaseStrategyOptions);
|
|
61
|
+
/**
|
|
62
|
+
* Specify the files necessary to update in a release pull request.
|
|
63
|
+
* @param {BuildUpdatesOptions} options
|
|
64
|
+
*/
|
|
65
|
+
protected abstract buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
|
|
66
|
+
/**
|
|
67
|
+
* Return the component for this strategy. This may be a computed field.
|
|
68
|
+
* @returns {string}
|
|
69
|
+
*/
|
|
70
|
+
getComponent(): Promise<string | undefined>;
|
|
71
|
+
getDefaultComponent(): Promise<string | undefined>;
|
|
72
|
+
getDefaultPackageName(): Promise<string | undefined>;
|
|
73
|
+
protected normalizeComponent(component: string | undefined): string;
|
|
74
|
+
/**
|
|
75
|
+
* Override this method to post process commits
|
|
76
|
+
* @param {ConventionalCommit[]} commits parsed commits
|
|
77
|
+
* @returns {ConventionalCommit[]} modified commits
|
|
78
|
+
*/
|
|
79
|
+
protected postProcessCommits(commits: ConventionalCommit[]): ConventionalCommit[];
|
|
80
|
+
protected buildReleaseNotes(conventionalCommits: ConventionalCommit[], newVersion: Version, newVersionTag: TagName, latestRelease?: Release): Promise<string>;
|
|
81
|
+
/**
|
|
82
|
+
* Builds a candidate release pull request
|
|
83
|
+
* @param {Commit[]} commits Raw commits to consider for this release.
|
|
84
|
+
* @param {Release} latestRelease Optional. The last release for this
|
|
85
|
+
* component if available.
|
|
86
|
+
* @param {boolean} draft Optional. Whether or not to create the pull
|
|
87
|
+
* request as a draft. Defaults to `false`.
|
|
88
|
+
* @returns {ReleasePullRequest | undefined} The release pull request to
|
|
89
|
+
* open for this path/component. Returns undefined if we should not
|
|
90
|
+
* open a pull request.
|
|
91
|
+
*/
|
|
92
|
+
buildReleasePullRequest(commits: Commit[], latestRelease?: Release, draft?: boolean, labels?: string[]): Promise<ReleasePullRequest | undefined>;
|
|
93
|
+
protected changelogEmpty(changelogEntry: string): boolean;
|
|
94
|
+
protected updateVersionsMap(versionsMap: VersionsMap, conventionalCommits: ConventionalCommit[]): Promise<VersionsMap>;
|
|
95
|
+
protected buildNewVersion(conventionalCommits: ConventionalCommit[], latestRelease?: Release): Promise<Version>;
|
|
96
|
+
protected buildVersionsMap(_conventionalCommits: ConventionalCommit[]): Promise<VersionsMap>;
|
|
97
|
+
/**
|
|
98
|
+
* Given a merged pull request, build the candidate release.
|
|
99
|
+
* @param {PullRequest} mergedPullRequest The merged release pull request.
|
|
100
|
+
* @returns {Release} The candidate release.
|
|
101
|
+
*/
|
|
102
|
+
buildRelease(mergedPullRequest: PullRequest): Promise<Release | undefined>;
|
|
103
|
+
/**
|
|
104
|
+
* Override this to handle the initial version of a new library.
|
|
105
|
+
*/
|
|
106
|
+
protected initialReleaseVersion(): Version;
|
|
107
|
+
protected addPath(file: string): string;
|
|
108
|
+
}
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2021 Google LLC
|
|
3
|
+
//
|
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
// you may not use this file except in compliance with the License.
|
|
6
|
+
// You may obtain a copy of the License at
|
|
7
|
+
//
|
|
8
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
//
|
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
// See the License for the specific language governing permissions and
|
|
14
|
+
// limitations under the License.
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.BaseStrategy = void 0;
|
|
17
|
+
const manifest_1 = require("../manifest");
|
|
18
|
+
const default_1 = require("../versioning-strategies/default");
|
|
19
|
+
const default_2 = require("../changelog-notes/default");
|
|
20
|
+
const commit_1 = require("../commit");
|
|
21
|
+
const version_1 = require("../version");
|
|
22
|
+
const tag_name_1 = require("../util/tag-name");
|
|
23
|
+
const logger_1 = require("../util/logger");
|
|
24
|
+
const pull_request_title_1 = require("../util/pull-request-title");
|
|
25
|
+
const branch_name_1 = require("../util/branch-name");
|
|
26
|
+
const pull_request_body_1 = require("../util/pull-request-body");
|
|
27
|
+
const DEFAULT_CHANGELOG_PATH = 'CHANGELOG.md';
|
|
28
|
+
/**
|
|
29
|
+
* A strategy is responsible for determining which files are
|
|
30
|
+
* necessary to update in a release pull request.
|
|
31
|
+
*/
|
|
32
|
+
class BaseStrategy {
|
|
33
|
+
constructor(options) {
|
|
34
|
+
var _a;
|
|
35
|
+
this.path = options.path || manifest_1.ROOT_PROJECT_PATH;
|
|
36
|
+
this.github = options.github;
|
|
37
|
+
this.packageName = options.packageName;
|
|
38
|
+
this.component =
|
|
39
|
+
options.component || this.normalizeComponent(this.packageName);
|
|
40
|
+
this.versioningStrategy =
|
|
41
|
+
options.versioningStrategy || new default_1.DefaultVersioningStrategy({});
|
|
42
|
+
this.targetBranch = options.targetBranch;
|
|
43
|
+
this.repository = options.github.repository;
|
|
44
|
+
this.changelogPath = options.changelogPath || DEFAULT_CHANGELOG_PATH;
|
|
45
|
+
this.changelogSections = options.changelogSections;
|
|
46
|
+
this.tagSeparator = options.tagSeparator;
|
|
47
|
+
this.skipGitHubRelease = options.skipGitHubRelease || false;
|
|
48
|
+
this.releaseAs = options.releaseAs;
|
|
49
|
+
this.changelogNotes =
|
|
50
|
+
options.changelogNotes || new default_2.DefaultChangelogNotes(options);
|
|
51
|
+
this.includeComponentInTag = (_a = options.includeComponentInTag) !== null && _a !== void 0 ? _a : true;
|
|
52
|
+
this.pullRequestTitlePattern = options.pullRequestTitlePattern;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Return the component for this strategy. This may be a computed field.
|
|
56
|
+
* @returns {string}
|
|
57
|
+
*/
|
|
58
|
+
async getComponent() {
|
|
59
|
+
if (!this.includeComponentInTag) {
|
|
60
|
+
return '';
|
|
61
|
+
}
|
|
62
|
+
return this.component || (await this.getDefaultComponent());
|
|
63
|
+
}
|
|
64
|
+
async getDefaultComponent() {
|
|
65
|
+
return this.normalizeComponent(await this.getDefaultPackageName());
|
|
66
|
+
}
|
|
67
|
+
async getDefaultPackageName() {
|
|
68
|
+
return '';
|
|
69
|
+
}
|
|
70
|
+
normalizeComponent(component) {
|
|
71
|
+
if (!component) {
|
|
72
|
+
return '';
|
|
73
|
+
}
|
|
74
|
+
return component;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Override this method to post process commits
|
|
78
|
+
* @param {ConventionalCommit[]} commits parsed commits
|
|
79
|
+
* @returns {ConventionalCommit[]} modified commits
|
|
80
|
+
*/
|
|
81
|
+
postProcessCommits(commits) {
|
|
82
|
+
return commits;
|
|
83
|
+
}
|
|
84
|
+
async buildReleaseNotes(conventionalCommits, newVersion, newVersionTag, latestRelease) {
|
|
85
|
+
var _a;
|
|
86
|
+
return await this.changelogNotes.buildNotes(conventionalCommits, {
|
|
87
|
+
owner: this.repository.owner,
|
|
88
|
+
repository: this.repository.repo,
|
|
89
|
+
version: newVersion.toString(),
|
|
90
|
+
previousTag: (_a = latestRelease === null || latestRelease === void 0 ? void 0 : latestRelease.tag) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
91
|
+
currentTag: newVersionTag.toString(),
|
|
92
|
+
targetBranch: this.targetBranch,
|
|
93
|
+
changelogSections: this.changelogSections,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Builds a candidate release pull request
|
|
98
|
+
* @param {Commit[]} commits Raw commits to consider for this release.
|
|
99
|
+
* @param {Release} latestRelease Optional. The last release for this
|
|
100
|
+
* component if available.
|
|
101
|
+
* @param {boolean} draft Optional. Whether or not to create the pull
|
|
102
|
+
* request as a draft. Defaults to `false`.
|
|
103
|
+
* @returns {ReleasePullRequest | undefined} The release pull request to
|
|
104
|
+
* open for this path/component. Returns undefined if we should not
|
|
105
|
+
* open a pull request.
|
|
106
|
+
*/
|
|
107
|
+
async buildReleasePullRequest(commits, latestRelease, draft, labels = []) {
|
|
108
|
+
const conventionalCommits = this.postProcessCommits(commit_1.parseConventionalCommits(commits));
|
|
109
|
+
const newVersion = await this.buildNewVersion(conventionalCommits, latestRelease);
|
|
110
|
+
const versionsMap = await this.updateVersionsMap(await this.buildVersionsMap(conventionalCommits), conventionalCommits);
|
|
111
|
+
const component = await this.getComponent();
|
|
112
|
+
logger_1.logger.debug('component:', component);
|
|
113
|
+
const newVersionTag = new tag_name_1.TagName(newVersion, this.includeComponentInTag ? component : undefined, this.tagSeparator);
|
|
114
|
+
logger_1.logger.warn('pull request title pattern:', this.pullRequestTitlePattern);
|
|
115
|
+
const pullRequestTitle = pull_request_title_1.PullRequestTitle.ofComponentTargetBranchVersion(component || '', this.targetBranch, newVersion, this.pullRequestTitlePattern);
|
|
116
|
+
const branchName = component
|
|
117
|
+
? branch_name_1.BranchName.ofComponentTargetBranch(component, this.targetBranch)
|
|
118
|
+
: branch_name_1.BranchName.ofTargetBranch(this.targetBranch);
|
|
119
|
+
const releaseNotesBody = await this.buildReleaseNotes(conventionalCommits, newVersion, newVersionTag, latestRelease);
|
|
120
|
+
if (this.changelogEmpty(releaseNotesBody)) {
|
|
121
|
+
logger_1.logger.info(`No user facing commits found since ${latestRelease ? latestRelease.sha : 'beginning of time'} - skipping`);
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
const updates = await this.buildUpdates({
|
|
125
|
+
changelogEntry: releaseNotesBody,
|
|
126
|
+
newVersion,
|
|
127
|
+
versionsMap,
|
|
128
|
+
latestVersion: latestRelease === null || latestRelease === void 0 ? void 0 : latestRelease.tag.version,
|
|
129
|
+
});
|
|
130
|
+
const pullRequestBody = new pull_request_body_1.PullRequestBody([
|
|
131
|
+
{
|
|
132
|
+
component,
|
|
133
|
+
version: newVersion,
|
|
134
|
+
notes: releaseNotesBody,
|
|
135
|
+
},
|
|
136
|
+
]);
|
|
137
|
+
return {
|
|
138
|
+
title: pullRequestTitle,
|
|
139
|
+
body: pullRequestBody,
|
|
140
|
+
updates,
|
|
141
|
+
labels,
|
|
142
|
+
headRefName: branchName.toString(),
|
|
143
|
+
version: newVersion,
|
|
144
|
+
draft: draft !== null && draft !== void 0 ? draft : false,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
changelogEmpty(changelogEntry) {
|
|
148
|
+
return changelogEntry.split('\n').length <= 1;
|
|
149
|
+
}
|
|
150
|
+
async updateVersionsMap(versionsMap, conventionalCommits) {
|
|
151
|
+
for (const versionKey of versionsMap.keys()) {
|
|
152
|
+
const version = versionsMap.get(versionKey);
|
|
153
|
+
if (!version) {
|
|
154
|
+
logger_1.logger.warn(`didn't find version for ${versionKey}`);
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
const newVersion = await this.versioningStrategy.bump(version, conventionalCommits);
|
|
158
|
+
versionsMap.set(versionKey, newVersion);
|
|
159
|
+
}
|
|
160
|
+
return versionsMap;
|
|
161
|
+
}
|
|
162
|
+
async buildNewVersion(conventionalCommits, latestRelease) {
|
|
163
|
+
if (this.releaseAs) {
|
|
164
|
+
logger_1.logger.warn(`Setting version for ${this.path} from release-as configuration`);
|
|
165
|
+
return version_1.Version.parse(this.releaseAs);
|
|
166
|
+
}
|
|
167
|
+
else if (latestRelease) {
|
|
168
|
+
return await this.versioningStrategy.bump(latestRelease.tag.version, conventionalCommits);
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
return this.initialReleaseVersion();
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
async buildVersionsMap(_conventionalCommits) {
|
|
175
|
+
return new Map();
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Given a merged pull request, build the candidate release.
|
|
179
|
+
* @param {PullRequest} mergedPullRequest The merged release pull request.
|
|
180
|
+
* @returns {Release} The candidate release.
|
|
181
|
+
*/
|
|
182
|
+
async buildRelease(mergedPullRequest) {
|
|
183
|
+
if (this.skipGitHubRelease) {
|
|
184
|
+
logger_1.logger.info('Release skipped from strategy config');
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
if (!mergedPullRequest.sha) {
|
|
188
|
+
logger_1.logger.error('Pull request should have been merged');
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
const pullRequestTitle = pull_request_title_1.PullRequestTitle.parse(mergedPullRequest.title, this.pullRequestTitlePattern) ||
|
|
192
|
+
pull_request_title_1.PullRequestTitle.parse(mergedPullRequest.title, manifest_1.MANIFEST_PULL_REQUEST_TITLE_PATTERN);
|
|
193
|
+
if (!pullRequestTitle) {
|
|
194
|
+
logger_1.logger.error(`Bad pull request title: '${mergedPullRequest.title}'`);
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
const branchName = branch_name_1.BranchName.parse(mergedPullRequest.headBranchName);
|
|
198
|
+
if (!branchName) {
|
|
199
|
+
logger_1.logger.error(`Bad branch name: ${mergedPullRequest.headBranchName}`);
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
const pullRequestBody = pull_request_body_1.PullRequestBody.parse(mergedPullRequest.body);
|
|
203
|
+
if (!pullRequestBody) {
|
|
204
|
+
logger_1.logger.error('Could not parse pull request body as a release PR');
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
const component = await this.getComponent();
|
|
208
|
+
logger_1.logger.info('component:', component);
|
|
209
|
+
const releaseData = pullRequestBody.releaseData.length === 1 &&
|
|
210
|
+
!pullRequestBody.releaseData[0].component
|
|
211
|
+
? pullRequestBody.releaseData[0]
|
|
212
|
+
: pullRequestBody.releaseData.find(releaseData => {
|
|
213
|
+
return (this.normalizeComponent(releaseData.component) ===
|
|
214
|
+
this.normalizeComponent(component));
|
|
215
|
+
});
|
|
216
|
+
const notes = releaseData === null || releaseData === void 0 ? void 0 : releaseData.notes;
|
|
217
|
+
if (notes === undefined) {
|
|
218
|
+
logger_1.logger.warn('Failed to find release notes');
|
|
219
|
+
}
|
|
220
|
+
const version = pullRequestTitle.getVersion() || (releaseData === null || releaseData === void 0 ? void 0 : releaseData.version);
|
|
221
|
+
if (!version) {
|
|
222
|
+
logger_1.logger.error('Pull request should have included version');
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
const tag = new tag_name_1.TagName(version, this.includeComponentInTag ? component : undefined, this.tagSeparator);
|
|
226
|
+
return {
|
|
227
|
+
tag,
|
|
228
|
+
notes: notes || '',
|
|
229
|
+
sha: mergedPullRequest.sha,
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Override this to handle the initial version of a new library.
|
|
234
|
+
*/
|
|
235
|
+
initialReleaseVersion() {
|
|
236
|
+
return version_1.Version.parse('1.0.0');
|
|
237
|
+
}
|
|
238
|
+
addPath(file) {
|
|
239
|
+
if (this.path === manifest_1.ROOT_PROJECT_PATH) {
|
|
240
|
+
return file;
|
|
241
|
+
}
|
|
242
|
+
file = file.replace(/^[/\\]/, '');
|
|
243
|
+
if (this.path === undefined) {
|
|
244
|
+
return file;
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
const path = this.path.replace(/[/\\]$/, '');
|
|
248
|
+
return `${path}/${file}`;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
exports.BaseStrategy = BaseStrategy;
|
|
253
|
+
//# sourceMappingURL=base.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseStrategy, BuildUpdatesOptions } from './base';
|
|
2
2
|
import { Update } from '../update';
|
|
3
|
-
export declare class Dart extends
|
|
3
|
+
export declare class Dart extends BaseStrategy {
|
|
4
4
|
private pubspecYmlContents?;
|
|
5
5
|
protected buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
|
|
6
6
|
getDefaultPackageName(): Promise<string | undefined>;
|
|
@@ -19,8 +19,8 @@ const changelog_1 = require("../updaters/changelog");
|
|
|
19
19
|
const yaml = require("js-yaml");
|
|
20
20
|
// pubspec
|
|
21
21
|
const pubspec_yaml_1 = require("../updaters/dart/pubspec-yaml");
|
|
22
|
-
const
|
|
23
|
-
class Dart extends
|
|
22
|
+
const base_1 = require("./base");
|
|
23
|
+
class Dart extends base_1.BaseStrategy {
|
|
24
24
|
async buildUpdates(options) {
|
|
25
25
|
const updates = [];
|
|
26
26
|
const version = options.newVersion;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseStrategy, BuildUpdatesOptions } from './base';
|
|
2
2
|
import { Update } from '../update';
|
|
3
|
-
export declare class Elixir extends
|
|
3
|
+
export declare class Elixir extends BaseStrategy {
|
|
4
4
|
protected buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
|
|
5
5
|
}
|
|
@@ -18,8 +18,8 @@ exports.Elixir = void 0;
|
|
|
18
18
|
const changelog_1 = require("../updaters/changelog");
|
|
19
19
|
// mix.exs support
|
|
20
20
|
const elixir_mix_exs_1 = require("../updaters/elixir/elixir-mix-exs");
|
|
21
|
-
const
|
|
22
|
-
class Elixir extends
|
|
21
|
+
const base_1 = require("./base");
|
|
22
|
+
class Elixir extends base_1.BaseStrategy {
|
|
23
23
|
async buildUpdates(options) {
|
|
24
24
|
const updates = [];
|
|
25
25
|
const version = options.newVersion;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseStrategy, BuildUpdatesOptions, BaseStrategyOptions } from './base';
|
|
2
2
|
import { Update } from '../update';
|
|
3
3
|
import { ConventionalCommit } from '../commit';
|
|
4
4
|
import { Version } from '../version';
|
|
5
5
|
import { TagName } from '../util/tag-name';
|
|
6
6
|
import { Release } from '../release';
|
|
7
|
-
export declare class GoYoshi extends
|
|
8
|
-
constructor(options:
|
|
7
|
+
export declare class GoYoshi extends BaseStrategy {
|
|
8
|
+
constructor(options: BaseStrategyOptions);
|
|
9
9
|
protected buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
|
|
10
10
|
protected postProcessCommits(commits: ConventionalCommit[]): ConventionalCommit[];
|
|
11
11
|
protected buildReleaseNotes(conventionalCommits: ConventionalCommit[], newVersion: Version, newVersionTag: TagName, latestRelease?: Release): Promise<string>;
|
|
@@ -14,9 +14,10 @@
|
|
|
14
14
|
// limitations under the License.
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.GoYoshi = void 0;
|
|
17
|
-
const
|
|
17
|
+
const base_1 = require("./base");
|
|
18
18
|
const changelog_1 = require("../updaters/changelog");
|
|
19
19
|
const version_1 = require("../version");
|
|
20
|
+
const version_go_1 = require("../updaters/go/version-go");
|
|
20
21
|
// Commits containing a scope prefixed with an item in this array will be
|
|
21
22
|
// ignored when generating a release PR for the parent module.
|
|
22
23
|
const IGNORED_SUB_MODULES = new Set([
|
|
@@ -32,7 +33,7 @@ const IGNORED_SUB_MODULES = new Set([
|
|
|
32
33
|
]);
|
|
33
34
|
const REGEN_PR_REGEX = /.*auto-regenerate.*/;
|
|
34
35
|
const REGEN_ISSUE_REGEX = /(?<prefix>.*)\(#(?<pr>.*)\)(\n|$)/;
|
|
35
|
-
class GoYoshi extends
|
|
36
|
+
class GoYoshi extends base_1.BaseStrategy {
|
|
36
37
|
constructor(options) {
|
|
37
38
|
var _a;
|
|
38
39
|
options.changelogPath = (_a = options.changelogPath) !== null && _a !== void 0 ? _a : 'CHANGES.md';
|
|
@@ -49,6 +50,13 @@ class GoYoshi extends strategy_1.Strategy {
|
|
|
49
50
|
changelogEntry: options.changelogEntry,
|
|
50
51
|
}),
|
|
51
52
|
});
|
|
53
|
+
updates.push({
|
|
54
|
+
path: this.addPath('internal/version.go'),
|
|
55
|
+
createIfMissing: false,
|
|
56
|
+
updater: new version_go_1.VersionGo({
|
|
57
|
+
version,
|
|
58
|
+
}),
|
|
59
|
+
});
|
|
52
60
|
return updates;
|
|
53
61
|
}
|
|
54
62
|
postProcessCommits(commits) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseStrategy, BuildUpdatesOptions } from './base';
|
|
2
2
|
import { Update } from '../update';
|
|
3
|
-
export declare class Go extends
|
|
3
|
+
export declare class Go extends BaseStrategy {
|
|
4
4
|
protected buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
|
|
5
5
|
}
|
|
@@ -16,8 +16,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
16
16
|
exports.Go = void 0;
|
|
17
17
|
// Generic
|
|
18
18
|
const changelog_1 = require("../updaters/changelog");
|
|
19
|
-
const
|
|
20
|
-
class Go extends
|
|
19
|
+
const base_1 = require("./base");
|
|
20
|
+
class Go extends base_1.BaseStrategy {
|
|
21
21
|
async buildUpdates(options) {
|
|
22
22
|
const updates = [];
|
|
23
23
|
const version = options.newVersion;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseStrategy, BuildUpdatesOptions } from './base';
|
|
2
2
|
import { Update } from '../update';
|
|
3
|
-
export declare class Helm extends
|
|
3
|
+
export declare class Helm extends BaseStrategy {
|
|
4
4
|
private chartYmlContents?;
|
|
5
5
|
protected buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
|
|
6
6
|
getDefaultPackageName(): Promise<string | undefined>;
|
|
@@ -19,8 +19,8 @@ const changelog_1 = require("../updaters/changelog");
|
|
|
19
19
|
const yaml = require("js-yaml");
|
|
20
20
|
// helm
|
|
21
21
|
const chart_yaml_1 = require("../updaters/helm/chart-yaml");
|
|
22
|
-
const
|
|
23
|
-
class Helm extends
|
|
22
|
+
const base_1 = require("./base");
|
|
23
|
+
class Helm extends base_1.BaseStrategy {
|
|
24
24
|
async buildUpdates(options) {
|
|
25
25
|
const updates = [];
|
|
26
26
|
const version = options.newVersion;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Update } from '../update';
|
|
2
2
|
import { Version, VersionsMap } from '../version';
|
|
3
|
-
import {
|
|
3
|
+
import { BaseStrategy, BuildUpdatesOptions, BaseStrategyOptions } from './base';
|
|
4
4
|
import { GitHubFileContents } from '../github';
|
|
5
|
-
import { Commit } from '../commit';
|
|
5
|
+
import { Commit, ConventionalCommit } from '../commit';
|
|
6
6
|
import { Release } from '../release';
|
|
7
7
|
import { ReleasePullRequest } from '../release-pull-request';
|
|
8
|
-
interface JavaStrategyOptions extends
|
|
8
|
+
interface JavaStrategyOptions extends BaseStrategyOptions {
|
|
9
9
|
extraFiles?: string[];
|
|
10
10
|
}
|
|
11
|
-
export declare class JavaYoshi extends
|
|
11
|
+
export declare class JavaYoshi extends BaseStrategy {
|
|
12
12
|
readonly extraFiles: string[];
|
|
13
13
|
private versionsContent?;
|
|
14
14
|
private snapshotVersioning;
|
|
@@ -19,6 +19,7 @@ export declare class JavaYoshi extends Strategy {
|
|
|
19
19
|
protected buildVersionsMap(): Promise<VersionsMap>;
|
|
20
20
|
protected getVersionsContent(): Promise<GitHubFileContents>;
|
|
21
21
|
protected buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
|
|
22
|
+
protected updateVersionsMap(versionsMap: VersionsMap, conventionalCommits: ConventionalCommit[]): Promise<VersionsMap>;
|
|
22
23
|
protected initialReleaseVersion(): Version;
|
|
23
24
|
}
|
|
24
25
|
export {};
|
|
@@ -17,7 +17,7 @@ exports.JavaYoshi = void 0;
|
|
|
17
17
|
const versions_manifest_1 = require("../updaters/java/versions-manifest");
|
|
18
18
|
const version_1 = require("../version");
|
|
19
19
|
const java_update_1 = require("../updaters/java/java-update");
|
|
20
|
-
const
|
|
20
|
+
const base_1 = require("./base");
|
|
21
21
|
const changelog_1 = require("../updaters/changelog");
|
|
22
22
|
const java_snapshot_1 = require("../versioning-strategies/java-snapshot");
|
|
23
23
|
const errors_1 = require("../errors");
|
|
@@ -41,7 +41,7 @@ const CHANGELOG_SECTIONS = [
|
|
|
41
41
|
{ type: 'build', section: 'Build System', hidden: true },
|
|
42
42
|
{ type: 'ci', section: 'Continuous Integration', hidden: true },
|
|
43
43
|
];
|
|
44
|
-
class JavaYoshi extends
|
|
44
|
+
class JavaYoshi extends base_1.BaseStrategy {
|
|
45
45
|
constructor(options) {
|
|
46
46
|
var _a;
|
|
47
47
|
options.changelogSections = (_a = options.changelogSections) !== null && _a !== void 0 ? _a : CHANGELOG_SECTIONS;
|
|
@@ -195,9 +195,65 @@ class JavaYoshi extends strategy_1.Strategy {
|
|
|
195
195
|
});
|
|
196
196
|
return updates;
|
|
197
197
|
}
|
|
198
|
+
async updateVersionsMap(versionsMap, conventionalCommits) {
|
|
199
|
+
let isPromotion = false;
|
|
200
|
+
const modifiedCommits = [];
|
|
201
|
+
for (const commit of conventionalCommits) {
|
|
202
|
+
if (isPromotionCommit(commit)) {
|
|
203
|
+
isPromotion = true;
|
|
204
|
+
modifiedCommits.push({
|
|
205
|
+
...commit,
|
|
206
|
+
notes: commit.notes.filter(note => !isPromotionNote(note)),
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
modifiedCommits.push(commit);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
for (const versionKey of versionsMap.keys()) {
|
|
214
|
+
const version = versionsMap.get(versionKey);
|
|
215
|
+
if (!version) {
|
|
216
|
+
logger_1.logger.warn(`didn't find version for ${versionKey}`);
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
if (isPromotion && isStableArtifact(versionKey)) {
|
|
220
|
+
versionsMap.set(versionKey, version_1.Version.parse('1.0.0'));
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
const newVersion = await this.versioningStrategy.bump(version, modifiedCommits);
|
|
224
|
+
versionsMap.set(versionKey, newVersion);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return versionsMap;
|
|
228
|
+
}
|
|
198
229
|
initialReleaseVersion() {
|
|
199
230
|
return version_1.Version.parse('0.1.0');
|
|
200
231
|
}
|
|
201
232
|
}
|
|
202
233
|
exports.JavaYoshi = JavaYoshi;
|
|
234
|
+
const VERSIONED_ARTIFACT_REGEX = /^.*-(v\d+[^-]*)$/;
|
|
235
|
+
const VERSION_REGEX = /^v\d+(.*)$/;
|
|
236
|
+
/**
|
|
237
|
+
* Returns true if the artifact should be considered stable
|
|
238
|
+
* @param artifact name of the artifact to check
|
|
239
|
+
*/
|
|
240
|
+
function isStableArtifact(artifact) {
|
|
241
|
+
const match = artifact.match(VERSIONED_ARTIFACT_REGEX);
|
|
242
|
+
if (!match) {
|
|
243
|
+
// The artifact does not have a version qualifier at the end
|
|
244
|
+
return true;
|
|
245
|
+
}
|
|
246
|
+
const versionMatch = match[1].match(VERSION_REGEX);
|
|
247
|
+
if (versionMatch && versionMatch[1]) {
|
|
248
|
+
// The version is not stable (probably alpha/beta/rc)
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
return true;
|
|
252
|
+
}
|
|
253
|
+
function isPromotionCommit(commit) {
|
|
254
|
+
return commit.notes.some(isPromotionNote);
|
|
255
|
+
}
|
|
256
|
+
function isPromotionNote(note) {
|
|
257
|
+
return note.title === 'RELEASE AS' && note.text === '1.0.0';
|
|
258
|
+
}
|
|
203
259
|
//# sourceMappingURL=java-yoshi.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseStrategy, BuildUpdatesOptions } from './base';
|
|
2
2
|
import { Update } from '../update';
|
|
3
3
|
import { Version } from '../version';
|
|
4
|
-
export declare class KRMBlueprint extends
|
|
4
|
+
export declare class KRMBlueprint extends BaseStrategy {
|
|
5
5
|
protected buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
|
|
6
6
|
protected initialReleaseVersion(): Version;
|
|
7
7
|
}
|
|
@@ -18,11 +18,11 @@ exports.KRMBlueprint = void 0;
|
|
|
18
18
|
const changelog_1 = require("../updaters/changelog");
|
|
19
19
|
// KRM specific.
|
|
20
20
|
const krm_blueprint_version_1 = require("../updaters/krm/krm-blueprint-version");
|
|
21
|
-
const
|
|
21
|
+
const base_1 = require("./base");
|
|
22
22
|
const version_1 = require("../version");
|
|
23
23
|
const KRMBlueprintAttribAnnotation = 'cnrm.cloud.google.com/blueprint';
|
|
24
24
|
const hasKRMBlueprintAttrib = (content) => content.includes(KRMBlueprintAttribAnnotation);
|
|
25
|
-
class KRMBlueprint extends
|
|
25
|
+
class KRMBlueprint extends base_1.BaseStrategy {
|
|
26
26
|
async buildUpdates(options) {
|
|
27
27
|
const updates = [];
|
|
28
28
|
const version = options.newVersion;
|
|
@@ -39,7 +39,7 @@ class KRMBlueprint extends strategy_1.Strategy {
|
|
|
39
39
|
versionsMap.set('previousVersion', options.latestVersion);
|
|
40
40
|
}
|
|
41
41
|
// Update version in all yaml files with attribution annotation
|
|
42
|
-
const yamlPaths = await this.github.
|
|
42
|
+
const yamlPaths = await this.github.findFilesByExtensionAndRef('yaml', this.targetBranch, this.path);
|
|
43
43
|
for (const yamlPath of yamlPaths) {
|
|
44
44
|
const contents = await this.github.getFileContents(this.addPath(yamlPath));
|
|
45
45
|
if (hasKRMBlueprintAttrib(contents.parsedContent)) {
|