release-please 13.7.1 → 13.9.0
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 +27 -0
- package/README.md +9 -6
- package/build/src/bin/release-please.d.ts +1 -0
- package/build/src/bin/release-please.js +15 -0
- package/build/src/factory.d.ts +1 -1
- package/build/src/factory.js +25 -1
- package/build/src/manifest.d.ts +16 -1
- package/build/src/manifest.js +39 -27
- package/build/src/strategies/base.d.ts +5 -3
- package/build/src/strategies/base.js +16 -8
- package/build/src/strategies/dotnet-yoshi.d.ts +12 -0
- package/build/src/strategies/dotnet-yoshi.js +96 -0
- package/build/src/strategies/java-yoshi.d.ts +4 -14
- package/build/src/strategies/java-yoshi.js +3 -83
- package/build/src/strategies/java.d.ts +28 -0
- package/build/src/strategies/java.js +160 -0
- package/build/src/strategies/maven.d.ts +9 -0
- package/build/src/strategies/maven.js +56 -0
- package/build/src/strategies/php-yoshi.js +2 -1
- package/build/src/strategies/ruby-yoshi.d.ts +3 -3
- package/build/src/strategies/ruby-yoshi.js +11 -46
- package/build/src/strategy.d.ts +7 -0
- package/build/src/updaters/base-xml.d.ts +19 -0
- package/build/src/updaters/base-xml.js +39 -0
- package/build/src/updaters/dotnet/apis.d.ts +17 -0
- package/build/src/updaters/dotnet/apis.js +45 -0
- package/build/src/updaters/generic-xml.d.ts +5 -10
- package/build/src/updaters/generic-xml.js +11 -20
- package/build/src/updaters/generic.d.ts +16 -4
- package/build/src/updaters/generic.js +13 -6
- package/build/src/updaters/java/java-released.d.ts +28 -0
- package/build/src/updaters/java/java-released.js +59 -0
- package/build/src/updaters/java/pom-xml.d.ts +14 -0
- package/build/src/updaters/java/pom-xml.js +52 -0
- package/build/src/util/tag-name.d.ts +2 -1
- package/build/src/util/tag-name.js +6 -5
- package/package.json +1 -1
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2022 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.DotnetYoshi = void 0;
|
|
17
|
+
const base_1 = require("./base");
|
|
18
|
+
const changelog_1 = require("../updaters/changelog");
|
|
19
|
+
const apis_1 = require("../updaters/dotnet/apis");
|
|
20
|
+
const logger_1 = require("../util/logger");
|
|
21
|
+
const errors_1 = require("../errors");
|
|
22
|
+
const CHANGELOG_SECTIONS = [
|
|
23
|
+
{ type: 'feat', section: 'New features' },
|
|
24
|
+
{ type: 'fix', section: 'Bug fixes' },
|
|
25
|
+
{ type: 'perf', section: 'Performance improvements' },
|
|
26
|
+
{ type: 'revert', section: 'Reverts' },
|
|
27
|
+
{ type: 'chore', section: 'Miscellaneous chores', hidden: true },
|
|
28
|
+
{ type: 'docs', section: 'Documentation improvements' },
|
|
29
|
+
{ type: 'style', section: 'Styles', hidden: true },
|
|
30
|
+
{ type: 'refactor', section: 'Code Refactoring', hidden: true },
|
|
31
|
+
{ type: 'test', section: 'Tests', hidden: true },
|
|
32
|
+
{ type: 'build', section: 'Build System', hidden: true },
|
|
33
|
+
{ type: 'ci', section: 'Continuous Integration', hidden: true },
|
|
34
|
+
];
|
|
35
|
+
const DEFAULT_CHANGELOG_PATH = 'docs/history.md';
|
|
36
|
+
const DEFAULT_PULL_REQUEST_TITLE_PATTERN = 'Release${component} version ${version}';
|
|
37
|
+
const RELEASE_NOTES_HEADER_PATTERN = /#{2,3} \[?(\d+\.\d+\.\d+-?[^\]]*)\]?.* \((\d{4}-\d{2}-\d{2})\)/;
|
|
38
|
+
class DotnetYoshi extends base_1.BaseStrategy {
|
|
39
|
+
constructor(options) {
|
|
40
|
+
var _a, _b, _c, _d;
|
|
41
|
+
options.changelogSections = (_a = options.changelogSections) !== null && _a !== void 0 ? _a : CHANGELOG_SECTIONS;
|
|
42
|
+
options.changelogPath = (_b = options.changelogPath) !== null && _b !== void 0 ? _b : DEFAULT_CHANGELOG_PATH;
|
|
43
|
+
options.pullRequestTitlePattern = (_c = options.pullRequestTitlePattern) !== null && _c !== void 0 ? _c : DEFAULT_PULL_REQUEST_TITLE_PATTERN;
|
|
44
|
+
options.includeVInTag = (_d = options.includeVInTag) !== null && _d !== void 0 ? _d : false;
|
|
45
|
+
super(options);
|
|
46
|
+
}
|
|
47
|
+
async buildReleaseNotes(conventionalCommits, newVersion, newVersionTag, latestRelease) {
|
|
48
|
+
const notes = await super.buildReleaseNotes(conventionalCommits, newVersion, newVersionTag, latestRelease);
|
|
49
|
+
return notes.replace(RELEASE_NOTES_HEADER_PATTERN, '## Version $1, released $2');
|
|
50
|
+
}
|
|
51
|
+
async getApi() {
|
|
52
|
+
try {
|
|
53
|
+
const contents = await this.github.getFileContentsOnBranch('apis/apis.json', this.targetBranch);
|
|
54
|
+
const apis = JSON.parse(contents.parsedContent);
|
|
55
|
+
const component = await this.getComponent();
|
|
56
|
+
return apis.apis.find(api => api.id === component);
|
|
57
|
+
}
|
|
58
|
+
catch (e) {
|
|
59
|
+
if (e instanceof errors_1.FileNotFoundError) {
|
|
60
|
+
throw new errors_1.MissingRequiredFileError('apis/apis.json', DotnetYoshi.name, `${this.repository.owner}/${this.repository.repo}`);
|
|
61
|
+
}
|
|
62
|
+
throw e;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
async buildUpdates(options) {
|
|
66
|
+
const updates = [];
|
|
67
|
+
const version = options.newVersion;
|
|
68
|
+
const component = await this.getComponent();
|
|
69
|
+
const api = await this.getApi();
|
|
70
|
+
if (api === null || api === void 0 ? void 0 : api.noVersionHistory) {
|
|
71
|
+
logger_1.logger.info(`Skipping changelog for ${component} via noVersionHistory configuration`);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
updates.push({
|
|
75
|
+
path: this.addPath(this.changelogPath),
|
|
76
|
+
createIfMissing: true,
|
|
77
|
+
updater: new changelog_1.Changelog({
|
|
78
|
+
version,
|
|
79
|
+
changelogEntry: options.changelogEntry,
|
|
80
|
+
}),
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
if (!this.component) {
|
|
84
|
+
logger_1.logger.warn('Dotnet strategy expects to use components, could not update all files');
|
|
85
|
+
return updates;
|
|
86
|
+
}
|
|
87
|
+
updates.push({
|
|
88
|
+
path: 'apis/apis.json',
|
|
89
|
+
createIfMissing: false,
|
|
90
|
+
updater: new apis_1.Apis(this.component, version),
|
|
91
|
+
});
|
|
92
|
+
return updates;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
exports.DotnetYoshi = DotnetYoshi;
|
|
96
|
+
//# sourceMappingURL=dotnet-yoshi.js.map
|
|
@@ -1,30 +1,20 @@
|
|
|
1
1
|
import { Update } from '../update';
|
|
2
2
|
import { Version, VersionsMap } from '../version';
|
|
3
|
-
import { BaseStrategy, BuildUpdatesOptions, BaseStrategyOptions } from './base';
|
|
4
3
|
import { GitHubFileContents } from '../util/file-cache';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
interface JavaBuildUpdatesOption extends BuildUpdatesOptions {
|
|
9
|
-
isSnapshot?: boolean;
|
|
10
|
-
}
|
|
11
|
-
export declare class JavaYoshi extends BaseStrategy {
|
|
4
|
+
import { ConventionalCommit } from '../commit';
|
|
5
|
+
import { Java, JavaBuildUpdatesOption } from './java';
|
|
6
|
+
export declare class JavaYoshi extends Java {
|
|
12
7
|
private versionsContent?;
|
|
13
|
-
private snapshotVersioning;
|
|
14
|
-
constructor(options: BaseStrategyOptions);
|
|
15
|
-
buildReleasePullRequest(commits: Commit[], latestRelease?: Release, draft?: boolean, labels?: string[]): Promise<ReleasePullRequest | undefined>;
|
|
16
|
-
private buildSnapshotPullRequest;
|
|
17
8
|
/**
|
|
18
9
|
* Override this method to post process commits
|
|
19
10
|
* @param {ConventionalCommit[]} commits parsed commits
|
|
20
11
|
* @returns {ConventionalCommit[]} modified commits
|
|
21
12
|
*/
|
|
22
13
|
protected postProcessCommits(commits: ConventionalCommit[]): Promise<ConventionalCommit[]>;
|
|
23
|
-
|
|
14
|
+
protected needsSnapshot(): Promise<boolean>;
|
|
24
15
|
protected buildVersionsMap(): Promise<VersionsMap>;
|
|
25
16
|
protected getVersionsContent(): Promise<GitHubFileContents>;
|
|
26
17
|
protected buildUpdates(options: JavaBuildUpdatesOption): Promise<Update[]>;
|
|
27
18
|
protected updateVersionsMap(versionsMap: VersionsMap, conventionalCommits: ConventionalCommit[]): Promise<VersionsMap>;
|
|
28
19
|
protected initialReleaseVersion(): Version;
|
|
29
20
|
}
|
|
30
|
-
export {};
|
|
@@ -16,92 +16,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
16
16
|
exports.JavaYoshi = void 0;
|
|
17
17
|
const versions_manifest_1 = require("../updaters/java/versions-manifest");
|
|
18
18
|
const version_1 = require("../version");
|
|
19
|
-
const java_update_1 = require("../updaters/java/java-update");
|
|
20
|
-
const base_1 = require("./base");
|
|
21
19
|
const changelog_1 = require("../updaters/changelog");
|
|
22
|
-
const java_snapshot_1 = require("../versioning-strategies/java-snapshot");
|
|
23
20
|
const errors_1 = require("../errors");
|
|
24
21
|
const logger_1 = require("../util/logger");
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
const default_1 = require("../versioning-strategies/default");
|
|
29
|
-
const java_add_snapshot_1 = require("../versioning-strategies/java-add-snapshot");
|
|
30
|
-
const CHANGELOG_SECTIONS = [
|
|
31
|
-
{ type: 'feat', section: 'Features' },
|
|
32
|
-
{ type: 'fix', section: 'Bug Fixes' },
|
|
33
|
-
{ type: 'perf', section: 'Performance Improvements' },
|
|
34
|
-
{ type: 'deps', section: 'Dependencies' },
|
|
35
|
-
{ type: 'revert', section: 'Reverts' },
|
|
36
|
-
{ type: 'docs', section: 'Documentation' },
|
|
37
|
-
{ type: 'style', section: 'Styles', hidden: true },
|
|
38
|
-
{ type: 'chore', section: 'Miscellaneous Chores', hidden: true },
|
|
39
|
-
{ type: 'refactor', section: 'Code Refactoring', hidden: true },
|
|
40
|
-
{ type: 'test', section: 'Tests', hidden: true },
|
|
41
|
-
{ type: 'build', section: 'Build System', hidden: true },
|
|
42
|
-
{ type: 'ci', section: 'Continuous Integration', hidden: true },
|
|
43
|
-
];
|
|
44
|
-
class JavaYoshi extends base_1.BaseStrategy {
|
|
45
|
-
constructor(options) {
|
|
46
|
-
var _a;
|
|
47
|
-
options.changelogSections = (_a = options.changelogSections) !== null && _a !== void 0 ? _a : CHANGELOG_SECTIONS;
|
|
48
|
-
// wrap the configured versioning strategy with snapshotting
|
|
49
|
-
const parentVersioningStrategy = options.versioningStrategy || new default_1.DefaultVersioningStrategy();
|
|
50
|
-
options.versioningStrategy = new java_snapshot_1.JavaSnapshot(parentVersioningStrategy);
|
|
51
|
-
super(options);
|
|
52
|
-
this.snapshotVersioning = new java_add_snapshot_1.JavaAddSnapshot(parentVersioningStrategy);
|
|
53
|
-
}
|
|
54
|
-
async buildReleasePullRequest(commits, latestRelease, draft, labels = []) {
|
|
55
|
-
if (await this.needsSnapshot()) {
|
|
56
|
-
logger_1.logger.info('Repository needs a snapshot bump.');
|
|
57
|
-
return await this.buildSnapshotPullRequest(latestRelease);
|
|
58
|
-
}
|
|
59
|
-
logger_1.logger.info('No Java snapshot needed');
|
|
60
|
-
return await super.buildReleasePullRequest(commits, latestRelease, draft, labels);
|
|
61
|
-
}
|
|
62
|
-
async buildSnapshotPullRequest(latestRelease) {
|
|
63
|
-
const component = await this.getComponent();
|
|
64
|
-
const newVersion = latestRelease
|
|
65
|
-
? await this.snapshotVersioning.bump(latestRelease.tag.version, [])
|
|
66
|
-
: this.initialReleaseVersion();
|
|
67
|
-
const versionsMap = await this.buildVersionsMap();
|
|
68
|
-
for (const versionKey of versionsMap.keys()) {
|
|
69
|
-
const version = versionsMap.get(versionKey);
|
|
70
|
-
if (!version) {
|
|
71
|
-
logger_1.logger.warn(`didn't find version for ${versionKey}`);
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
const newVersion = await this.snapshotVersioning.bump(version, []);
|
|
75
|
-
versionsMap.set(versionKey, newVersion);
|
|
76
|
-
}
|
|
77
|
-
const pullRequestTitle = pull_request_title_1.PullRequestTitle.ofComponentTargetBranchVersion(component || '', this.targetBranch, newVersion);
|
|
78
|
-
const branchName = component
|
|
79
|
-
? branch_name_1.BranchName.ofComponentTargetBranch(component, this.targetBranch)
|
|
80
|
-
: branch_name_1.BranchName.ofTargetBranch(this.targetBranch);
|
|
81
|
-
const notes = '### Updating meta-information for bleeding-edge SNAPSHOT release.';
|
|
82
|
-
const pullRequestBody = new pull_request_body_1.PullRequestBody([
|
|
83
|
-
{
|
|
84
|
-
component,
|
|
85
|
-
version: newVersion,
|
|
86
|
-
notes,
|
|
87
|
-
},
|
|
88
|
-
]);
|
|
89
|
-
const updates = await this.buildUpdates({
|
|
90
|
-
newVersion,
|
|
91
|
-
versionsMap,
|
|
92
|
-
changelogEntry: notes,
|
|
93
|
-
isSnapshot: true,
|
|
94
|
-
});
|
|
95
|
-
return {
|
|
96
|
-
title: pullRequestTitle,
|
|
97
|
-
body: pullRequestBody,
|
|
98
|
-
updates,
|
|
99
|
-
labels: [],
|
|
100
|
-
headRefName: branchName.toString(),
|
|
101
|
-
version: newVersion,
|
|
102
|
-
draft: false,
|
|
103
|
-
};
|
|
104
|
-
}
|
|
22
|
+
const java_1 = require("./java");
|
|
23
|
+
const java_update_1 = require("../updaters/java/java-update");
|
|
24
|
+
class JavaYoshi extends java_1.Java {
|
|
105
25
|
/**
|
|
106
26
|
* Override this method to post process commits
|
|
107
27
|
* @param {ConventionalCommit[]} commits parsed commits
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Update } from '../update';
|
|
2
|
+
import { Version } from '../version';
|
|
3
|
+
import { BaseStrategy, BaseStrategyOptions, BuildUpdatesOptions } from './base';
|
|
4
|
+
import { Commit } from '../commit';
|
|
5
|
+
import { Release } from '../release';
|
|
6
|
+
import { ReleasePullRequest } from '../release-pull-request';
|
|
7
|
+
import { VersioningStrategy } from '../versioning-strategy';
|
|
8
|
+
export interface JavaStrategyOptions extends BaseStrategyOptions {
|
|
9
|
+
snapshotLabels?: string[];
|
|
10
|
+
}
|
|
11
|
+
export interface JavaBuildUpdatesOption extends BuildUpdatesOptions {
|
|
12
|
+
isSnapshot?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A strategy that generates SNAPSHOT version after each release, which is standard especially in Maven projects.
|
|
16
|
+
*
|
|
17
|
+
* This is universal strategy that does not update any files on its own. Use maven strategy for Maven projects.
|
|
18
|
+
*/
|
|
19
|
+
export declare class Java extends BaseStrategy {
|
|
20
|
+
protected readonly snapshotVersioning: VersioningStrategy;
|
|
21
|
+
protected readonly snapshotLabels: string[];
|
|
22
|
+
constructor(options: JavaStrategyOptions);
|
|
23
|
+
buildReleasePullRequest(commits: Commit[], latestRelease?: Release, draft?: boolean, labels?: string[]): Promise<ReleasePullRequest | undefined>;
|
|
24
|
+
protected buildSnapshotPullRequest(latestRelease?: Release, draft?: boolean, labels?: string[]): Promise<ReleasePullRequest>;
|
|
25
|
+
isPublishedVersion(version: Version): boolean;
|
|
26
|
+
protected needsSnapshot(commits: Commit[], latestRelease?: Release): Promise<boolean>;
|
|
27
|
+
protected buildUpdates(options: JavaBuildUpdatesOption): Promise<Update[]>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2022 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.Java = void 0;
|
|
17
|
+
const base_1 = require("./base");
|
|
18
|
+
const changelog_1 = require("../updaters/changelog");
|
|
19
|
+
const java_snapshot_1 = require("../versioning-strategies/java-snapshot");
|
|
20
|
+
const logger_1 = require("../util/logger");
|
|
21
|
+
const pull_request_title_1 = require("../util/pull-request-title");
|
|
22
|
+
const branch_name_1 = require("../util/branch-name");
|
|
23
|
+
const pull_request_body_1 = require("../util/pull-request-body");
|
|
24
|
+
const default_1 = require("../versioning-strategies/default");
|
|
25
|
+
const java_add_snapshot_1 = require("../versioning-strategies/java-add-snapshot");
|
|
26
|
+
const manifest_1 = require("../manifest");
|
|
27
|
+
const java_released_1 = require("../updaters/java/java-released");
|
|
28
|
+
const composite_1 = require("../updaters/composite");
|
|
29
|
+
const CHANGELOG_SECTIONS = [
|
|
30
|
+
{ type: 'feat', section: 'Features' },
|
|
31
|
+
{ type: 'fix', section: 'Bug Fixes' },
|
|
32
|
+
{ type: 'perf', section: 'Performance Improvements' },
|
|
33
|
+
{ type: 'deps', section: 'Dependencies' },
|
|
34
|
+
{ type: 'revert', section: 'Reverts' },
|
|
35
|
+
{ type: 'docs', section: 'Documentation' },
|
|
36
|
+
{ type: 'style', section: 'Styles', hidden: true },
|
|
37
|
+
{ type: 'chore', section: 'Miscellaneous Chores', hidden: true },
|
|
38
|
+
{ type: 'refactor', section: 'Code Refactoring', hidden: true },
|
|
39
|
+
{ type: 'test', section: 'Tests', hidden: true },
|
|
40
|
+
{ type: 'build', section: 'Build System', hidden: true },
|
|
41
|
+
{ type: 'ci', section: 'Continuous Integration', hidden: true },
|
|
42
|
+
];
|
|
43
|
+
/**
|
|
44
|
+
* A strategy that generates SNAPSHOT version after each release, which is standard especially in Maven projects.
|
|
45
|
+
*
|
|
46
|
+
* This is universal strategy that does not update any files on its own. Use maven strategy for Maven projects.
|
|
47
|
+
*/
|
|
48
|
+
class Java extends base_1.BaseStrategy {
|
|
49
|
+
constructor(options) {
|
|
50
|
+
var _a;
|
|
51
|
+
options.changelogSections = (_a = options.changelogSections) !== null && _a !== void 0 ? _a : CHANGELOG_SECTIONS;
|
|
52
|
+
// wrap the configured versioning strategy with snapshotting
|
|
53
|
+
const parentVersioningStrategy = options.versioningStrategy || new default_1.DefaultVersioningStrategy();
|
|
54
|
+
options.versioningStrategy = new java_snapshot_1.JavaSnapshot(parentVersioningStrategy);
|
|
55
|
+
super(options);
|
|
56
|
+
this.snapshotVersioning = new java_add_snapshot_1.JavaAddSnapshot(parentVersioningStrategy);
|
|
57
|
+
this.snapshotLabels = options.snapshotLabels || manifest_1.DEFAULT_SNAPSHOT_LABELS;
|
|
58
|
+
}
|
|
59
|
+
async buildReleasePullRequest(commits, latestRelease, draft, labels = []) {
|
|
60
|
+
if (await this.needsSnapshot(commits, latestRelease)) {
|
|
61
|
+
logger_1.logger.info('Repository needs a snapshot bump.');
|
|
62
|
+
return await this.buildSnapshotPullRequest(latestRelease, draft, this.snapshotLabels);
|
|
63
|
+
}
|
|
64
|
+
logger_1.logger.info('No Java snapshot needed');
|
|
65
|
+
return await super.buildReleasePullRequest(commits, latestRelease, draft, labels);
|
|
66
|
+
}
|
|
67
|
+
async buildSnapshotPullRequest(latestRelease, draft, labels = []) {
|
|
68
|
+
const component = await this.getComponent();
|
|
69
|
+
const newVersion = latestRelease
|
|
70
|
+
? await this.snapshotVersioning.bump(latestRelease.tag.version, [])
|
|
71
|
+
: this.initialReleaseVersion();
|
|
72
|
+
const versionsMap = await this.buildVersionsMap([]);
|
|
73
|
+
const pullRequestTitle = pull_request_title_1.PullRequestTitle.ofComponentTargetBranchVersion(component || '', this.targetBranch, newVersion);
|
|
74
|
+
const branchName = component
|
|
75
|
+
? branch_name_1.BranchName.ofComponentTargetBranch(component, this.targetBranch)
|
|
76
|
+
: branch_name_1.BranchName.ofTargetBranch(this.targetBranch);
|
|
77
|
+
const notes = '### Updating meta-information for bleeding-edge SNAPSHOT release.';
|
|
78
|
+
const pullRequestBody = new pull_request_body_1.PullRequestBody([
|
|
79
|
+
{
|
|
80
|
+
component,
|
|
81
|
+
version: newVersion,
|
|
82
|
+
notes,
|
|
83
|
+
},
|
|
84
|
+
]);
|
|
85
|
+
const updates = await this.buildUpdates({
|
|
86
|
+
newVersion,
|
|
87
|
+
versionsMap,
|
|
88
|
+
changelogEntry: notes,
|
|
89
|
+
isSnapshot: true,
|
|
90
|
+
});
|
|
91
|
+
const updatesWithExtras = composite_1.mergeUpdates(updates.concat(...this.extraFileUpdates(newVersion, versionsMap)));
|
|
92
|
+
return {
|
|
93
|
+
title: pullRequestTitle,
|
|
94
|
+
body: pullRequestBody,
|
|
95
|
+
updates: updatesWithExtras,
|
|
96
|
+
labels: labels,
|
|
97
|
+
headRefName: branchName.toString(),
|
|
98
|
+
version: newVersion,
|
|
99
|
+
draft: draft !== null && draft !== void 0 ? draft : false,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
isPublishedVersion(version) {
|
|
103
|
+
return !version.preRelease || version.preRelease.indexOf('SNAPSHOT') < 0;
|
|
104
|
+
}
|
|
105
|
+
async needsSnapshot(commits, latestRelease) {
|
|
106
|
+
var _a;
|
|
107
|
+
const component = await this.getComponent();
|
|
108
|
+
logger_1.logger.debug('component:', component);
|
|
109
|
+
const version = (_a = latestRelease === null || latestRelease === void 0 ? void 0 : latestRelease.tag) === null || _a === void 0 ? void 0 : _a.version;
|
|
110
|
+
if (!version) {
|
|
111
|
+
// Don't bump snapshots for the first release ever
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
// Found snapshot as a release, this is unexpected, but use it
|
|
115
|
+
if (!this.isPublishedVersion(version)) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
// Search commits for snapshot bump
|
|
119
|
+
const pullRequests = commits
|
|
120
|
+
.map(commit => {
|
|
121
|
+
var _a;
|
|
122
|
+
return pull_request_title_1.PullRequestTitle.parse(((_a = commit.pullRequest) === null || _a === void 0 ? void 0 : _a.title) || commit.message, this.pullRequestTitlePattern);
|
|
123
|
+
})
|
|
124
|
+
.filter(pullRequest => pullRequest);
|
|
125
|
+
const snapshotCommits = pullRequests
|
|
126
|
+
.filter(pullRequest => ((pullRequest === null || pullRequest === void 0 ? void 0 : pullRequest.component) || '') === component)
|
|
127
|
+
.map(pullRequest => pullRequest === null || pullRequest === void 0 ? void 0 : pullRequest.getVersion())
|
|
128
|
+
.filter(version => version && !this.isPublishedVersion(version));
|
|
129
|
+
return snapshotCommits.length === 0;
|
|
130
|
+
}
|
|
131
|
+
async buildUpdates(options) {
|
|
132
|
+
const version = options.newVersion;
|
|
133
|
+
const versionsMap = options.versionsMap;
|
|
134
|
+
const updates = [];
|
|
135
|
+
if (!options.isSnapshot) {
|
|
136
|
+
// Append java-specific updater for extraFiles
|
|
137
|
+
this.extraFiles.forEach(extraFile => {
|
|
138
|
+
if (typeof extraFile === 'string') {
|
|
139
|
+
updates.push({
|
|
140
|
+
path: this.addPath(extraFile),
|
|
141
|
+
createIfMissing: false,
|
|
142
|
+
updater: new java_released_1.JavaReleased({ version, versionsMap }),
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
// Update changelog
|
|
147
|
+
updates.push({
|
|
148
|
+
path: this.addPath(this.changelogPath),
|
|
149
|
+
createIfMissing: true,
|
|
150
|
+
updater: new changelog_1.Changelog({
|
|
151
|
+
version,
|
|
152
|
+
changelogEntry: options.changelogEntry,
|
|
153
|
+
}),
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
return updates;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
exports.Java = Java;
|
|
160
|
+
//# sourceMappingURL=java.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Java, JavaBuildUpdatesOption } from './java';
|
|
2
|
+
import { Update } from '../update';
|
|
3
|
+
/**
|
|
4
|
+
* Strategy for Maven projects. It generates SNAPSHOT version after each release, and updates all found
|
|
5
|
+
* pom.xml files automatically.
|
|
6
|
+
*/
|
|
7
|
+
export declare class Maven extends Java {
|
|
8
|
+
protected buildUpdates(options: JavaBuildUpdatesOption): Promise<Update[]>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2022 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.Maven = void 0;
|
|
17
|
+
const java_1 = require("./java");
|
|
18
|
+
const java_released_1 = require("../updaters/java/java-released");
|
|
19
|
+
const generic_1 = require("../updaters/generic");
|
|
20
|
+
const pom_xml_1 = require("../updaters/java/pom-xml");
|
|
21
|
+
/**
|
|
22
|
+
* Strategy for Maven projects. It generates SNAPSHOT version after each release, and updates all found
|
|
23
|
+
* pom.xml files automatically.
|
|
24
|
+
*/
|
|
25
|
+
class Maven extends java_1.Java {
|
|
26
|
+
async buildUpdates(options) {
|
|
27
|
+
const version = options.newVersion;
|
|
28
|
+
const versionsMap = options.versionsMap;
|
|
29
|
+
// Use generic Java updates
|
|
30
|
+
const updates = await super.buildUpdates(options);
|
|
31
|
+
// Update pom.xml files
|
|
32
|
+
const pomFiles = await this.github.findFilesByFilenameAndRef('pom.xml', this.targetBranch, this.path);
|
|
33
|
+
pomFiles.forEach(path => {
|
|
34
|
+
updates.push({
|
|
35
|
+
path: this.addPath(path),
|
|
36
|
+
createIfMissing: false,
|
|
37
|
+
updater: new pom_xml_1.PomXml(version),
|
|
38
|
+
});
|
|
39
|
+
if (!options.isSnapshot) {
|
|
40
|
+
updates.push({
|
|
41
|
+
path: this.addPath(path),
|
|
42
|
+
createIfMissing: false,
|
|
43
|
+
updater: new java_released_1.JavaReleased({ version, versionsMap }),
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
updates.push({
|
|
47
|
+
path: this.addPath(path),
|
|
48
|
+
createIfMissing: false,
|
|
49
|
+
updater: new generic_1.Generic({ version, versionsMap }),
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
return updates;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.Maven = Maven;
|
|
56
|
+
//# sourceMappingURL=maven.js.map
|
|
@@ -28,6 +28,7 @@ const tag_name_1 = require("../util/tag-name");
|
|
|
28
28
|
const pull_request_title_1 = require("../util/pull-request-title");
|
|
29
29
|
const branch_name_1 = require("../util/branch-name");
|
|
30
30
|
const pull_request_body_1 = require("../util/pull-request-body");
|
|
31
|
+
const errors_1 = require("../errors");
|
|
31
32
|
const CHANGELOG_SECTIONS = [
|
|
32
33
|
{ type: 'feat', section: 'Features' },
|
|
33
34
|
{ type: 'fix', section: 'Bug Fixes' },
|
|
@@ -89,7 +90,7 @@ class PHPYoshi extends base_1.BaseStrategy {
|
|
|
89
90
|
releaseNotesBody = updatePHPChangelogEntry(`${composer.name} ${newVersion.toString()}`, releaseNotesBody, partialReleaseNotes);
|
|
90
91
|
}
|
|
91
92
|
catch (err) {
|
|
92
|
-
if (err
|
|
93
|
+
if (err instanceof errors_1.FileNotFoundError) {
|
|
93
94
|
// if the updated path has no VERSION, assume this isn't a
|
|
94
95
|
// module that needs updating.
|
|
95
96
|
continue;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BaseStrategy, BuildUpdatesOptions, BaseStrategyOptions } from './base';
|
|
2
|
-
import { ConventionalCommit } from '../commit';
|
|
2
|
+
import { ConventionalCommit, Commit } from '../commit';
|
|
3
3
|
import { Update } from '../update';
|
|
4
4
|
import { Release } from '../release';
|
|
5
|
+
import { TagName } from '../util/tag-name';
|
|
5
6
|
import { Version } from '../version';
|
|
6
|
-
import { PullRequestBody } from '../util/pull-request-body';
|
|
7
7
|
interface RubyYoshiStrategyOptions extends BaseStrategyOptions {
|
|
8
8
|
versionFile?: string;
|
|
9
9
|
}
|
|
@@ -12,6 +12,6 @@ export declare class RubyYoshi extends BaseStrategy {
|
|
|
12
12
|
constructor(options: RubyYoshiStrategyOptions);
|
|
13
13
|
protected buildUpdates(options: BuildUpdatesOptions): Promise<Update[]>;
|
|
14
14
|
protected postProcessCommits(commits: ConventionalCommit[]): Promise<ConventionalCommit[]>;
|
|
15
|
-
protected
|
|
15
|
+
protected buildReleaseNotes(conventionalCommits: ConventionalCommit[], newVersion: Version, newVersionTag: TagName, latestRelease?: Release, commits?: Commit[]): Promise<string>;
|
|
16
16
|
}
|
|
17
17
|
export {};
|
|
@@ -22,9 +22,6 @@ const version_rb_1 = require("../updaters/ruby/version-rb");
|
|
|
22
22
|
const base_1 = require("./base");
|
|
23
23
|
const fs_1 = require("fs");
|
|
24
24
|
const path_1 = require("path");
|
|
25
|
-
const manifest_1 = require("../manifest");
|
|
26
|
-
const logger_1 = require("../util/logger");
|
|
27
|
-
const pull_request_body_1 = require("../util/pull-request-body");
|
|
28
25
|
const CHANGELOG_SECTIONS = [
|
|
29
26
|
{ type: 'feat', section: 'Features' },
|
|
30
27
|
{ type: 'fix', section: 'Bug Fixes' },
|
|
@@ -80,49 +77,17 @@ class RubyYoshi extends base_1.BaseStrategy {
|
|
|
80
77
|
});
|
|
81
78
|
return commits;
|
|
82
79
|
}
|
|
83
|
-
async
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const splitMessage = commit.message.split('\n');
|
|
95
|
-
summary += `* [${splitMessage[0]}](https://github.com/${repoUrl}/commit/${commit.sha})\n`;
|
|
96
|
-
if (splitMessage.length > 2) {
|
|
97
|
-
summary = `${summary}<pre><code>${splitMessage
|
|
98
|
-
.slice(1)
|
|
99
|
-
.join('\n')}</code></pre>\n`;
|
|
100
|
-
}
|
|
101
|
-
if (commit.files === undefined) {
|
|
102
|
-
logger_1.logger.error('No files for commit - this is likely a bug.');
|
|
103
|
-
continue;
|
|
104
|
-
}
|
|
105
|
-
commit.files.forEach(file => {
|
|
106
|
-
if (this.path === manifest_1.ROOT_PROJECT_PATH || file.startsWith(this.path)) {
|
|
107
|
-
updatedFiles[file] = true;
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
// summarize the files that changed:
|
|
112
|
-
summary = `${summary}\n### Files edited since last release:\n\n<pre><code>`;
|
|
113
|
-
Object.keys(updatedFiles).forEach(file => {
|
|
114
|
-
summary += `${file}\n`;
|
|
115
|
-
});
|
|
116
|
-
summary += `</code></pre>\n[Compare Changes](https://github.com/${repoUrl}/compare/${latestRelease.sha}...HEAD)\n`;
|
|
117
|
-
return new pull_request_body_1.PullRequestBody([
|
|
118
|
-
{
|
|
119
|
-
component,
|
|
120
|
-
version: newVersion,
|
|
121
|
-
notes: releaseNotesBody,
|
|
122
|
-
},
|
|
123
|
-
], {
|
|
124
|
-
extra: summary,
|
|
125
|
-
});
|
|
80
|
+
async buildReleaseNotes(conventionalCommits, newVersion, newVersionTag, latestRelease, commits) {
|
|
81
|
+
const releaseNotes = await super.buildReleaseNotes(conventionalCommits, newVersion, newVersionTag, latestRelease, commits);
|
|
82
|
+
return (releaseNotes
|
|
83
|
+
// Remove links in version title line and standardize on h3
|
|
84
|
+
.replace(/^###? \[([\d.]+)\]\([^)]*\)/gm, '### $1')
|
|
85
|
+
// Remove PR and commit links from pull request title suffixes
|
|
86
|
+
.replace(/ \(\[#\d+\]\([^)]*\)\)( \(\[\w+\]\([^)]*\)\))?\s*$/gm, '')
|
|
87
|
+
// Standardize on h4 for change type subheaders
|
|
88
|
+
.replace(/^### (Features|Bug Fixes|Documentation)$/gm, '#### $1')
|
|
89
|
+
// Collapse 2 or more blank lines
|
|
90
|
+
.replace(/\n{3,}/g, '\n\n'));
|
|
126
91
|
}
|
|
127
92
|
}
|
|
128
93
|
exports.RubyYoshi = RubyYoshi;
|
package/build/src/strategy.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { PullRequest } from './pull-request';
|
|
|
4
4
|
import { Commit } from './commit';
|
|
5
5
|
import { VersioningStrategy } from './versioning-strategy';
|
|
6
6
|
import { ChangelogNotes } from './changelog-notes';
|
|
7
|
+
import { Version } from './version';
|
|
7
8
|
/**
|
|
8
9
|
* A strategy is responsible for determining which files are
|
|
9
10
|
* necessary to update in a release pull request.
|
|
@@ -35,4 +36,10 @@ export interface Strategy {
|
|
|
35
36
|
* @returns {string}
|
|
36
37
|
*/
|
|
37
38
|
getComponent(): Promise<string | undefined>;
|
|
39
|
+
/**
|
|
40
|
+
* Validate whether version is a valid release.
|
|
41
|
+
* @param version Released version.
|
|
42
|
+
* @returns true of release is valid, false if it should be skipped.
|
|
43
|
+
*/
|
|
44
|
+
isPublishedVersion?(version: Version): boolean;
|
|
38
45
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Updater } from '../update';
|
|
2
|
+
/**
|
|
3
|
+
* Base class for all updaters working with XML files.
|
|
4
|
+
*/
|
|
5
|
+
export declare abstract class BaseXml implements Updater {
|
|
6
|
+
/**
|
|
7
|
+
* Given initial file contents, return updated contents.
|
|
8
|
+
* @param {string} content The initial content
|
|
9
|
+
* @returns {string} The updated content
|
|
10
|
+
*/
|
|
11
|
+
updateContent(content: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* Updates the document in-place if needed.
|
|
14
|
+
* @param document Document to be modified.
|
|
15
|
+
* @return true if document has been changed and therefore file needs to be changed, false otherwise.
|
|
16
|
+
* @protected
|
|
17
|
+
*/
|
|
18
|
+
protected abstract updateDocument(document: Document): boolean;
|
|
19
|
+
}
|