release-please 13.8.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 +7 -0
- package/README.md +9 -6
- package/build/src/bin/release-please.d.ts +1 -0
- package/build/src/bin/release-please.js +8 -0
- package/build/src/factory.d.ts +1 -1
- package/build/src/factory.js +22 -1
- package/build/src/manifest.d.ts +14 -1
- package/build/src/manifest.js +33 -23
- package/build/src/strategies/base.d.ts +3 -3
- package/build/src/strategies/base.js +12 -5
- 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/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/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/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
[1]: https://www.npmjs.com/package/release-please?activeTab=versions
|
|
6
6
|
|
|
7
|
+
## [13.9.0](https://github.com/googleapis/release-please/compare/v13.8.1...v13.9.0) (2022-04-12)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* added java strategy ([#1333](https://github.com/googleapis/release-please/issues/1333)) ([25f9c85](https://github.com/googleapis/release-please/commit/25f9c85a8472208a83dfd5cc4014c84adc3c771f))
|
|
13
|
+
|
|
7
14
|
### [13.8.1](https://github.com/googleapis/release-please/compare/v13.8.0...v13.8.1) (2022-04-11)
|
|
8
15
|
|
|
9
16
|
|
package/README.md
CHANGED
|
@@ -32,9 +32,10 @@ When the Release PR is merged, release-please takes the following steps:
|
|
|
32
32
|
You can tell where the Release PR is its lifecycle by the status label on the
|
|
33
33
|
PR itself:
|
|
34
34
|
|
|
35
|
-
- `autorelease:pending` is the initial state of the Release PR before it is merged
|
|
36
|
-
- `autorelease:tagged` means that the Release PR has been merged and the release has been tagged in GitHub
|
|
37
|
-
- `autorelease:
|
|
35
|
+
- `autorelease: pending` is the initial state of the Release PR before it is merged
|
|
36
|
+
- `autorelease: tagged` means that the Release PR has been merged and the release has been tagged in GitHub
|
|
37
|
+
- `autorelease: snapshot` is special state for snapshot version bumps
|
|
38
|
+
- `autorelease: published` means that a GitHub release has been published based on the Release PR (_release-please does not automatically add this tag, but we recommend it as a convention for publication tooling_).
|
|
38
39
|
|
|
39
40
|
## How should I write my commits?
|
|
40
41
|
|
|
@@ -112,7 +113,7 @@ commit message instead of the merged commit message.
|
|
|
112
113
|
## Release Please bot does not create a release PR. Why?
|
|
113
114
|
|
|
114
115
|
Release Please creates a release pull request after it sees the default branch
|
|
115
|
-
contains "
|
|
116
|
+
contains "releasable units" since the last release.
|
|
116
117
|
A releasable unit is a commit to the branch with one of the following
|
|
117
118
|
prefixes: "feat" and "fix". (A "chore" commit is not a releasable unit.)
|
|
118
119
|
|
|
@@ -123,13 +124,15 @@ Some languages have their specific releasable unit configuration. For example,
|
|
|
123
124
|
|
|
124
125
|
Release Please automates releases for the following flavors of repositories:
|
|
125
126
|
|
|
126
|
-
| release type
|
|
127
|
-
|
|
127
|
+
| release type | description |
|
|
128
|
+
|---------------------|---------------------------------------------------------|
|
|
128
129
|
| `dart` | A repository with a pubspec.yaml and a CHANGELOG.md |
|
|
129
130
|
| `elixir` | A repository with a mix.exs and a CHANGELOG.md |
|
|
130
131
|
| `go` | A repository with a CHANGELOG.md |
|
|
131
132
|
| `helm` | A repository with a Chart.yaml and a CHANGELOG.md |
|
|
133
|
+
| `java` | [A strategy that generates SNAPSHOT version after each release](docs/java.md) |
|
|
132
134
|
| `krm-blueprint` | [A kpt package, with 1 or more KRM files and a CHANGELOG.md](https://github.com/GoogleCloudPlatform/blueprints/tree/main/catalog/project) |
|
|
135
|
+
| `maven` | [Strategy for Maven projects, generates SNAPSHOT version after each release and updates `pom.xml` automatically](docs/java.md) |
|
|
133
136
|
| `node` | [A Node.js repository, with a package.json and CHANGELOG.md](https://github.com/yargs/yargs) |
|
|
134
137
|
| `ocaml` | [An OCaml repository, containing 1 or more opam or esy files and a CHANGELOG.md](https://github.com/grain-lang/binaryen.ml) |
|
|
135
138
|
| `php` | A repository with a composer.json and a CHANGELOG.md |
|
|
@@ -91,6 +91,11 @@ function releaseOptions(yargs) {
|
|
|
91
91
|
describe: 'set a pull request label other than "autorelease: tagged"',
|
|
92
92
|
default: 'autorelease: tagged',
|
|
93
93
|
type: 'string',
|
|
94
|
+
})
|
|
95
|
+
.option('snapshot-label', {
|
|
96
|
+
describe: 'set a java snapshot pull request label other than "autorelease: snapshot"',
|
|
97
|
+
default: 'autorelease: snapshot',
|
|
98
|
+
type: 'string',
|
|
94
99
|
});
|
|
95
100
|
}
|
|
96
101
|
function pullRequestOptions(yargs) {
|
|
@@ -505,6 +510,9 @@ function extractManifestOptions(argv) {
|
|
|
505
510
|
if ('releaseLabel' in argv && argv.releaseLabel) {
|
|
506
511
|
manifestOptions.releaseLabels = argv.releaseLabel.split(',');
|
|
507
512
|
}
|
|
513
|
+
if ('snapshotLabel' in argv && argv.snapshotLabel) {
|
|
514
|
+
manifestOptions.snapshotLabels = argv.snapshotLabel.split(',');
|
|
515
|
+
}
|
|
508
516
|
if ('signoff' in argv && argv.signoff) {
|
|
509
517
|
manifestOptions.signoff = argv.signoff;
|
|
510
518
|
}
|
package/build/src/factory.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { GitHub } from './github';
|
|
|
3
3
|
import { ReleaserConfig, PluginType, RepositoryConfig } from './manifest';
|
|
4
4
|
import { ManifestPlugin } from './plugin';
|
|
5
5
|
import { ChangelogNotes, ChangelogSection } from './changelog-notes';
|
|
6
|
-
declare const allReleaseTypes: readonly ["dart", "dotnet-yoshi", "elixir", "go", "go-yoshi", "helm", "java-backport", "java-bom", "java-lts", "java-yoshi", "krm-blueprint", "node", "ocaml", "php", "php-yoshi", "python", "ruby", "ruby-yoshi", "rust", "simple", "terraform-module"];
|
|
6
|
+
declare const allReleaseTypes: readonly ["dart", "dotnet-yoshi", "elixir", "go", "go-yoshi", "helm", "java", "java-backport", "java-bom", "java-lts", "java-yoshi", "krm-blueprint", "maven", "node", "ocaml", "php", "php-yoshi", "python", "ruby", "ruby-yoshi", "rust", "simple", "terraform-module"];
|
|
7
7
|
export declare type ReleaseType = typeof allReleaseTypes[number];
|
|
8
8
|
export declare function getReleaserTypes(): readonly ReleaseType[];
|
|
9
9
|
export declare function getVersioningStrategyTypes(): readonly VersioningStrategyType[];
|
package/build/src/factory.js
CHANGED
|
@@ -41,6 +41,8 @@ const github_1 = require("./changelog-notes/github");
|
|
|
41
41
|
const default_2 = require("./changelog-notes/default");
|
|
42
42
|
const linked_versions_1 = require("./plugins/linked-versions");
|
|
43
43
|
const dotnet_yoshi_1 = require("./strategies/dotnet-yoshi");
|
|
44
|
+
const java_1 = require("./strategies/java");
|
|
45
|
+
const maven_1 = require("./strategies/maven");
|
|
44
46
|
// Factory shared by GitHub Action and CLI for creating Release PRs
|
|
45
47
|
// and GitHub Releases:
|
|
46
48
|
// add any new releasers you create to this type as well as the `releasers`
|
|
@@ -52,11 +54,13 @@ const allReleaseTypes = [
|
|
|
52
54
|
'go',
|
|
53
55
|
'go-yoshi',
|
|
54
56
|
'helm',
|
|
57
|
+
'java',
|
|
55
58
|
'java-backport',
|
|
56
59
|
'java-bom',
|
|
57
60
|
'java-lts',
|
|
58
61
|
'java-yoshi',
|
|
59
62
|
'krm-blueprint',
|
|
63
|
+
'maven',
|
|
60
64
|
'node',
|
|
61
65
|
'ocaml',
|
|
62
66
|
'php',
|
|
@@ -72,7 +76,6 @@ const releasers = {
|
|
|
72
76
|
'dotnet-yoshi': options => new dotnet_yoshi_1.DotnetYoshi(options),
|
|
73
77
|
go: options => new go_1.Go(options),
|
|
74
78
|
'go-yoshi': options => new go_yoshi_1.GoYoshi(options),
|
|
75
|
-
'java-yoshi': options => new java_yoshi_1.JavaYoshi(options),
|
|
76
79
|
'krm-blueprint': options => new krm_blueprint_1.KRMBlueprint(options),
|
|
77
80
|
node: options => new node_1.Node(options),
|
|
78
81
|
ocaml: options => new ocaml_1.OCaml(options),
|
|
@@ -142,6 +145,24 @@ async function buildStrategy(options) {
|
|
|
142
145
|
versionFile: options.versionFile,
|
|
143
146
|
});
|
|
144
147
|
}
|
|
148
|
+
case 'java': {
|
|
149
|
+
return new java_1.Java({
|
|
150
|
+
...strategyOptions,
|
|
151
|
+
snapshotLabels: options.snapshotLabels,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
case 'maven': {
|
|
155
|
+
return new maven_1.Maven({
|
|
156
|
+
...strategyOptions,
|
|
157
|
+
snapshotLabels: options.snapshotLabels,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
case 'java-yoshi': {
|
|
161
|
+
return new java_yoshi_1.JavaYoshi({
|
|
162
|
+
...strategyOptions,
|
|
163
|
+
snapshotLabels: options.snapshotLabels,
|
|
164
|
+
});
|
|
165
|
+
}
|
|
145
166
|
case 'java-backport': {
|
|
146
167
|
return new java_yoshi_1.JavaYoshi({
|
|
147
168
|
...strategyOptions,
|
package/build/src/manifest.d.ts
CHANGED
|
@@ -15,7 +15,11 @@ declare type ExtraXmlFile = {
|
|
|
15
15
|
path: string;
|
|
16
16
|
xpath: string;
|
|
17
17
|
};
|
|
18
|
-
|
|
18
|
+
declare type ExtraPomFile = {
|
|
19
|
+
type: 'pom';
|
|
20
|
+
path: string;
|
|
21
|
+
};
|
|
22
|
+
export declare type ExtraFile = string | ExtraJsonFile | ExtraXmlFile | ExtraPomFile;
|
|
19
23
|
/**
|
|
20
24
|
* These are configurations provided to each strategy per-path.
|
|
21
25
|
*/
|
|
@@ -40,6 +44,7 @@ export interface ReleaserConfig {
|
|
|
40
44
|
changelogType?: ChangelogNotesType;
|
|
41
45
|
versionFile?: string;
|
|
42
46
|
extraFiles?: ExtraFile[];
|
|
47
|
+
snapshotLabels?: string[];
|
|
43
48
|
}
|
|
44
49
|
export interface CandidateReleasePullRequest {
|
|
45
50
|
path: string;
|
|
@@ -71,6 +76,7 @@ interface ReleaserConfigJson {
|
|
|
71
76
|
'tag-separator'?: string;
|
|
72
77
|
'version-file'?: string;
|
|
73
78
|
'extra-files'?: string[];
|
|
79
|
+
'snapshot-label'?: string;
|
|
74
80
|
}
|
|
75
81
|
export interface ManifestOptions {
|
|
76
82
|
bootstrapSha?: string;
|
|
@@ -83,6 +89,7 @@ export interface ManifestOptions {
|
|
|
83
89
|
manifestPath?: string;
|
|
84
90
|
labels?: string[];
|
|
85
91
|
releaseLabels?: string[];
|
|
92
|
+
snapshotLabels?: string[];
|
|
86
93
|
draft?: boolean;
|
|
87
94
|
prerelease?: boolean;
|
|
88
95
|
draftPullRequest?: boolean;
|
|
@@ -117,6 +124,11 @@ export declare type RepositoryConfig = Record<string, ReleaserConfig>;
|
|
|
117
124
|
export declare const DEFAULT_RELEASE_PLEASE_CONFIG = "release-please-config.json";
|
|
118
125
|
export declare const DEFAULT_RELEASE_PLEASE_MANIFEST = ".release-please-manifest.json";
|
|
119
126
|
export declare const ROOT_PROJECT_PATH = ".";
|
|
127
|
+
export declare const DEFAULT_COMPONENT_NAME = "";
|
|
128
|
+
export declare const DEFAULT_LABELS: string[];
|
|
129
|
+
export declare const DEFAULT_RELEASE_LABELS: string[];
|
|
130
|
+
export declare const DEFAULT_SNAPSHOT_LABELS: string[];
|
|
131
|
+
export declare const SNOOZE_LABEL = "autorelease: snooze";
|
|
120
132
|
export declare const MANIFEST_PULL_REQUEST_TITLE_PATTERN = "chore: release ${branch}";
|
|
121
133
|
interface CreatedRelease extends GitHubRelease {
|
|
122
134
|
path: string;
|
|
@@ -136,6 +148,7 @@ export declare class Manifest {
|
|
|
136
148
|
private signoffUser?;
|
|
137
149
|
private labels;
|
|
138
150
|
private releaseLabels;
|
|
151
|
+
private snapshotLabels;
|
|
139
152
|
private plugins;
|
|
140
153
|
private _strategiesByPath?;
|
|
141
154
|
private _pathsByComponent?;
|
package/build/src/manifest.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
// See the License for the specific language governing permissions and
|
|
14
14
|
// limitations under the License.
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.Manifest = exports.MANIFEST_PULL_REQUEST_TITLE_PATTERN = exports.ROOT_PROJECT_PATH = exports.DEFAULT_RELEASE_PLEASE_MANIFEST = exports.DEFAULT_RELEASE_PLEASE_CONFIG = void 0;
|
|
16
|
+
exports.Manifest = exports.MANIFEST_PULL_REQUEST_TITLE_PATTERN = exports.SNOOZE_LABEL = exports.DEFAULT_SNAPSHOT_LABELS = exports.DEFAULT_RELEASE_LABELS = exports.DEFAULT_LABELS = exports.DEFAULT_COMPONENT_NAME = exports.ROOT_PROJECT_PATH = exports.DEFAULT_RELEASE_PLEASE_MANIFEST = exports.DEFAULT_RELEASE_PLEASE_CONFIG = void 0;
|
|
17
17
|
const version_1 = require("./version");
|
|
18
18
|
const logger_1 = require("./util/logger");
|
|
19
19
|
const commit_split_1 = require("./util/commit-split");
|
|
@@ -28,10 +28,11 @@ const errors_1 = require("./errors");
|
|
|
28
28
|
exports.DEFAULT_RELEASE_PLEASE_CONFIG = 'release-please-config.json';
|
|
29
29
|
exports.DEFAULT_RELEASE_PLEASE_MANIFEST = '.release-please-manifest.json';
|
|
30
30
|
exports.ROOT_PROJECT_PATH = '.';
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
exports.DEFAULT_COMPONENT_NAME = '';
|
|
32
|
+
exports.DEFAULT_LABELS = ['autorelease: pending'];
|
|
33
|
+
exports.DEFAULT_RELEASE_LABELS = ['autorelease: tagged'];
|
|
34
|
+
exports.DEFAULT_SNAPSHOT_LABELS = ['autorelease: snapshot'];
|
|
35
|
+
exports.SNOOZE_LABEL = 'autorelease: snooze';
|
|
35
36
|
exports.MANIFEST_PULL_REQUEST_TITLE_PATTERN = 'chore: release ${branch}';
|
|
36
37
|
class Manifest {
|
|
37
38
|
/**
|
|
@@ -73,8 +74,10 @@ class Manifest {
|
|
|
73
74
|
this.fork = (manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.fork) || false;
|
|
74
75
|
this.signoffUser = manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.signoff;
|
|
75
76
|
this.releaseLabels =
|
|
76
|
-
(manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.releaseLabels) || DEFAULT_RELEASE_LABELS;
|
|
77
|
-
this.labels = (manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.labels) || DEFAULT_LABELS;
|
|
77
|
+
(manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.releaseLabels) || exports.DEFAULT_RELEASE_LABELS;
|
|
78
|
+
this.labels = (manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.labels) || exports.DEFAULT_LABELS;
|
|
79
|
+
this.snapshotLabels =
|
|
80
|
+
(manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.snapshotLabels) || exports.DEFAULT_SNAPSHOT_LABELS;
|
|
78
81
|
this.bootstrapSha = manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.bootstrapSha;
|
|
79
82
|
this.lastReleaseSha = manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.lastReleaseSha;
|
|
80
83
|
this.draft = manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.draft;
|
|
@@ -135,7 +138,7 @@ class Manifest {
|
|
|
135
138
|
});
|
|
136
139
|
const component = await strategy.getComponent();
|
|
137
140
|
const releasedVersions = {};
|
|
138
|
-
const latestVersion = await latestReleaseVersion(github, targetBranch, config.includeComponentInTag ? component : '', config.pullRequestTitlePattern);
|
|
141
|
+
const latestVersion = await latestReleaseVersion(github, targetBranch, version => isPublishedVersion(strategy, version), config.includeComponentInTag ? component : '', config.pullRequestTitlePattern);
|
|
139
142
|
if (latestVersion) {
|
|
140
143
|
releasedVersions[path] = latestVersion;
|
|
141
144
|
}
|
|
@@ -173,7 +176,7 @@ class Manifest {
|
|
|
173
176
|
logger_1.logger.warn(`Unable to parse release name: ${release.name}`);
|
|
174
177
|
continue;
|
|
175
178
|
}
|
|
176
|
-
const component = tagName.component || DEFAULT_COMPONENT_NAME;
|
|
179
|
+
const component = tagName.component || exports.DEFAULT_COMPONENT_NAME;
|
|
177
180
|
const path = pathsByComponent[component];
|
|
178
181
|
if (!path) {
|
|
179
182
|
logger_1.logger.warn(`Found release tag with component '${component}', but not configured in manifest`);
|
|
@@ -321,7 +324,9 @@ class Manifest {
|
|
|
321
324
|
const latestRelease = releasesByPath[path];
|
|
322
325
|
const releasePullRequest = await strategy.buildReleasePullRequest(pathCommits, latestRelease, (_a = config.draftPullRequest) !== null && _a !== void 0 ? _a : this.draftPullRequest, this.labels);
|
|
323
326
|
if (releasePullRequest) {
|
|
324
|
-
|
|
327
|
+
// Update manifest, but only for valid release version - this will skip SNAPSHOT from java strategy
|
|
328
|
+
if (releasePullRequest.version &&
|
|
329
|
+
isPublishedVersion(strategy, releasePullRequest.version)) {
|
|
325
330
|
const versionsMap = new Map();
|
|
326
331
|
versionsMap.set(path, releasePullRequest.version);
|
|
327
332
|
releasePullRequest.updates.push({
|
|
@@ -415,7 +420,8 @@ class Manifest {
|
|
|
415
420
|
const openPullRequests = [];
|
|
416
421
|
const generator = this.github.pullRequestIterator(this.targetBranch, 'OPEN');
|
|
417
422
|
for await (const openPullRequest of generator) {
|
|
418
|
-
if (hasAllLabels(this.labels, openPullRequest.labels)
|
|
423
|
+
if ((hasAllLabels(this.labels, openPullRequest.labels) ||
|
|
424
|
+
hasAllLabels(this.snapshotLabels, openPullRequest.labels)) &&
|
|
419
425
|
branch_name_1.BranchName.parse(openPullRequest.headBranchName) &&
|
|
420
426
|
pull_request_body_1.PullRequestBody.parse(openPullRequest.body)) {
|
|
421
427
|
openPullRequests.push(openPullRequest);
|
|
@@ -429,7 +435,7 @@ class Manifest {
|
|
|
429
435
|
const snoozedPullRequests = [];
|
|
430
436
|
const closedGenerator = this.github.pullRequestIterator(this.targetBranch, 'CLOSED');
|
|
431
437
|
for await (const closedPullRequest of closedGenerator) {
|
|
432
|
-
if (hasAllLabels([SNOOZE_LABEL], closedPullRequest.labels) &&
|
|
438
|
+
if (hasAllLabels([exports.SNOOZE_LABEL], closedPullRequest.labels) &&
|
|
433
439
|
branch_name_1.BranchName.parse(closedPullRequest.headBranchName) &&
|
|
434
440
|
pull_request_body_1.PullRequestBody.parse(closedPullRequest.body)) {
|
|
435
441
|
snoozedPullRequests.push(closedPullRequest);
|
|
@@ -480,7 +486,7 @@ class Manifest {
|
|
|
480
486
|
signoffUser: this.signoffUser,
|
|
481
487
|
});
|
|
482
488
|
// TODO: consider leaving the snooze label
|
|
483
|
-
await this.github.removeIssueLabels([SNOOZE_LABEL], snoozed.number);
|
|
489
|
+
await this.github.removeIssueLabels([exports.SNOOZE_LABEL], snoozed.number);
|
|
484
490
|
return updatedPullRequest;
|
|
485
491
|
}
|
|
486
492
|
async *findMergedReleasePullRequests() {
|
|
@@ -694,6 +700,7 @@ async function parseConfig(github, configFile, branch) {
|
|
|
694
700
|
}
|
|
695
701
|
const configLabel = config['label'];
|
|
696
702
|
const configReleaseLabel = config['release-label'];
|
|
703
|
+
const configSnapshotLabel = config['snapshot-label'];
|
|
697
704
|
const manifestOptions = {
|
|
698
705
|
bootstrapSha: config['bootstrap-sha'],
|
|
699
706
|
lastReleaseSha: config['last-release-sha'],
|
|
@@ -703,6 +710,7 @@ async function parseConfig(github, configFile, branch) {
|
|
|
703
710
|
plugins: config['plugins'],
|
|
704
711
|
labels: configLabel === undefined ? undefined : [configLabel],
|
|
705
712
|
releaseLabels: configReleaseLabel === undefined ? undefined : [configReleaseLabel],
|
|
713
|
+
snapshotLabels: configSnapshotLabel === undefined ? undefined : [configSnapshotLabel],
|
|
706
714
|
};
|
|
707
715
|
return { config: repositoryConfig, options: manifestOptions };
|
|
708
716
|
}
|
|
@@ -721,16 +729,22 @@ async function parseReleasedVersions(github, manifestFile, branch) {
|
|
|
721
729
|
}
|
|
722
730
|
return releasedVersions;
|
|
723
731
|
}
|
|
732
|
+
function isPublishedVersion(strategy, version) {
|
|
733
|
+
return strategy.isPublishedVersion
|
|
734
|
+
? strategy.isPublishedVersion(version)
|
|
735
|
+
: true;
|
|
736
|
+
}
|
|
724
737
|
/**
|
|
725
738
|
* Find the most recent matching release tag on the branch we're
|
|
726
739
|
* configured for.
|
|
727
740
|
*
|
|
728
|
-
* @param
|
|
729
|
-
* @param {
|
|
730
|
-
*
|
|
741
|
+
* @param github GitHub client instance.
|
|
742
|
+
* @param {string} targetBranch Name of the scanned branch.
|
|
743
|
+
* @param releaseFilter Validator function for release version. Used to filter-out SNAPSHOT releases for Java strategy.
|
|
744
|
+
* @param {string} prefix Limit the release to a specific component.
|
|
745
|
+
* @param pullRequestTitlePattern Configured PR title pattern.
|
|
731
746
|
*/
|
|
732
|
-
async function latestReleaseVersion(github, targetBranch, prefix, pullRequestTitlePattern) {
|
|
733
|
-
var _a;
|
|
747
|
+
async function latestReleaseVersion(github, targetBranch, releaseFilter, prefix, pullRequestTitlePattern) {
|
|
734
748
|
const branchPrefix = prefix
|
|
735
749
|
? prefix.endsWith('-')
|
|
736
750
|
? prefix.replace(/-$/, '')
|
|
@@ -765,11 +779,7 @@ async function latestReleaseVersion(github, targetBranch, prefix, pullRequestTit
|
|
|
765
779
|
continue;
|
|
766
780
|
}
|
|
767
781
|
const version = pullRequestTitle.getVersion();
|
|
768
|
-
if (
|
|
769
|
-
// FIXME, don't hardcode this
|
|
770
|
-
continue;
|
|
771
|
-
}
|
|
772
|
-
if (version) {
|
|
782
|
+
if (version && releaseFilter(version)) {
|
|
773
783
|
logger_1.logger.debug(`Found latest release pull request: ${mergedPullRequest.number} version: ${version}`);
|
|
774
784
|
candidateReleaseVersions.push(version);
|
|
775
785
|
break;
|
|
@@ -59,7 +59,7 @@ export declare abstract class BaseStrategy implements Strategy {
|
|
|
59
59
|
private releaseAs?;
|
|
60
60
|
protected includeComponentInTag: boolean;
|
|
61
61
|
protected includeVInTag: boolean;
|
|
62
|
-
|
|
62
|
+
readonly pullRequestTitlePattern?: string;
|
|
63
63
|
readonly extraFiles: ExtraFile[];
|
|
64
64
|
readonly changelogNotes: ChangelogNotes;
|
|
65
65
|
protected changelogSections?: ChangelogSection[];
|
|
@@ -98,9 +98,9 @@ export declare abstract class BaseStrategy implements Strategy {
|
|
|
98
98
|
* open a pull request.
|
|
99
99
|
*/
|
|
100
100
|
buildReleasePullRequest(commits: Commit[], latestRelease?: Release, draft?: boolean, labels?: string[]): Promise<ReleasePullRequest | undefined>;
|
|
101
|
-
|
|
101
|
+
protected extraFileUpdates(version: Version, versionsMap: VersionsMap): Update[];
|
|
102
102
|
protected changelogEmpty(changelogEntry: string): boolean;
|
|
103
|
-
protected updateVersionsMap(versionsMap: VersionsMap, conventionalCommits: ConventionalCommit[]): Promise<VersionsMap>;
|
|
103
|
+
protected updateVersionsMap(versionsMap: VersionsMap, conventionalCommits: ConventionalCommit[], _newVersion: Version): Promise<VersionsMap>;
|
|
104
104
|
protected buildNewVersion(conventionalCommits: ConventionalCommit[], latestRelease?: Release): Promise<Version>;
|
|
105
105
|
protected buildVersionsMap(_conventionalCommits: ConventionalCommit[]): Promise<VersionsMap>;
|
|
106
106
|
protected parsePullRequestBody(pullRequestBody: string): Promise<PullRequestBody | undefined>;
|
|
@@ -28,6 +28,7 @@ const composite_1 = require("../updaters/composite");
|
|
|
28
28
|
const generic_1 = require("../updaters/generic");
|
|
29
29
|
const generic_json_1 = require("../updaters/generic-json");
|
|
30
30
|
const generic_xml_1 = require("../updaters/generic-xml");
|
|
31
|
+
const pom_xml_1 = require("../updaters/java/pom-xml");
|
|
31
32
|
const DEFAULT_CHANGELOG_PATH = 'CHANGELOG.md';
|
|
32
33
|
/**
|
|
33
34
|
* A strategy is responsible for determining which files are
|
|
@@ -134,7 +135,7 @@ class BaseStrategy {
|
|
|
134
135
|
return undefined;
|
|
135
136
|
}
|
|
136
137
|
const newVersion = await this.buildNewVersion(conventionalCommits, latestRelease);
|
|
137
|
-
const versionsMap = await this.updateVersionsMap(await this.buildVersionsMap(conventionalCommits), conventionalCommits);
|
|
138
|
+
const versionsMap = await this.updateVersionsMap(await this.buildVersionsMap(conventionalCommits), conventionalCommits, newVersion);
|
|
138
139
|
const component = await this.getComponent();
|
|
139
140
|
logger_1.logger.debug('component:', component);
|
|
140
141
|
const newVersionTag = new tag_name_1.TagName(newVersion, this.includeComponentInTag ? component : undefined, this.tagSeparator, this.includeVInTag);
|
|
@@ -154,7 +155,7 @@ class BaseStrategy {
|
|
|
154
155
|
versionsMap,
|
|
155
156
|
latestVersion: latestRelease === null || latestRelease === void 0 ? void 0 : latestRelease.tag.version,
|
|
156
157
|
});
|
|
157
|
-
const updatesWithExtras = composite_1.mergeUpdates(updates.concat(...this.extraFileUpdates(newVersion)));
|
|
158
|
+
const updatesWithExtras = composite_1.mergeUpdates(updates.concat(...this.extraFileUpdates(newVersion, versionsMap)));
|
|
158
159
|
const pullRequestBody = await this.buildPullRequestBody(component, newVersion, releaseNotesBody, conventionalCommits, latestRelease);
|
|
159
160
|
return {
|
|
160
161
|
title: pullRequestTitle,
|
|
@@ -166,7 +167,7 @@ class BaseStrategy {
|
|
|
166
167
|
draft: draft !== null && draft !== void 0 ? draft : false,
|
|
167
168
|
};
|
|
168
169
|
}
|
|
169
|
-
extraFileUpdates(version) {
|
|
170
|
+
extraFileUpdates(version, versionsMap) {
|
|
170
171
|
return this.extraFiles.map(extraFile => {
|
|
171
172
|
if (typeof extraFile === 'object') {
|
|
172
173
|
switch (extraFile.type) {
|
|
@@ -182,6 +183,12 @@ class BaseStrategy {
|
|
|
182
183
|
createIfMissing: false,
|
|
183
184
|
updater: new generic_xml_1.GenericXml(extraFile.xpath, version),
|
|
184
185
|
};
|
|
186
|
+
case 'pom':
|
|
187
|
+
return {
|
|
188
|
+
path: this.addPath(extraFile.path),
|
|
189
|
+
createIfMissing: false,
|
|
190
|
+
updater: new pom_xml_1.PomXml(version),
|
|
191
|
+
};
|
|
185
192
|
default:
|
|
186
193
|
throw new Error(`unsupported extraFile type: ${extraFile.type}`);
|
|
187
194
|
}
|
|
@@ -189,14 +196,14 @@ class BaseStrategy {
|
|
|
189
196
|
return {
|
|
190
197
|
path: this.addPath(extraFile),
|
|
191
198
|
createIfMissing: false,
|
|
192
|
-
updater: new generic_1.Generic({ version }),
|
|
199
|
+
updater: new generic_1.Generic({ version, versionsMap }),
|
|
193
200
|
};
|
|
194
201
|
});
|
|
195
202
|
}
|
|
196
203
|
changelogEmpty(changelogEntry) {
|
|
197
204
|
return changelogEntry.split('\n').length <= 1;
|
|
198
205
|
}
|
|
199
|
-
async updateVersionsMap(versionsMap, conventionalCommits) {
|
|
206
|
+
async updateVersionsMap(versionsMap, conventionalCommits, _newVersion) {
|
|
200
207
|
for (const versionKey of versionsMap.keys()) {
|
|
201
208
|
const version = versionsMap.get(versionKey);
|
|
202
209
|
if (!version) {
|
|
@@ -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
|
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
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
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.BaseXml = void 0;
|
|
17
|
+
const dom = require("xmldom");
|
|
18
|
+
/**
|
|
19
|
+
* Base class for all updaters working with XML files.
|
|
20
|
+
*/
|
|
21
|
+
class BaseXml {
|
|
22
|
+
/**
|
|
23
|
+
* Given initial file contents, return updated contents.
|
|
24
|
+
* @param {string} content The initial content
|
|
25
|
+
* @returns {string} The updated content
|
|
26
|
+
*/
|
|
27
|
+
updateContent(content) {
|
|
28
|
+
const document = new dom.DOMParser().parseFromString(content);
|
|
29
|
+
const updated = this.updateDocument(document);
|
|
30
|
+
if (updated) {
|
|
31
|
+
return new dom.XMLSerializer().serializeToString(document);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
return content;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.BaseXml = BaseXml;
|
|
39
|
+
//# sourceMappingURL=base-xml.js.map
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
import { Updater } from '../update';
|
|
2
1
|
import { Version } from '../version';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
private
|
|
2
|
+
import { BaseXml } from './base-xml';
|
|
3
|
+
export declare class GenericXml extends BaseXml {
|
|
4
|
+
private readonly xpath;
|
|
5
|
+
private readonly version;
|
|
6
6
|
constructor(xpath: string, version: Version);
|
|
7
|
-
|
|
8
|
-
* Given initial file contents, return updated contents.
|
|
9
|
-
* @param {string} content The initial content
|
|
10
|
-
* @returns {string} The updated content
|
|
11
|
-
*/
|
|
12
|
-
updateContent(content: string): string;
|
|
7
|
+
protected updateDocument(document: Document): boolean;
|
|
13
8
|
}
|
|
@@ -14,33 +14,24 @@
|
|
|
14
14
|
// limitations under the License.
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.GenericXml = void 0;
|
|
17
|
+
const base_xml_1 = require("./base-xml");
|
|
17
18
|
const xpath = require("xpath");
|
|
18
|
-
|
|
19
|
-
class GenericXml {
|
|
19
|
+
class GenericXml extends base_xml_1.BaseXml {
|
|
20
20
|
constructor(xpath, version) {
|
|
21
|
+
super();
|
|
21
22
|
this.xpath = xpath;
|
|
22
23
|
this.version = version;
|
|
23
24
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
* @param {string} content The initial content
|
|
27
|
-
* @returns {string} The updated content
|
|
28
|
-
*/
|
|
29
|
-
updateContent(content) {
|
|
30
|
-
const document = new dom.DOMParser().parseFromString(content);
|
|
31
|
-
const iterator = xpath.evaluate(this.xpath, document, null, 0, null);
|
|
32
|
-
let node;
|
|
25
|
+
updateDocument(document) {
|
|
26
|
+
const version = this.version.toString();
|
|
33
27
|
let updated = false;
|
|
34
|
-
|
|
35
|
-
node.textContent
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return new dom.XMLSerializer().serializeToString(document);
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
return content;
|
|
28
|
+
for (const node of xpath.select(this.xpath, document)) {
|
|
29
|
+
if (node.textContent !== version) {
|
|
30
|
+
node.textContent = version;
|
|
31
|
+
updated = true;
|
|
32
|
+
}
|
|
43
33
|
}
|
|
34
|
+
return updated;
|
|
44
35
|
}
|
|
45
36
|
}
|
|
46
37
|
exports.GenericXml = GenericXml;
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import { DefaultUpdater } from './default';
|
|
1
|
+
import { DefaultUpdater, UpdateOptions } from './default';
|
|
2
|
+
/**
|
|
3
|
+
* Options for the Generic updater.
|
|
4
|
+
*/
|
|
5
|
+
export interface GenericUpdateOptions extends UpdateOptions {
|
|
6
|
+
inlineUpdateRegex?: RegExp;
|
|
7
|
+
blockStartRegex?: RegExp;
|
|
8
|
+
blockEndRegex?: RegExp;
|
|
9
|
+
}
|
|
2
10
|
/**
|
|
3
11
|
* The Generic updater looks for well known patterns and replaces
|
|
4
12
|
* content. The well known patterns are:
|
|
@@ -7,13 +15,13 @@ import { DefaultUpdater } from './default';
|
|
|
7
15
|
* then replace a semver-looking string on that line with the next
|
|
8
16
|
* version
|
|
9
17
|
* 2. `x-release-please-major` if this string is found on the line,
|
|
10
|
-
* then replace an integer looking value with the
|
|
18
|
+
* then replace an integer looking value with the next version's
|
|
11
19
|
* major
|
|
12
20
|
* 3. `x-release-please-minor` if this string is found on the line,
|
|
13
|
-
* then replace an integer looking value with the
|
|
21
|
+
* then replace an integer looking value with the next version's
|
|
14
22
|
* minor
|
|
15
23
|
* 4. `x-release-please-patch` if this string is found on the line,
|
|
16
|
-
* then replace an integer looking value with the
|
|
24
|
+
* then replace an integer looking value with the next version's
|
|
17
25
|
* patch
|
|
18
26
|
*
|
|
19
27
|
* You can also use a block-based replacement. Content between the
|
|
@@ -23,6 +31,10 @@ import { DefaultUpdater } from './default';
|
|
|
23
31
|
* numbers
|
|
24
32
|
*/
|
|
25
33
|
export declare class Generic extends DefaultUpdater {
|
|
34
|
+
private readonly inlineUpdateRegex;
|
|
35
|
+
private readonly blockStartRegex;
|
|
36
|
+
private readonly blockEndRegex;
|
|
37
|
+
constructor(options: GenericUpdateOptions);
|
|
26
38
|
/**
|
|
27
39
|
* Given initial file contents, return updated contents.
|
|
28
40
|
* @param {string} content The initial content
|
|
@@ -29,13 +29,13 @@ const BLOCK_END_REGEX = /x-release-please-end/;
|
|
|
29
29
|
* then replace a semver-looking string on that line with the next
|
|
30
30
|
* version
|
|
31
31
|
* 2. `x-release-please-major` if this string is found on the line,
|
|
32
|
-
* then replace an integer looking value with the
|
|
32
|
+
* then replace an integer looking value with the next version's
|
|
33
33
|
* major
|
|
34
34
|
* 3. `x-release-please-minor` if this string is found on the line,
|
|
35
|
-
* then replace an integer looking value with the
|
|
35
|
+
* then replace an integer looking value with the next version's
|
|
36
36
|
* minor
|
|
37
37
|
* 4. `x-release-please-patch` if this string is found on the line,
|
|
38
|
-
* then replace an integer looking value with the
|
|
38
|
+
* then replace an integer looking value with the next version's
|
|
39
39
|
* patch
|
|
40
40
|
*
|
|
41
41
|
* You can also use a block-based replacement. Content between the
|
|
@@ -45,6 +45,13 @@ const BLOCK_END_REGEX = /x-release-please-end/;
|
|
|
45
45
|
* numbers
|
|
46
46
|
*/
|
|
47
47
|
class Generic extends default_1.DefaultUpdater {
|
|
48
|
+
constructor(options) {
|
|
49
|
+
var _a, _b, _c;
|
|
50
|
+
super(options);
|
|
51
|
+
this.inlineUpdateRegex = (_a = options.inlineUpdateRegex) !== null && _a !== void 0 ? _a : INLINE_UPDATE_REGEX;
|
|
52
|
+
this.blockStartRegex = (_b = options.blockStartRegex) !== null && _b !== void 0 ? _b : BLOCK_START_REGEX;
|
|
53
|
+
this.blockEndRegex = (_c = options.blockEndRegex) !== null && _c !== void 0 ? _c : BLOCK_END_REGEX;
|
|
54
|
+
}
|
|
48
55
|
/**
|
|
49
56
|
* Given initial file contents, return updated contents.
|
|
50
57
|
* @param {string} content The initial content
|
|
@@ -77,7 +84,7 @@ class Generic extends default_1.DefaultUpdater {
|
|
|
77
84
|
}
|
|
78
85
|
content.split(/\r?\n/).forEach(line => {
|
|
79
86
|
var _a, _b;
|
|
80
|
-
let match = line.match(
|
|
87
|
+
let match = line.match(this.inlineUpdateRegex);
|
|
81
88
|
if (match) {
|
|
82
89
|
// replace inline versions
|
|
83
90
|
replaceVersion(line, (((_a = match.groups) === null || _a === void 0 ? void 0 : _a.scope) || 'version'), this.version);
|
|
@@ -85,13 +92,13 @@ class Generic extends default_1.DefaultUpdater {
|
|
|
85
92
|
else if (blockScope) {
|
|
86
93
|
// in a block, so try to replace versions
|
|
87
94
|
replaceVersion(line, blockScope, this.version);
|
|
88
|
-
if (line.match(
|
|
95
|
+
if (line.match(this.blockEndRegex)) {
|
|
89
96
|
blockScope = undefined;
|
|
90
97
|
}
|
|
91
98
|
}
|
|
92
99
|
else {
|
|
93
100
|
// look for block start line
|
|
94
|
-
match = line.match(
|
|
101
|
+
match = line.match(this.blockStartRegex);
|
|
95
102
|
if (match) {
|
|
96
103
|
if ((_b = match.groups) === null || _b === void 0 ? void 0 : _b.scope) {
|
|
97
104
|
blockScope = match.groups.scope;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Generic, GenericUpdateOptions } from '../generic';
|
|
2
|
+
/**
|
|
3
|
+
* The JavaReleased updater is used only when updating to stable (not SNAPSHOT)
|
|
4
|
+
* versions. It looks for well known patterns and replaces content.
|
|
5
|
+
* The well known patterns are:
|
|
6
|
+
*
|
|
7
|
+
* 1. `x-release-please-released-version` if this string is found on the line,
|
|
8
|
+
* then replace a semver-looking string on that line with the next
|
|
9
|
+
* version
|
|
10
|
+
* 2. `x-release-please-released-major` if this string is found on the line,
|
|
11
|
+
* then replace an integer looking value with the next version's
|
|
12
|
+
* major
|
|
13
|
+
* 3. `x-release-please-released-minor` if this string is found on the line,
|
|
14
|
+
* then replace an integer looking value with the next version's
|
|
15
|
+
* minor
|
|
16
|
+
* 4. `x-release-please-released-patch` if this string is found on the line,
|
|
17
|
+
* then replace an integer looking value with the next version's
|
|
18
|
+
* patch
|
|
19
|
+
*
|
|
20
|
+
* You can also use a block-based replacement. Content between the
|
|
21
|
+
* opening `x-release-please-released-start-version` and `x-release-please-released-end` will
|
|
22
|
+
* be considered for version replacement. You can also open these blocks
|
|
23
|
+
* with `x-release-please-released-start-<major|minor|patch>` to replace single
|
|
24
|
+
* numbers
|
|
25
|
+
*/
|
|
26
|
+
export declare class JavaReleased extends Generic {
|
|
27
|
+
constructor(options: GenericUpdateOptions);
|
|
28
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
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.JavaReleased = void 0;
|
|
17
|
+
const generic_1 = require("../generic");
|
|
18
|
+
const INLINE_UPDATE_REGEX = /x-release-please-released-(?<scope>major|minor|patch|version)/;
|
|
19
|
+
const BLOCK_START_REGEX = /x-release-please-released-start-(?<scope>major|minor|patch|version)/;
|
|
20
|
+
const BLOCK_END_REGEX = /x-release-please-released-end/;
|
|
21
|
+
const REGEX_OPTIONS = {
|
|
22
|
+
inlineUpdateRegex: INLINE_UPDATE_REGEX,
|
|
23
|
+
blockStartRegex: BLOCK_START_REGEX,
|
|
24
|
+
blockEndRegex: BLOCK_END_REGEX,
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* The JavaReleased updater is used only when updating to stable (not SNAPSHOT)
|
|
28
|
+
* versions. It looks for well known patterns and replaces content.
|
|
29
|
+
* The well known patterns are:
|
|
30
|
+
*
|
|
31
|
+
* 1. `x-release-please-released-version` if this string is found on the line,
|
|
32
|
+
* then replace a semver-looking string on that line with the next
|
|
33
|
+
* version
|
|
34
|
+
* 2. `x-release-please-released-major` if this string is found on the line,
|
|
35
|
+
* then replace an integer looking value with the next version's
|
|
36
|
+
* major
|
|
37
|
+
* 3. `x-release-please-released-minor` if this string is found on the line,
|
|
38
|
+
* then replace an integer looking value with the next version's
|
|
39
|
+
* minor
|
|
40
|
+
* 4. `x-release-please-released-patch` if this string is found on the line,
|
|
41
|
+
* then replace an integer looking value with the next version's
|
|
42
|
+
* patch
|
|
43
|
+
*
|
|
44
|
+
* You can also use a block-based replacement. Content between the
|
|
45
|
+
* opening `x-release-please-released-start-version` and `x-release-please-released-end` will
|
|
46
|
+
* be considered for version replacement. You can also open these blocks
|
|
47
|
+
* with `x-release-please-released-start-<major|minor|patch>` to replace single
|
|
48
|
+
* numbers
|
|
49
|
+
*/
|
|
50
|
+
class JavaReleased extends generic_1.Generic {
|
|
51
|
+
constructor(options) {
|
|
52
|
+
super({
|
|
53
|
+
...REGEX_OPTIONS,
|
|
54
|
+
...options,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.JavaReleased = JavaReleased;
|
|
59
|
+
//# sourceMappingURL=java-released.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Version } from '../../version';
|
|
2
|
+
import { BaseXml } from '../base-xml';
|
|
3
|
+
/**
|
|
4
|
+
* Updates version pom.xml files.
|
|
5
|
+
*
|
|
6
|
+
* If present it updates project.version element.
|
|
7
|
+
* If project.version is not present, it updates project.parent.version.
|
|
8
|
+
*/
|
|
9
|
+
export declare class PomXml extends BaseXml {
|
|
10
|
+
private readonly version;
|
|
11
|
+
constructor(version: Version);
|
|
12
|
+
protected updateDocument(document: Document): boolean;
|
|
13
|
+
private static updateNodes;
|
|
14
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
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.PomXml = void 0;
|
|
17
|
+
const base_xml_1 = require("../base-xml");
|
|
18
|
+
const xpath = require("xpath");
|
|
19
|
+
const XPATH_PROJECT_VERSION = '/*[local-name()="project"]/*[local-name()="version"]';
|
|
20
|
+
const XPATH_PROJECT_PARENT_VERSION = '/*[local-name()="project"]/*[local-name()="parent"]/*[local-name()="version"]';
|
|
21
|
+
/**
|
|
22
|
+
* Updates version pom.xml files.
|
|
23
|
+
*
|
|
24
|
+
* If present it updates project.version element.
|
|
25
|
+
* If project.version is not present, it updates project.parent.version.
|
|
26
|
+
*/
|
|
27
|
+
class PomXml extends base_xml_1.BaseXml {
|
|
28
|
+
constructor(version) {
|
|
29
|
+
super();
|
|
30
|
+
this.version = version;
|
|
31
|
+
}
|
|
32
|
+
updateDocument(document) {
|
|
33
|
+
const version = this.version.toString();
|
|
34
|
+
// NOTE this intentionally ignores namespaces - let the maven decide, what's valid and what's not
|
|
35
|
+
// Update project.version
|
|
36
|
+
const projectVersionNodes = xpath.select(XPATH_PROJECT_VERSION, document);
|
|
37
|
+
if (projectVersionNodes.length) {
|
|
38
|
+
// If found update, detect actual change
|
|
39
|
+
return PomXml.updateNodes(projectVersionNodes, version);
|
|
40
|
+
}
|
|
41
|
+
// Try updating project.parent.version
|
|
42
|
+
const parentVersionNodes = xpath.select(XPATH_PROJECT_PARENT_VERSION, document);
|
|
43
|
+
return PomXml.updateNodes(parentVersionNodes, version);
|
|
44
|
+
}
|
|
45
|
+
static updateNodes(nodes, value) {
|
|
46
|
+
const toUpdate = nodes.filter(node => node.textContent !== value);
|
|
47
|
+
toUpdate.forEach(node => (node.textContent = value));
|
|
48
|
+
return toUpdate.length > 0;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.PomXml = PomXml;
|
|
52
|
+
//# sourceMappingURL=pom-xml.js.map
|