release-please 13.8.0 → 13.10.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 CHANGED
@@ -4,6 +4,33 @@
4
4
 
5
5
  [1]: https://www.npmjs.com/package/release-please?activeTab=versions
6
6
 
7
+ ## [13.10.0](https://github.com/googleapis/release-please/compare/v13.9.0...v13.10.0) (2022-04-12)
8
+
9
+
10
+ ### Features
11
+
12
+ * enable overriding release-as ([ffa0f7c](https://github.com/googleapis/release-please/commit/ffa0f7c7b0d0d2b65ce6285b62802ac08951a43c))
13
+ * support selecting a single path when releasing from a manifest ([#1362](https://github.com/googleapis/release-please/issues/1362)) ([ffa0f7c](https://github.com/googleapis/release-please/commit/ffa0f7c7b0d0d2b65ce6285b62802ac08951a43c))
14
+
15
+
16
+ ### Bug Fixes
17
+
18
+ * **rust:** update Cargo.lock for single Rust crate ([#1374](https://github.com/googleapis/release-please/issues/1374)) ([e3571d3](https://github.com/googleapis/release-please/commit/e3571d32c44ae2bef8bac7dd8cdc3556a9d621c7))
19
+
20
+ ## [13.9.0](https://github.com/googleapis/release-please/compare/v13.8.1...v13.9.0) (2022-04-12)
21
+
22
+
23
+ ### Features
24
+
25
+ * added java strategy ([#1333](https://github.com/googleapis/release-please/issues/1333)) ([25f9c85](https://github.com/googleapis/release-please/commit/25f9c85a8472208a83dfd5cc4014c84adc3c771f))
26
+
27
+ ### [13.8.1](https://github.com/googleapis/release-please/compare/v13.8.0...v13.8.1) (2022-04-11)
28
+
29
+
30
+ ### Bug Fixes
31
+
32
+ * Restore v12 changelog formatting for ruby-yoshi ([#1361](https://github.com/googleapis/release-please/issues/1361)) ([ff87c7d](https://github.com/googleapis/release-please/commit/ff87c7df00b652512641454ead34bb2cede2f67e))
33
+
7
34
  ## [13.8.0](https://github.com/googleapis/release-please/compare/v13.7.1...v13.8.0) (2022-03-31)
8
35
 
9
36
 
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: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_).
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 "releaseable units" since the last release.
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 | description
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 |
@@ -41,6 +41,7 @@ interface ReleaseArgs {
41
41
  draft?: boolean;
42
42
  prerelease?: boolean;
43
43
  releaseLabel?: string;
44
+ snapshotLabel?: string;
44
45
  label?: string;
45
46
  }
46
47
  interface PullRequestArgs {
@@ -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) {
@@ -285,7 +290,7 @@ const createReleasePullRequestCommand = {
285
290
  }
286
291
  else {
287
292
  const manifestOptions = extractManifestOptions(argv);
288
- manifest = await manifest_1.Manifest.fromManifest(github, targetBranch, argv.configFile, argv.manifestFile, manifestOptions);
293
+ manifest = await manifest_1.Manifest.fromManifest(github, targetBranch, argv.configFile, argv.manifestFile, manifestOptions, argv.path, argv.releaseAs);
289
294
  }
290
295
  if (argv.dryRun) {
291
296
  const pullRequests = await manifest.buildPullRequests();
@@ -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
  }
@@ -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[];
@@ -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,
@@ -15,7 +15,11 @@ declare type ExtraXmlFile = {
15
15
  path: string;
16
16
  xpath: string;
17
17
  };
18
- export declare type ExtraFile = string | ExtraJsonFile | ExtraXmlFile;
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?;
@@ -179,9 +192,10 @@ export declare class Manifest {
179
192
  * @param {string} targetBranch The releaseable base branch
180
193
  * @param {string} configFile Optional. The path to the manifest config file
181
194
  * @param {string} manifestFile Optional. The path to the manifest versions file
195
+ * @param {string} path The single path to check. Optional
182
196
  * @returns {Manifest}
183
197
  */
184
- static fromManifest(github: GitHub, targetBranch: string, configFile?: string, manifestFile?: string, manifestOptionOverrides?: ManifestOptions): Promise<Manifest>;
198
+ static fromManifest(github: GitHub, targetBranch: string, configFile?: string, manifestFile?: string, manifestOptionOverrides?: ManifestOptions, path?: string, releaseAs?: string): Promise<Manifest>;
185
199
  /**
186
200
  * Create a Manifest from explicit config in code. This assumes that the
187
201
  * repository has a single component at the root path.
@@ -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
- const DEFAULT_COMPONENT_NAME = '';
32
- const DEFAULT_LABELS = ['autorelease: pending'];
33
- const DEFAULT_RELEASE_LABELS = ['autorelease: tagged'];
34
- const SNOOZE_LABEL = 'autorelease: snooze';
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;
@@ -88,11 +91,12 @@ class Manifest {
88
91
  * @param {string} targetBranch The releaseable base branch
89
92
  * @param {string} configFile Optional. The path to the manifest config file
90
93
  * @param {string} manifestFile Optional. The path to the manifest versions file
94
+ * @param {string} path The single path to check. Optional
91
95
  * @returns {Manifest}
92
96
  */
93
- static async fromManifest(github, targetBranch, configFile = exports.DEFAULT_RELEASE_PLEASE_CONFIG, manifestFile = exports.DEFAULT_RELEASE_PLEASE_MANIFEST, manifestOptionOverrides = {}) {
97
+ static async fromManifest(github, targetBranch, configFile = exports.DEFAULT_RELEASE_PLEASE_CONFIG, manifestFile = exports.DEFAULT_RELEASE_PLEASE_MANIFEST, manifestOptionOverrides = {}, path, releaseAs) {
94
98
  const [{ config: repositoryConfig, options: manifestOptions }, releasedVersions,] = await Promise.all([
95
- parseConfig(github, configFile, targetBranch),
99
+ parseConfig(github, configFile, targetBranch, path, releaseAs),
96
100
  parseReleasedVersions(github, manifestFile, targetBranch),
97
101
  ]);
98
102
  return new Manifest(github, targetBranch, repositoryConfig, releasedVersions, {
@@ -135,7 +139,7 @@ class Manifest {
135
139
  });
136
140
  const component = await strategy.getComponent();
137
141
  const releasedVersions = {};
138
- const latestVersion = await latestReleaseVersion(github, targetBranch, config.includeComponentInTag ? component : '', config.pullRequestTitlePattern);
142
+ const latestVersion = await latestReleaseVersion(github, targetBranch, version => isPublishedVersion(strategy, version), config.includeComponentInTag ? component : '', config.pullRequestTitlePattern);
139
143
  if (latestVersion) {
140
144
  releasedVersions[path] = latestVersion;
141
145
  }
@@ -173,7 +177,7 @@ class Manifest {
173
177
  logger_1.logger.warn(`Unable to parse release name: ${release.name}`);
174
178
  continue;
175
179
  }
176
- const component = tagName.component || DEFAULT_COMPONENT_NAME;
180
+ const component = tagName.component || exports.DEFAULT_COMPONENT_NAME;
177
181
  const path = pathsByComponent[component];
178
182
  if (!path) {
179
183
  logger_1.logger.warn(`Found release tag with component '${component}', but not configured in manifest`);
@@ -321,7 +325,9 @@ class Manifest {
321
325
  const latestRelease = releasesByPath[path];
322
326
  const releasePullRequest = await strategy.buildReleasePullRequest(pathCommits, latestRelease, (_a = config.draftPullRequest) !== null && _a !== void 0 ? _a : this.draftPullRequest, this.labels);
323
327
  if (releasePullRequest) {
324
- if (releasePullRequest.version) {
328
+ // Update manifest, but only for valid release version - this will skip SNAPSHOT from java strategy
329
+ if (releasePullRequest.version &&
330
+ isPublishedVersion(strategy, releasePullRequest.version)) {
325
331
  const versionsMap = new Map();
326
332
  versionsMap.set(path, releasePullRequest.version);
327
333
  releasePullRequest.updates.push({
@@ -415,7 +421,8 @@ class Manifest {
415
421
  const openPullRequests = [];
416
422
  const generator = this.github.pullRequestIterator(this.targetBranch, 'OPEN');
417
423
  for await (const openPullRequest of generator) {
418
- if (hasAllLabels(this.labels, openPullRequest.labels) &&
424
+ if ((hasAllLabels(this.labels, openPullRequest.labels) ||
425
+ hasAllLabels(this.snapshotLabels, openPullRequest.labels)) &&
419
426
  branch_name_1.BranchName.parse(openPullRequest.headBranchName) &&
420
427
  pull_request_body_1.PullRequestBody.parse(openPullRequest.body)) {
421
428
  openPullRequests.push(openPullRequest);
@@ -429,7 +436,7 @@ class Manifest {
429
436
  const snoozedPullRequests = [];
430
437
  const closedGenerator = this.github.pullRequestIterator(this.targetBranch, 'CLOSED');
431
438
  for await (const closedPullRequest of closedGenerator) {
432
- if (hasAllLabels([SNOOZE_LABEL], closedPullRequest.labels) &&
439
+ if (hasAllLabels([exports.SNOOZE_LABEL], closedPullRequest.labels) &&
433
440
  branch_name_1.BranchName.parse(closedPullRequest.headBranchName) &&
434
441
  pull_request_body_1.PullRequestBody.parse(closedPullRequest.body)) {
435
442
  snoozedPullRequests.push(closedPullRequest);
@@ -480,7 +487,7 @@ class Manifest {
480
487
  signoffUser: this.signoffUser,
481
488
  });
482
489
  // TODO: consider leaving the snooze label
483
- await this.github.removeIssueLabels([SNOOZE_LABEL], snoozed.number);
490
+ await this.github.removeIssueLabels([exports.SNOOZE_LABEL], snoozed.number);
484
491
  return updatedPullRequest;
485
492
  }
486
493
  async *findMergedReleasePullRequests() {
@@ -684,16 +691,24 @@ function extractReleaserConfig(config) {
684
691
  * @param {GitHub} github GitHub client
685
692
  * @param {string} configFile Path in the repository to the manifest config
686
693
  * @param {string} branch Branch to fetch the config file from
694
+ * @param {string} onlyPath Optional. Use only the given package
695
+ * @param {string} releaseAs Optional. Override release-as and use the given version
687
696
  */
688
- async function parseConfig(github, configFile, branch) {
697
+ async function parseConfig(github, configFile, branch, onlyPath, releaseAs) {
689
698
  const config = await github.getFileJson(configFile, branch);
690
699
  const defaultConfig = extractReleaserConfig(config);
691
700
  const repositoryConfig = {};
692
701
  for (const path in config.packages) {
702
+ if (onlyPath && onlyPath !== path)
703
+ continue;
693
704
  repositoryConfig[path] = mergeReleaserConfig(defaultConfig, extractReleaserConfig(config.packages[path]));
705
+ if (releaseAs) {
706
+ repositoryConfig[path].releaseAs = releaseAs;
707
+ }
694
708
  }
695
709
  const configLabel = config['label'];
696
710
  const configReleaseLabel = config['release-label'];
711
+ const configSnapshotLabel = config['snapshot-label'];
697
712
  const manifestOptions = {
698
713
  bootstrapSha: config['bootstrap-sha'],
699
714
  lastReleaseSha: config['last-release-sha'],
@@ -703,6 +718,7 @@ async function parseConfig(github, configFile, branch) {
703
718
  plugins: config['plugins'],
704
719
  labels: configLabel === undefined ? undefined : [configLabel],
705
720
  releaseLabels: configReleaseLabel === undefined ? undefined : [configReleaseLabel],
721
+ snapshotLabels: configSnapshotLabel === undefined ? undefined : [configSnapshotLabel],
706
722
  };
707
723
  return { config: repositoryConfig, options: manifestOptions };
708
724
  }
@@ -721,16 +737,22 @@ async function parseReleasedVersions(github, manifestFile, branch) {
721
737
  }
722
738
  return releasedVersions;
723
739
  }
740
+ function isPublishedVersion(strategy, version) {
741
+ return strategy.isPublishedVersion
742
+ ? strategy.isPublishedVersion(version)
743
+ : true;
744
+ }
724
745
  /**
725
746
  * Find the most recent matching release tag on the branch we're
726
747
  * configured for.
727
748
  *
728
- * @param {string} prefix - Limit the release to a specific component.
729
- * @param {boolean} preRelease - Whether or not to return pre-release
730
- * versions. Defaults to false.
749
+ * @param github GitHub client instance.
750
+ * @param {string} targetBranch Name of the scanned branch.
751
+ * @param releaseFilter Validator function for release version. Used to filter-out SNAPSHOT releases for Java strategy.
752
+ * @param {string} prefix Limit the release to a specific component.
753
+ * @param pullRequestTitlePattern Configured PR title pattern.
731
754
  */
732
- async function latestReleaseVersion(github, targetBranch, prefix, pullRequestTitlePattern) {
733
- var _a;
755
+ async function latestReleaseVersion(github, targetBranch, releaseFilter, prefix, pullRequestTitlePattern) {
734
756
  const branchPrefix = prefix
735
757
  ? prefix.endsWith('-')
736
758
  ? prefix.replace(/-$/, '')
@@ -765,11 +787,7 @@ async function latestReleaseVersion(github, targetBranch, prefix, pullRequestTit
765
787
  continue;
766
788
  }
767
789
  const version = pullRequestTitle.getVersion();
768
- if ((_a = version === null || version === void 0 ? void 0 : version.preRelease) === null || _a === void 0 ? void 0 : _a.includes('SNAPSHOT')) {
769
- // FIXME, don't hardcode this
770
- continue;
771
- }
772
- if (version) {
790
+ if (version && releaseFilter(version)) {
773
791
  logger_1.logger.debug(`Found latest release pull request: ${mergedPullRequest.number} version: ${version}`);
774
792
  candidateReleaseVersions.push(version);
775
793
  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
- private pullRequestTitlePattern?;
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
- private extraFileUpdates;
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 { Commit, ConventionalCommit } from '../commit';
6
- import { Release } from '../release';
7
- import { ReleasePullRequest } from '../release-pull-request';
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
- private needsSnapshot;
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 pull_request_title_1 = require("../util/pull-request-title");
26
- const branch_name_1 = require("../util/branch-name");
27
- const pull_request_body_1 = require("../util/pull-request-body");
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