@release-please-oss/release-please 0.0.0 → 17.11.3
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/LICENSE +202 -0
- package/README.md +280 -0
- package/build/src/bin/release-please.d.ts +22 -0
- package/build/src/bin/release-please.js +727 -0
- package/build/src/bootstrapper.d.ts +18 -0
- package/build/src/bootstrapper.js +64 -0
- package/build/src/changelog-notes/default.d.ts +15 -0
- package/build/src/changelog-notes/default.js +96 -0
- package/build/src/changelog-notes/github.d.ts +8 -0
- package/build/src/changelog-notes/github.js +29 -0
- package/build/src/changelog-notes.d.ts +22 -0
- package/build/src/changelog-notes.js +40 -0
- package/build/src/commit.d.ts +33 -0
- package/build/src/commit.js +422 -0
- package/build/src/errors/index.d.ts +36 -0
- package/build/src/errors/index.js +77 -0
- package/build/src/factories/changelog-notes-factory.d.ts +16 -0
- package/build/src/factories/changelog-notes-factory.js +44 -0
- package/build/src/factories/plugin-factory.d.ts +23 -0
- package/build/src/factories/plugin-factory.js +94 -0
- package/build/src/factories/versioning-strategy-factory.d.ts +16 -0
- package/build/src/factories/versioning-strategy-factory.js +52 -0
- package/build/src/factory.d.ts +18 -0
- package/build/src/factory.js +161 -0
- package/build/src/github-api.d.ts +260 -0
- package/build/src/github-api.js +714 -0
- package/build/src/github.d.ts +306 -0
- package/build/src/github.js +769 -0
- package/build/src/index.d.ts +17 -0
- package/build/src/index.js +41 -0
- package/build/src/local-github.d.ts +270 -0
- package/build/src/local-github.js +756 -0
- package/build/src/manifest.d.ts +370 -0
- package/build/src/manifest.js +1142 -0
- package/build/src/plugin.d.ts +37 -0
- package/build/src/plugin.js +57 -0
- package/build/src/plugins/cargo-workspace.d.ts +58 -0
- package/build/src/plugins/cargo-workspace.js +339 -0
- package/build/src/plugins/group-priority.d.ts +29 -0
- package/build/src/plugins/group-priority.js +82 -0
- package/build/src/plugins/linked-versions.d.ts +36 -0
- package/build/src/plugins/linked-versions.js +137 -0
- package/build/src/plugins/maven-workspace.d.ts +81 -0
- package/build/src/plugins/maven-workspace.js +431 -0
- package/build/src/plugins/merge.d.ts +27 -0
- package/build/src/plugins/merge.js +99 -0
- package/build/src/plugins/node-workspace.d.ts +50 -0
- package/build/src/plugins/node-workspace.js +352 -0
- package/build/src/plugins/sentence-case.d.ts +19 -0
- package/build/src/plugins/sentence-case.js +80 -0
- package/build/src/plugins/workspace.d.ts +173 -0
- package/build/src/plugins/workspace.js +308 -0
- package/build/src/pull-request.d.ts +11 -0
- package/build/src/pull-request.js +16 -0
- package/build/src/release-pull-request.d.ts +14 -0
- package/build/src/release-pull-request.js +16 -0
- package/build/src/release.d.ts +7 -0
- package/build/src/release.js +16 -0
- package/build/src/repository.d.ts +5 -0
- package/build/src/repository.js +16 -0
- package/build/src/scm.d.ts +80 -0
- package/build/src/scm.js +16 -0
- package/build/src/strategies/base.d.ts +162 -0
- package/build/src/strategies/base.js +494 -0
- package/build/src/strategies/bazel.d.ts +7 -0
- package/build/src/strategies/bazel.js +49 -0
- package/build/src/strategies/dart.d.ts +8 -0
- package/build/src/strategies/dart.js +73 -0
- package/build/src/strategies/dotnet-yoshi.d.ts +13 -0
- package/build/src/strategies/dotnet-yoshi.js +109 -0
- package/build/src/strategies/elixir.d.ts +5 -0
- package/build/src/strategies/elixir.js +46 -0
- package/build/src/strategies/expo.d.ts +15 -0
- package/build/src/strategies/expo.js +51 -0
- package/build/src/strategies/go-librarian.d.ts +11 -0
- package/build/src/strategies/go-librarian.js +84 -0
- package/build/src/strategies/go-yoshi.d.ts +14 -0
- package/build/src/strategies/go-yoshi.js +168 -0
- package/build/src/strategies/go.d.ts +7 -0
- package/build/src/strategies/go.js +53 -0
- package/build/src/strategies/helm.d.ts +8 -0
- package/build/src/strategies/helm.js +73 -0
- package/build/src/strategies/java-yoshi-mono-repo.d.ts +22 -0
- package/build/src/strategies/java-yoshi-mono-repo.js +308 -0
- package/build/src/strategies/java-yoshi.d.ts +20 -0
- package/build/src/strategies/java-yoshi.js +210 -0
- package/build/src/strategies/java.d.ts +28 -0
- package/build/src/strategies/java.js +176 -0
- package/build/src/strategies/krm-blueprint.d.ts +7 -0
- package/build/src/strategies/krm-blueprint.js +65 -0
- package/build/src/strategies/maven.d.ts +9 -0
- package/build/src/strategies/maven.js +56 -0
- package/build/src/strategies/node-librarian.d.ts +10 -0
- package/build/src/strategies/node-librarian.js +121 -0
- package/build/src/strategies/node.d.ts +10 -0
- package/build/src/strategies/node.js +111 -0
- package/build/src/strategies/ocaml.d.ts +5 -0
- package/build/src/strategies/ocaml.js +86 -0
- package/build/src/strategies/php-librarian.d.ts +6 -0
- package/build/src/strategies/php-librarian.js +35 -0
- package/build/src/strategies/php-yoshi.d.ts +13 -0
- package/build/src/strategies/php-yoshi.js +255 -0
- package/build/src/strategies/php.d.ts +6 -0
- package/build/src/strategies/php.js +76 -0
- package/build/src/strategies/python-librarian.d.ts +6 -0
- package/build/src/strategies/python-librarian.js +35 -0
- package/build/src/strategies/python.d.ts +11 -0
- package/build/src/strategies/python.js +175 -0
- package/build/src/strategies/r.d.ts +8 -0
- package/build/src/strategies/r.js +67 -0
- package/build/src/strategies/ruby-librarian.d.ts +6 -0
- package/build/src/strategies/ruby-librarian.js +35 -0
- package/build/src/strategies/ruby-yoshi.d.ts +13 -0
- package/build/src/strategies/ruby-yoshi.js +97 -0
- package/build/src/strategies/ruby.d.ts +9 -0
- package/build/src/strategies/ruby.js +71 -0
- package/build/src/strategies/rust.d.ts +17 -0
- package/build/src/strategies/rust.js +149 -0
- package/build/src/strategies/sfdx.d.ts +9 -0
- package/build/src/strategies/sfdx.js +67 -0
- package/build/src/strategies/simple.d.ts +7 -0
- package/build/src/strategies/simple.js +51 -0
- package/build/src/strategies/terraform-module.d.ts +7 -0
- package/build/src/strategies/terraform-module.js +90 -0
- package/build/src/strategy.d.ts +68 -0
- package/build/src/strategy.js +16 -0
- package/build/src/update.d.ts +24 -0
- package/build/src/update.js +16 -0
- package/build/src/updaters/base-xml.d.ts +19 -0
- package/build/src/updaters/base-xml.js +43 -0
- package/build/src/updaters/bazel/module-bazel.d.ts +7 -0
- package/build/src/updaters/bazel/module-bazel.js +33 -0
- package/build/src/updaters/changelog-json.d.ts +29 -0
- package/build/src/updaters/changelog-json.js +100 -0
- package/build/src/updaters/changelog.d.ts +13 -0
- package/build/src/updaters/changelog.js +55 -0
- package/build/src/updaters/composite.d.ts +20 -0
- package/build/src/updaters/composite.js +65 -0
- package/build/src/updaters/dart/pubspec-yaml.d.ts +13 -0
- package/build/src/updaters/dart/pubspec-yaml.js +50 -0
- package/build/src/updaters/default.d.ts +21 -0
- package/build/src/updaters/default.js +36 -0
- package/build/src/updaters/dotnet/apis.d.ts +18 -0
- package/build/src/updaters/dotnet/apis.js +45 -0
- package/build/src/updaters/dotnet/csproj.d.ts +12 -0
- package/build/src/updaters/dotnet/csproj.js +33 -0
- package/build/src/updaters/elixir/elixir-mix-exs.d.ts +13 -0
- package/build/src/updaters/elixir/elixir-mix-exs.js +42 -0
- package/build/src/updaters/expo/app-json.d.ts +31 -0
- package/build/src/updaters/expo/app-json.js +67 -0
- package/build/src/updaters/generic-json.d.ts +14 -0
- package/build/src/updaters/generic-json.js +54 -0
- package/build/src/updaters/generic-toml.d.ts +21 -0
- package/build/src/updaters/generic-toml.js +66 -0
- package/build/src/updaters/generic-xml.d.ts +8 -0
- package/build/src/updaters/generic-xml.js +38 -0
- package/build/src/updaters/generic-yaml.d.ts +23 -0
- package/build/src/updaters/generic-yaml.js +85 -0
- package/build/src/updaters/generic.d.ts +54 -0
- package/build/src/updaters/generic.js +187 -0
- package/build/src/updaters/go/version-go.d.ts +4 -0
- package/build/src/updaters/go/version-go.js +24 -0
- package/build/src/updaters/helm/chart-yaml.d.ts +13 -0
- package/build/src/updaters/helm/chart-yaml.js +41 -0
- 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/java-update.d.ts +21 -0
- package/build/src/updaters/java/java-update.js +80 -0
- package/build/src/updaters/java/pom-xml.d.ts +29 -0
- package/build/src/updaters/java/pom-xml.js +135 -0
- package/build/src/updaters/java/versions-manifest.d.ts +19 -0
- package/build/src/updaters/java/versions-manifest.js +71 -0
- package/build/src/updaters/krm/krm-blueprint-version.d.ts +13 -0
- package/build/src/updaters/krm/krm-blueprint-version.js +46 -0
- package/build/src/updaters/librarian-yaml.d.ts +45 -0
- package/build/src/updaters/librarian-yaml.js +149 -0
- package/build/src/updaters/node/package-json.d.ts +46 -0
- package/build/src/updaters/node/package-json.js +106 -0
- package/build/src/updaters/node/package-lock-json.d.ts +14 -0
- package/build/src/updaters/node/package-lock-json.js +83 -0
- package/build/src/updaters/node/samples-package-json.d.ts +24 -0
- package/build/src/updaters/node/samples-package-json.js +49 -0
- package/build/src/updaters/ocaml/dune-project.d.ts +13 -0
- package/build/src/updaters/ocaml/dune-project.js +37 -0
- package/build/src/updaters/ocaml/esy-json.d.ts +13 -0
- package/build/src/updaters/ocaml/esy-json.js +37 -0
- package/build/src/updaters/ocaml/opam.d.ts +13 -0
- package/build/src/updaters/ocaml/opam.js +37 -0
- package/build/src/updaters/php/php-client-version.d.ts +12 -0
- package/build/src/updaters/php/php-client-version.js +32 -0
- package/build/src/updaters/php/root-composer-update-packages.d.ts +13 -0
- package/build/src/updaters/php/root-composer-update-packages.js +60 -0
- package/build/src/updaters/python/pyproject-toml.d.ts +29 -0
- package/build/src/updaters/python/pyproject-toml.js +53 -0
- package/build/src/updaters/python/python-file-with-version.d.ts +12 -0
- package/build/src/updaters/python/python-file-with-version.js +32 -0
- package/build/src/updaters/python/setup-cfg.d.ts +12 -0
- package/build/src/updaters/python/setup-cfg.js +32 -0
- package/build/src/updaters/python/setup-py.d.ts +12 -0
- package/build/src/updaters/python/setup-py.js +32 -0
- package/build/src/updaters/r/description.d.ts +12 -0
- package/build/src/updaters/r/description.js +32 -0
- package/build/src/updaters/r/news.d.ts +12 -0
- package/build/src/updaters/r/news.js +49 -0
- package/build/src/updaters/raw-content.d.ts +19 -0
- package/build/src/updaters/raw-content.js +39 -0
- package/build/src/updaters/release-please-config.d.ts +8 -0
- package/build/src/updaters/release-please-config.js +80 -0
- package/build/src/updaters/release-please-manifest.d.ts +4 -0
- package/build/src/updaters/release-please-manifest.js +34 -0
- package/build/src/updaters/ruby/common.d.ts +17 -0
- package/build/src/updaters/ruby/common.js +46 -0
- package/build/src/updaters/ruby/gemfile-lock.d.ts +24 -0
- package/build/src/updaters/ruby/gemfile-lock.js +53 -0
- package/build/src/updaters/ruby/version-rb.d.ts +12 -0
- package/build/src/updaters/ruby/version-rb.js +34 -0
- package/build/src/updaters/rust/cargo-lock.d.ts +16 -0
- package/build/src/updaters/rust/cargo-lock.js +64 -0
- package/build/src/updaters/rust/cargo-toml.d.ts +13 -0
- package/build/src/updaters/rust/cargo-toml.js +89 -0
- package/build/src/updaters/rust/common.d.ts +54 -0
- package/build/src/updaters/rust/common.js +35 -0
- package/build/src/updaters/sfdx/sfdx-project-json.d.ts +21 -0
- package/build/src/updaters/sfdx/sfdx-project-json.js +41 -0
- package/build/src/updaters/terraform/metadata-version.d.ts +13 -0
- package/build/src/updaters/terraform/metadata-version.js +37 -0
- package/build/src/updaters/terraform/module-version.d.ts +13 -0
- package/build/src/updaters/terraform/module-version.js +37 -0
- package/build/src/updaters/terraform/readme.d.ts +12 -0
- package/build/src/updaters/terraform/readme.js +32 -0
- package/build/src/util/branch-name.d.ts +20 -0
- package/build/src/util/branch-name.js +225 -0
- package/build/src/util/code-suggester/default-options-handler.d.ts +10 -0
- package/build/src/util/code-suggester/default-options-handler.js +45 -0
- package/build/src/util/code-suggester/errors.d.ts +4 -0
- package/build/src/util/code-suggester/errors.js +24 -0
- package/build/src/util/code-suggester/github/branch.d.ts +45 -0
- package/build/src/util/code-suggester/github/branch.js +118 -0
- package/build/src/util/code-suggester/github/commit-and-push.d.ts +51 -0
- package/build/src/util/code-suggester/github/commit-and-push.js +141 -0
- package/build/src/util/code-suggester/github/create-commit.d.ts +20 -0
- package/build/src/util/code-suggester/github/create-commit.js +60 -0
- package/build/src/util/code-suggester/github/fork.d.ts +15 -0
- package/build/src/util/code-suggester/github/fork.js +48 -0
- package/build/src/util/code-suggester/github/labels.d.ts +14 -0
- package/build/src/util/code-suggester/github/labels.js +42 -0
- package/build/src/util/code-suggester/github/open-pull-request.d.ts +16 -0
- package/build/src/util/code-suggester/github/open-pull-request.js +56 -0
- package/build/src/util/code-suggester/index.d.ts +28 -0
- package/build/src/util/code-suggester/index.js +110 -0
- package/build/src/util/code-suggester/logger.d.ts +4 -0
- package/build/src/util/code-suggester/logger.js +37 -0
- package/build/src/util/code-suggester/types.d.ts +109 -0
- package/build/src/util/code-suggester/types.js +30 -0
- package/build/src/util/coerce-option.d.ts +1 -0
- package/build/src/util/coerce-option.js +40 -0
- package/build/src/util/commit-exclude.d.ts +10 -0
- package/build/src/util/commit-exclude.js +49 -0
- package/build/src/util/commit-split.d.ts +26 -0
- package/build/src/util/commit-split.js +100 -0
- package/build/src/util/commit-utils.d.ts +1 -0
- package/build/src/util/commit-utils.js +34 -0
- package/build/src/util/filter-commits.d.ts +12 -0
- package/build/src/util/filter-commits.js +59 -0
- package/build/src/util/indent-commit.d.ts +2 -0
- package/build/src/util/indent-commit.js +39 -0
- package/build/src/util/json-stringify.d.ts +1 -0
- package/build/src/util/json-stringify.js +22 -0
- package/build/src/util/logger.d.ts +24 -0
- package/build/src/util/logger.js +54 -0
- package/build/src/util/pull-request-body.d.ts +25 -0
- package/build/src/util/pull-request-body.js +147 -0
- package/build/src/util/pull-request-overflow-handler.d.ts +54 -0
- package/build/src/util/pull-request-overflow-handler.js +78 -0
- package/build/src/util/pull-request-title.d.ts +22 -0
- package/build/src/util/pull-request-title.js +146 -0
- package/build/src/util/signoff-commit-message.d.ts +1 -0
- package/build/src/util/signoff-commit-message.js +35 -0
- package/build/src/util/tag-name.d.ts +10 -0
- package/build/src/util/tag-name.js +42 -0
- package/build/src/util/toml-edit.d.ts +16 -0
- package/build/src/util/toml-edit.js +126 -0
- package/build/src/version.d.ts +35 -0
- package/build/src/version.js +74 -0
- package/build/src/versioning-strategies/always-bump-major.d.ts +10 -0
- package/build/src/versioning-strategies/always-bump-major.js +28 -0
- package/build/src/versioning-strategies/always-bump-minor.d.ts +10 -0
- package/build/src/versioning-strategies/always-bump-minor.js +28 -0
- package/build/src/versioning-strategies/always-bump-patch.d.ts +11 -0
- package/build/src/versioning-strategies/always-bump-patch.js +29 -0
- package/build/src/versioning-strategies/default.d.ts +48 -0
- package/build/src/versioning-strategies/default.js +102 -0
- package/build/src/versioning-strategies/dependency-manifest.d.ts +15 -0
- package/build/src/versioning-strategies/dependency-manifest.js +103 -0
- package/build/src/versioning-strategies/java-add-snapshot.d.ts +13 -0
- package/build/src/versioning-strategies/java-add-snapshot.js +54 -0
- package/build/src/versioning-strategies/java-snapshot.d.ts +13 -0
- package/build/src/versioning-strategies/java-snapshot.js +70 -0
- package/build/src/versioning-strategies/prerelease.d.ts +20 -0
- package/build/src/versioning-strategies/prerelease.js +163 -0
- package/build/src/versioning-strategies/service-pack.d.ts +12 -0
- package/build/src/versioning-strategies/service-pack.js +47 -0
- package/build/src/versioning-strategy.d.ts +90 -0
- package/build/src/versioning-strategy.js +82 -0
- package/package.json +113 -4
- package/schemas/config.json +513 -0
- package/schemas/manifest.json +9 -0
- package/templates/commit.hbs +2 -0
- package/templates/header.hbs +9 -0
- package/templates/template.hbs +19 -0
|
@@ -0,0 +1,1142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2021 Google LLC
|
|
3
|
+
//
|
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
// you may not use this file except in compliance with the License.
|
|
6
|
+
// You may obtain a copy of the License at
|
|
7
|
+
//
|
|
8
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
//
|
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
// See the License for the specific language governing permissions and
|
|
14
|
+
// limitations under the License.
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.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
|
+
const version_1 = require("./version");
|
|
18
|
+
const commit_1 = require("./commit");
|
|
19
|
+
const logger_1 = require("./util/logger");
|
|
20
|
+
const commit_split_1 = require("./util/commit-split");
|
|
21
|
+
const tag_name_1 = require("./util/tag-name");
|
|
22
|
+
const branch_name_1 = require("./util/branch-name");
|
|
23
|
+
const pull_request_title_1 = require("./util/pull-request-title");
|
|
24
|
+
const factory_1 = require("./factory");
|
|
25
|
+
const merge_1 = require("./plugins/merge");
|
|
26
|
+
const release_please_manifest_1 = require("./updaters/release-please-manifest");
|
|
27
|
+
const errors_1 = require("./errors");
|
|
28
|
+
const pull_request_overflow_handler_1 = require("./util/pull-request-overflow-handler");
|
|
29
|
+
const signoff_commit_message_1 = require("./util/signoff-commit-message");
|
|
30
|
+
const commit_exclude_1 = require("./util/commit-exclude");
|
|
31
|
+
exports.DEFAULT_RELEASE_PLEASE_CONFIG = 'release-please-config.json';
|
|
32
|
+
exports.DEFAULT_RELEASE_PLEASE_MANIFEST = '.release-please-manifest.json';
|
|
33
|
+
exports.ROOT_PROJECT_PATH = '.';
|
|
34
|
+
exports.DEFAULT_COMPONENT_NAME = '';
|
|
35
|
+
exports.DEFAULT_LABELS = ['autorelease: pending'];
|
|
36
|
+
exports.DEFAULT_RELEASE_LABELS = ['autorelease: tagged'];
|
|
37
|
+
exports.DEFAULT_SNAPSHOT_LABELS = ['autorelease: snapshot'];
|
|
38
|
+
exports.SNOOZE_LABEL = 'autorelease: snooze';
|
|
39
|
+
const DEFAULT_RELEASE_SEARCH_DEPTH = 400;
|
|
40
|
+
const DEFAULT_COMMIT_SEARCH_DEPTH = 500;
|
|
41
|
+
const DEFAULT_COMMIT_BATCH_SIZE = 10;
|
|
42
|
+
exports.MANIFEST_PULL_REQUEST_TITLE_PATTERN = 'chore: release ${branch}';
|
|
43
|
+
class Manifest {
|
|
44
|
+
/**
|
|
45
|
+
* Create a Manifest from explicit config in code. This assumes that the
|
|
46
|
+
* repository has a single component at the root path.
|
|
47
|
+
*
|
|
48
|
+
* @param {GitHub} github GitHub client
|
|
49
|
+
* @param {string} targetBranch The releaseable base branch
|
|
50
|
+
* @param {RepositoryConfig} repositoryConfig Parsed configuration of path => release configuration
|
|
51
|
+
* @param {ReleasedVersions} releasedVersions Parsed versions of path => latest release version
|
|
52
|
+
* @param {ManifestOptions} manifestOptions Optional. Manifest options
|
|
53
|
+
* @param {string} manifestOptions.bootstrapSha If provided, use this SHA
|
|
54
|
+
* as the point to consider commits after
|
|
55
|
+
* @param {boolean} manifestOptions.alwaysLinkLocal Option for the node-workspace
|
|
56
|
+
* plugin
|
|
57
|
+
* @param {boolean} manifestOptions.updatePeerDependencies Option for the node-workspace
|
|
58
|
+
* plugin
|
|
59
|
+
* @param {boolean} manifestOptions.separatePullRequests If true, create separate pull
|
|
60
|
+
* requests instead of a single manifest release pull request
|
|
61
|
+
* @param {boolean} manifestOptions.alwaysUpdate If true, always updates pull requests instead of
|
|
62
|
+
* only when the release notes change
|
|
63
|
+
* @param {PluginType[]} manifestOptions.plugins Any plugins to use for this repository
|
|
64
|
+
* @param {boolean} manifestOptions.fork If true, create pull requests from a fork. Defaults
|
|
65
|
+
* to `false`
|
|
66
|
+
* @param {string} manifestOptions.signoff Add a Signed-off-by annotation to the commit
|
|
67
|
+
* @param {string} manifestOptions.manifestPath Path to the versions manifest
|
|
68
|
+
* @param {string[]} manifestOptions.labels Labels that denote a pending, untagged release
|
|
69
|
+
* pull request. Defaults to `[autorelease: pending]`
|
|
70
|
+
* @param {string[]} manifestOptions.releaseLabels Labels to apply to a tagged release
|
|
71
|
+
* pull request. Defaults to `[autorelease: tagged]`
|
|
72
|
+
*/
|
|
73
|
+
constructor(github, targetBranch, repositoryConfig, releasedVersions, manifestOptions) {
|
|
74
|
+
var _a, _b;
|
|
75
|
+
this.repository = github.repository;
|
|
76
|
+
this.github = github;
|
|
77
|
+
this.targetBranch = targetBranch;
|
|
78
|
+
this.repositoryConfig = repositoryConfig;
|
|
79
|
+
this.releasedVersions = releasedVersions;
|
|
80
|
+
this.manifestPath =
|
|
81
|
+
(manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.manifestPath) || exports.DEFAULT_RELEASE_PLEASE_MANIFEST;
|
|
82
|
+
this.separatePullRequests =
|
|
83
|
+
(_a = manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.separatePullRequests) !== null && _a !== void 0 ? _a : Object.keys(repositoryConfig).length === 1;
|
|
84
|
+
this.alwaysUpdate = (manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.alwaysUpdate) || false;
|
|
85
|
+
this.fork = (manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.fork) || false;
|
|
86
|
+
this.signoffUser = manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.signoff;
|
|
87
|
+
this.releaseLabels =
|
|
88
|
+
(manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.releaseLabels) || exports.DEFAULT_RELEASE_LABELS;
|
|
89
|
+
this.labels = (manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.labels) || exports.DEFAULT_LABELS;
|
|
90
|
+
this.skipLabeling = (manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.skipLabeling) || false;
|
|
91
|
+
this.sequentialCalls = (manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.sequentialCalls) || false;
|
|
92
|
+
this.snapshotLabels =
|
|
93
|
+
(manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.snapshotLabels) || exports.DEFAULT_SNAPSHOT_LABELS;
|
|
94
|
+
this.bootstrapSha = manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.bootstrapSha;
|
|
95
|
+
this.lastReleaseSha = manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.lastReleaseSha;
|
|
96
|
+
this.draft = manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.draft;
|
|
97
|
+
this.draftPullRequest = manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.draftPullRequest;
|
|
98
|
+
this.groupPullRequestTitlePattern =
|
|
99
|
+
manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.groupPullRequestTitlePattern;
|
|
100
|
+
this.releaseSearchDepth =
|
|
101
|
+
(manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.releaseSearchDepth) || DEFAULT_RELEASE_SEARCH_DEPTH;
|
|
102
|
+
this.commitSearchDepth =
|
|
103
|
+
(manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.commitSearchDepth) || DEFAULT_COMMIT_SEARCH_DEPTH;
|
|
104
|
+
this.commitBatchSize =
|
|
105
|
+
(manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.commitBatchSize) || DEFAULT_COMMIT_BATCH_SIZE;
|
|
106
|
+
this.logger = (_b = manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.logger) !== null && _b !== void 0 ? _b : logger_1.logger;
|
|
107
|
+
this.plugins = ((manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.plugins) || []).map(pluginType => (0, factory_1.buildPlugin)({
|
|
108
|
+
type: pluginType,
|
|
109
|
+
github: this.github,
|
|
110
|
+
targetBranch: this.targetBranch,
|
|
111
|
+
repositoryConfig: this.repositoryConfig,
|
|
112
|
+
manifestPath: this.manifestPath,
|
|
113
|
+
separatePullRequests: this.separatePullRequests,
|
|
114
|
+
}));
|
|
115
|
+
this.pullRequestOverflowHandler = new pull_request_overflow_handler_1.FilePullRequestOverflowHandler(this.github, this.logger);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Create a Manifest from config files in the repository.
|
|
119
|
+
*
|
|
120
|
+
* @param {GitHub} github GitHub client
|
|
121
|
+
* @param {string} targetBranch The releaseable base branch
|
|
122
|
+
* @param {string} configFile Optional. The path to the manifest config file
|
|
123
|
+
* @param {string} manifestFile Optional. The path to the manifest versions file
|
|
124
|
+
* @param {string} path The single path to check. Optional
|
|
125
|
+
* @returns {Manifest}
|
|
126
|
+
*/
|
|
127
|
+
static async fromManifest(github, targetBranch, configFile = exports.DEFAULT_RELEASE_PLEASE_CONFIG, manifestFile = exports.DEFAULT_RELEASE_PLEASE_MANIFEST, manifestOptionOverrides = {}, path, releaseAs) {
|
|
128
|
+
const [{ config: repositoryConfig, options: manifestOptions }, releasedVersions,] = await Promise.all([
|
|
129
|
+
parseConfig(github, configFile, targetBranch, path, releaseAs),
|
|
130
|
+
parseReleasedVersions(github, manifestFile, targetBranch),
|
|
131
|
+
]);
|
|
132
|
+
return new Manifest(github, targetBranch, repositoryConfig, releasedVersions, {
|
|
133
|
+
manifestPath: manifestFile,
|
|
134
|
+
...manifestOptions,
|
|
135
|
+
...manifestOptionOverrides,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Create a Manifest from explicit config in code. This assumes that the
|
|
140
|
+
* repository has a single component at the root path.
|
|
141
|
+
*
|
|
142
|
+
* @param {GitHub} github GitHub client
|
|
143
|
+
* @param {string} targetBranch The releaseable base branch
|
|
144
|
+
* @param {ReleaserConfig} config Release strategy options
|
|
145
|
+
* @param {ManifestOptions} manifestOptions Optional. Manifest options
|
|
146
|
+
* @param {string} manifestOptions.bootstrapSha If provided, use this SHA
|
|
147
|
+
* as the point to consider commits after
|
|
148
|
+
* @param {boolean} manifestOptions.alwaysLinkLocal Option for the node-workspace
|
|
149
|
+
* plugin
|
|
150
|
+
* @param {boolean} manifestOptions.updatePeerDependencies Option for the node-workspace
|
|
151
|
+
* plugin
|
|
152
|
+
* @param {boolean} manifestOptions.separatePullRequests If true, create separate pull
|
|
153
|
+
* requests instead of a single manifest release pull request
|
|
154
|
+
* @param {PluginType[]} manifestOptions.plugins Any plugins to use for this repository
|
|
155
|
+
* @param {boolean} manifestOptions.fork If true, create pull requests from a fork. Defaults
|
|
156
|
+
* to `false`
|
|
157
|
+
* @param {string} manifestOptions.signoff Add a Signed-off-by annotation to the commit
|
|
158
|
+
* @param {string} manifestOptions.manifestPath Path to the versions manifest
|
|
159
|
+
* @param {string[]} manifestOptions.labels Labels that denote a pending, untagged release
|
|
160
|
+
* pull request. Defaults to `[autorelease: pending]`
|
|
161
|
+
* @param {string[]} manifestOptions.releaseLabels Labels to apply to a tagged release
|
|
162
|
+
* pull request. Defaults to `[autorelease: tagged]`
|
|
163
|
+
* @returns {Manifest}
|
|
164
|
+
*/
|
|
165
|
+
static async fromConfig(github, targetBranch, config, manifestOptions, path = exports.ROOT_PROJECT_PATH) {
|
|
166
|
+
const repositoryConfig = {};
|
|
167
|
+
repositoryConfig[path] = config;
|
|
168
|
+
const strategy = await (0, factory_1.buildStrategy)({
|
|
169
|
+
github,
|
|
170
|
+
...config,
|
|
171
|
+
});
|
|
172
|
+
const component = await strategy.getBranchComponent();
|
|
173
|
+
const releasedVersions = {};
|
|
174
|
+
const latestVersion = await latestReleaseVersion(github, targetBranch, version => isPublishedVersion(strategy, version), config, component, manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.logger);
|
|
175
|
+
if (latestVersion) {
|
|
176
|
+
releasedVersions[path] = latestVersion;
|
|
177
|
+
}
|
|
178
|
+
return new Manifest(github, targetBranch, repositoryConfig, releasedVersions, {
|
|
179
|
+
separatePullRequests: true,
|
|
180
|
+
...manifestOptions,
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Build all candidate pull requests for this repository.
|
|
185
|
+
*
|
|
186
|
+
* Iterates through each path and builds a candidate pull request for component.
|
|
187
|
+
* Applies any configured plugins.
|
|
188
|
+
*
|
|
189
|
+
* @returns {ReleasePullRequest[]} The candidate pull requests to open or update.
|
|
190
|
+
*/
|
|
191
|
+
async buildPullRequests() {
|
|
192
|
+
var _a;
|
|
193
|
+
this.logger.info('Building pull requests');
|
|
194
|
+
const pathsByComponent = await this.getPathsByComponent();
|
|
195
|
+
const strategiesByPath = await this.getStrategiesByPath();
|
|
196
|
+
// Collect all the SHAs of the latest release packages
|
|
197
|
+
this.logger.info('Collecting release commit SHAs');
|
|
198
|
+
let releasesFound = 0;
|
|
199
|
+
const expectedReleases = Object.keys(strategiesByPath).length;
|
|
200
|
+
// SHAs by path
|
|
201
|
+
const releaseShasByPath = {};
|
|
202
|
+
// Releases by path
|
|
203
|
+
const releasesByPath = {};
|
|
204
|
+
this.logger.debug(`release search depth: ${this.releaseSearchDepth}`);
|
|
205
|
+
for await (const release of this.github.releaseIterator({
|
|
206
|
+
maxResults: this.releaseSearchDepth,
|
|
207
|
+
})) {
|
|
208
|
+
const tagName = tag_name_1.TagName.parse(release.tagName);
|
|
209
|
+
if (!tagName) {
|
|
210
|
+
this.logger.warn(`Unable to parse release name: ${release.name}`);
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
const component = tagName.component || exports.DEFAULT_COMPONENT_NAME;
|
|
214
|
+
const paths = pathsByComponent[component] || [];
|
|
215
|
+
if (paths.length === 0) {
|
|
216
|
+
this.logger.warn(`Found release tag with component '${component}', but not configured in manifest`);
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
for (const path of paths) {
|
|
220
|
+
const expectedVersion = this.releasedVersions[path];
|
|
221
|
+
if (!expectedVersion) {
|
|
222
|
+
this.logger.warn(`Unable to find expected version for path '${path}' in manifest`);
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
if (expectedVersion.toString() === tagName.version.toString()) {
|
|
226
|
+
this.logger.debug(`Found release for path ${path}, ${release.tagName}`);
|
|
227
|
+
releaseShasByPath[path] = release.sha;
|
|
228
|
+
releasesByPath[path] = {
|
|
229
|
+
name: release.name,
|
|
230
|
+
tag: tagName,
|
|
231
|
+
sha: release.sha,
|
|
232
|
+
notes: release.notes || '',
|
|
233
|
+
};
|
|
234
|
+
releasesFound += 1;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
if (releasesFound >= expectedReleases) {
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
if (releasesFound < expectedReleases) {
|
|
242
|
+
this.logger.warn(`Expected ${expectedReleases} releases, only found ${releasesFound}`);
|
|
243
|
+
// Fall back to looking for missing releases using expected tags
|
|
244
|
+
const missingPaths = Object.keys(strategiesByPath).filter(path => !releasesByPath[path]);
|
|
245
|
+
this.logger.warn(`Missing ${missingPaths.length} paths: ${missingPaths}`);
|
|
246
|
+
const missingReleases = await this.backfillReleasesFromTags(missingPaths, strategiesByPath);
|
|
247
|
+
for (const path in missingReleases) {
|
|
248
|
+
releaseShasByPath[path] = missingReleases[path].sha;
|
|
249
|
+
releasesByPath[path] = missingReleases[path];
|
|
250
|
+
releasesFound++;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
const needsBootstrap = releasesFound < expectedReleases;
|
|
254
|
+
if (releasesFound < expectedReleases) {
|
|
255
|
+
this.logger.warn(`Expected ${expectedReleases} releases, only found ${releasesFound}`);
|
|
256
|
+
}
|
|
257
|
+
for (const path in releasesByPath) {
|
|
258
|
+
const release = releasesByPath[path];
|
|
259
|
+
this.logger.debug(`release for path: ${path}, version: ${release.tag.version.toString()}, sha: ${release.sha}`);
|
|
260
|
+
}
|
|
261
|
+
// iterate through commits and collect commits until we have
|
|
262
|
+
// seen all release commits
|
|
263
|
+
this.logger.info('Collecting commits since all latest releases');
|
|
264
|
+
const commits = [];
|
|
265
|
+
this.logger.debug(`commit search depth: ${this.commitSearchDepth}`);
|
|
266
|
+
const commitGenerator = this.github.mergeCommitIterator(this.targetBranch, {
|
|
267
|
+
maxResults: this.commitSearchDepth,
|
|
268
|
+
backfillFiles: true,
|
|
269
|
+
batchSize: this.commitBatchSize,
|
|
270
|
+
});
|
|
271
|
+
const releaseShas = new Set(Object.values(releaseShasByPath));
|
|
272
|
+
this.logger.debug(releaseShas);
|
|
273
|
+
const expectedShas = releaseShas.size;
|
|
274
|
+
// sha => release pull request
|
|
275
|
+
const releasePullRequestsBySha = {};
|
|
276
|
+
let releaseCommitsFound = 0;
|
|
277
|
+
for await (const commit of commitGenerator) {
|
|
278
|
+
if (releaseShas.has(commit.sha)) {
|
|
279
|
+
if (commit.pullRequest) {
|
|
280
|
+
releasePullRequestsBySha[commit.sha] = commit.pullRequest;
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
this.logger.warn(`Release SHA ${commit.sha} did not have an associated pull request`);
|
|
284
|
+
}
|
|
285
|
+
releaseCommitsFound += 1;
|
|
286
|
+
}
|
|
287
|
+
if (this.lastReleaseSha && this.lastReleaseSha === commit.sha) {
|
|
288
|
+
this.logger.info(`Using configured lastReleaseSha ${this.lastReleaseSha} as last commit.`);
|
|
289
|
+
break;
|
|
290
|
+
}
|
|
291
|
+
else if (needsBootstrap && commit.sha === this.bootstrapSha) {
|
|
292
|
+
this.logger.info(`Needed bootstrapping, found configured bootstrapSha ${this.bootstrapSha}`);
|
|
293
|
+
break;
|
|
294
|
+
}
|
|
295
|
+
else if (!needsBootstrap && releaseCommitsFound >= expectedShas) {
|
|
296
|
+
// found enough commits
|
|
297
|
+
break;
|
|
298
|
+
}
|
|
299
|
+
commits.push({
|
|
300
|
+
sha: commit.sha,
|
|
301
|
+
message: commit.message,
|
|
302
|
+
files: commit.files,
|
|
303
|
+
pullRequest: commit.pullRequest,
|
|
304
|
+
author: commit.author,
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
if (releaseCommitsFound < expectedShas) {
|
|
308
|
+
this.logger.warn(`Expected ${expectedShas} commits, only found ${releaseCommitsFound}`);
|
|
309
|
+
}
|
|
310
|
+
// split commits by path
|
|
311
|
+
this.logger.info(`Splitting ${commits.length} commits by path`);
|
|
312
|
+
const cs = new commit_split_1.CommitSplit({
|
|
313
|
+
includeEmpty: true,
|
|
314
|
+
packagePaths: Object.keys(this.repositoryConfig),
|
|
315
|
+
});
|
|
316
|
+
const splitCommits = cs.split(commits);
|
|
317
|
+
// limit paths to ones since the last release
|
|
318
|
+
let commitsPerPath = {};
|
|
319
|
+
for (const path in this.repositoryConfig) {
|
|
320
|
+
commitsPerPath[path] = commitsAfterSha(path === exports.ROOT_PROJECT_PATH ? commits : splitCommits[path], releaseShasByPath[path]);
|
|
321
|
+
}
|
|
322
|
+
const commitExclude = new commit_exclude_1.CommitExclude(this.repositoryConfig);
|
|
323
|
+
commitsPerPath = commitExclude.excludeCommits(commitsPerPath);
|
|
324
|
+
// backfill latest release tags from manifest
|
|
325
|
+
for (const path in this.repositoryConfig) {
|
|
326
|
+
const latestRelease = releasesByPath[path];
|
|
327
|
+
if (!latestRelease &&
|
|
328
|
+
this.releasedVersions[path] &&
|
|
329
|
+
this.releasedVersions[path].toString() !== '0.0.0') {
|
|
330
|
+
const version = this.releasedVersions[path];
|
|
331
|
+
const strategy = strategiesByPath[path];
|
|
332
|
+
const component = await strategy.getComponent();
|
|
333
|
+
this.logger.info(`No latest release found for path: ${path}, component: ${component}, but a previous version (${version.toString()}) was specified in the manifest.`);
|
|
334
|
+
releasesByPath[path] = {
|
|
335
|
+
tag: new tag_name_1.TagName(version, component, this.repositoryConfig[path].tagSeparator, this.repositoryConfig[path].includeVInTag),
|
|
336
|
+
sha: '',
|
|
337
|
+
notes: '',
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
let strategies = strategiesByPath;
|
|
342
|
+
for (const plugin of this.plugins) {
|
|
343
|
+
strategies = await plugin.preconfigure(strategies, commitsPerPath, releasesByPath);
|
|
344
|
+
}
|
|
345
|
+
let newReleasePullRequests = [];
|
|
346
|
+
for (const path in this.repositoryConfig) {
|
|
347
|
+
const config = this.repositoryConfig[path];
|
|
348
|
+
this.logger.info(`Building candidate release pull request for path: ${path}`);
|
|
349
|
+
this.logger.debug(`type: ${config.releaseType}`);
|
|
350
|
+
this.logger.debug(`targetBranch: ${this.targetBranch}`);
|
|
351
|
+
let pathCommits = (0, commit_1.parseConventionalCommits)(commitsPerPath[path], this.logger);
|
|
352
|
+
// The processCommits hook can be implemented by plugins to
|
|
353
|
+
// post-process commits. This can be used to perform cleanup, e.g,, sentence
|
|
354
|
+
// casing all commit messages:
|
|
355
|
+
for (const plugin of this.plugins) {
|
|
356
|
+
pathCommits = plugin.processCommits(pathCommits);
|
|
357
|
+
}
|
|
358
|
+
this.logger.debug(`commits: ${pathCommits.length}`);
|
|
359
|
+
const latestReleasePullRequest = releasePullRequestsBySha[releaseShasByPath[path]];
|
|
360
|
+
if (!latestReleasePullRequest) {
|
|
361
|
+
this.logger.warn('No latest release pull request found.');
|
|
362
|
+
}
|
|
363
|
+
const strategy = strategies[path];
|
|
364
|
+
const latestRelease = releasesByPath[path];
|
|
365
|
+
const releasePullRequest = await strategy.buildReleasePullRequest(pathCommits, latestRelease, (_a = config.draftPullRequest) !== null && _a !== void 0 ? _a : this.draftPullRequest, this.labels);
|
|
366
|
+
if (releasePullRequest) {
|
|
367
|
+
// Update manifest, but only for valid release version - this will skip SNAPSHOT from java strategy
|
|
368
|
+
if (releasePullRequest.version &&
|
|
369
|
+
isPublishedVersion(strategy, releasePullRequest.version)) {
|
|
370
|
+
const versionsMap = new Map();
|
|
371
|
+
versionsMap.set(path, releasePullRequest.version);
|
|
372
|
+
releasePullRequest.updates.push({
|
|
373
|
+
path: this.manifestPath,
|
|
374
|
+
createIfMissing: false,
|
|
375
|
+
updater: new release_please_manifest_1.ReleasePleaseManifest({
|
|
376
|
+
version: releasePullRequest.version,
|
|
377
|
+
versionsMap,
|
|
378
|
+
}),
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
newReleasePullRequests.push({
|
|
382
|
+
path,
|
|
383
|
+
config,
|
|
384
|
+
pullRequest: releasePullRequest,
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
// Combine pull requests into 1 unless configured for separate
|
|
389
|
+
// pull requests
|
|
390
|
+
if (!this.separatePullRequests) {
|
|
391
|
+
const mergeOptions = {
|
|
392
|
+
pullRequestTitlePattern: this.groupPullRequestTitlePattern,
|
|
393
|
+
};
|
|
394
|
+
// Find the first repositoryConfig item that has a set value
|
|
395
|
+
// for the options that can be passed to the merge plugin
|
|
396
|
+
for (const path in this.repositoryConfig) {
|
|
397
|
+
const config = this.repositoryConfig[path];
|
|
398
|
+
if ('pullRequestHeader' in config &&
|
|
399
|
+
!('pullRequestHeader' in mergeOptions)) {
|
|
400
|
+
mergeOptions.pullRequestHeader = config.pullRequestHeader;
|
|
401
|
+
}
|
|
402
|
+
if ('pullRequestFooter' in config &&
|
|
403
|
+
!('pullRequestFooter' in mergeOptions)) {
|
|
404
|
+
mergeOptions.pullRequestFooter = config.pullRequestFooter;
|
|
405
|
+
}
|
|
406
|
+
if ('componentNoSpace' in config &&
|
|
407
|
+
!('componentNoSpace' in mergeOptions)) {
|
|
408
|
+
mergeOptions.componentNoSpace = config.componentNoSpace;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
this.plugins.push(new merge_1.Merge(this.github, this.targetBranch, this.repositoryConfig, mergeOptions));
|
|
412
|
+
}
|
|
413
|
+
for (const plugin of this.plugins) {
|
|
414
|
+
this.logger.debug(`running plugin: ${plugin.constructor.name}`);
|
|
415
|
+
newReleasePullRequests = await plugin.run(newReleasePullRequests);
|
|
416
|
+
}
|
|
417
|
+
return newReleasePullRequests.map(pullRequestWithConfig => pullRequestWithConfig.pullRequest);
|
|
418
|
+
}
|
|
419
|
+
async backfillReleasesFromTags(missingPaths, strategiesByPath) {
|
|
420
|
+
const releasesByPath = {};
|
|
421
|
+
const allTags = await this.getAllTags();
|
|
422
|
+
for (const path of missingPaths) {
|
|
423
|
+
const expectedVersion = this.releasedVersions[path];
|
|
424
|
+
if (!expectedVersion) {
|
|
425
|
+
this.logger.warn(`No version for path ${path}`);
|
|
426
|
+
continue;
|
|
427
|
+
}
|
|
428
|
+
const component = await strategiesByPath[path].getComponent();
|
|
429
|
+
const expectedTag = new tag_name_1.TagName(expectedVersion, component, this.repositoryConfig[path].tagSeparator, this.repositoryConfig[path].includeVInTag);
|
|
430
|
+
this.logger.debug(`looking for tagName: ${expectedTag.toString()}`);
|
|
431
|
+
const foundTag = allTags[expectedTag.toString()];
|
|
432
|
+
if (foundTag) {
|
|
433
|
+
this.logger.debug(`found: ${foundTag.name} ${foundTag.sha}`);
|
|
434
|
+
releasesByPath[path] = {
|
|
435
|
+
name: foundTag.name,
|
|
436
|
+
tag: expectedTag,
|
|
437
|
+
sha: foundTag.sha,
|
|
438
|
+
notes: '',
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
else {
|
|
442
|
+
if (strategiesByPath[exports.ROOT_PROJECT_PATH] &&
|
|
443
|
+
this.repositoryConfig[path].skipGithubRelease) {
|
|
444
|
+
this.logger.debug('could not find release, checking root package');
|
|
445
|
+
const rootComponent = await strategiesByPath[exports.ROOT_PROJECT_PATH].getComponent();
|
|
446
|
+
const rootTag = new tag_name_1.TagName(expectedVersion, rootComponent, this.repositoryConfig[exports.ROOT_PROJECT_PATH].tagSeparator, this.repositoryConfig[exports.ROOT_PROJECT_PATH].includeVInTag);
|
|
447
|
+
const foundTag = allTags[rootTag.toString()];
|
|
448
|
+
if (foundTag) {
|
|
449
|
+
this.logger.debug(`found rootTag: ${foundTag.name} ${foundTag.sha}`);
|
|
450
|
+
releasesByPath[path] = {
|
|
451
|
+
name: foundTag.name,
|
|
452
|
+
tag: rootTag,
|
|
453
|
+
sha: foundTag.sha,
|
|
454
|
+
notes: '',
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
return releasesByPath;
|
|
461
|
+
}
|
|
462
|
+
async getAllTags() {
|
|
463
|
+
const allTags = {};
|
|
464
|
+
for await (const tag of this.github.tagIterator()) {
|
|
465
|
+
allTags[tag.name] = tag;
|
|
466
|
+
}
|
|
467
|
+
return allTags;
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Opens/updates all candidate release pull requests for this repository.
|
|
471
|
+
*
|
|
472
|
+
* @returns {PullRequest[]} Pull request numbers of release pull requests
|
|
473
|
+
*/
|
|
474
|
+
async createPullRequests() {
|
|
475
|
+
const candidatePullRequests = await this.buildPullRequests();
|
|
476
|
+
if (candidatePullRequests.length === 0) {
|
|
477
|
+
return [];
|
|
478
|
+
}
|
|
479
|
+
// if there are any merged, pending release pull requests, don't open
|
|
480
|
+
// any new release PRs
|
|
481
|
+
const mergedPullRequestsGenerator = this.findMergedReleasePullRequests();
|
|
482
|
+
for await (const _ of mergedPullRequestsGenerator) {
|
|
483
|
+
this.logger.warn('There are untagged, merged release PRs outstanding - aborting');
|
|
484
|
+
return [];
|
|
485
|
+
}
|
|
486
|
+
// collect open and snoozed release pull requests
|
|
487
|
+
const openPullRequests = await this.findOpenReleasePullRequests();
|
|
488
|
+
const snoozedPullRequests = await this.findSnoozedReleasePullRequests();
|
|
489
|
+
if (this.sequentialCalls) {
|
|
490
|
+
const pullRequests = [];
|
|
491
|
+
for (const pullRequest of candidatePullRequests) {
|
|
492
|
+
const resultPullRequest = await this.createOrUpdatePullRequest(pullRequest, openPullRequests, snoozedPullRequests);
|
|
493
|
+
if (resultPullRequest)
|
|
494
|
+
pullRequests.push(resultPullRequest);
|
|
495
|
+
}
|
|
496
|
+
return pullRequests;
|
|
497
|
+
}
|
|
498
|
+
else {
|
|
499
|
+
const promises = [];
|
|
500
|
+
for (const pullRequest of candidatePullRequests) {
|
|
501
|
+
promises.push(this.createOrUpdatePullRequest(pullRequest, openPullRequests, snoozedPullRequests));
|
|
502
|
+
}
|
|
503
|
+
const pullNumbers = await Promise.all(promises);
|
|
504
|
+
// reject any pull numbers that were not created or updated
|
|
505
|
+
return pullNumbers.filter(number => !!number);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
async findOpenReleasePullRequests() {
|
|
509
|
+
this.logger.info('Looking for open release pull requests');
|
|
510
|
+
const openPullRequests = [];
|
|
511
|
+
const generator = this.github.pullRequestIterator(this.targetBranch, 'OPEN', Number.MAX_SAFE_INTEGER, false);
|
|
512
|
+
for await (const openPullRequest of generator) {
|
|
513
|
+
if (hasAllLabels(this.labels, openPullRequest.labels) ||
|
|
514
|
+
hasAllLabels(this.snapshotLabels, openPullRequest.labels)) {
|
|
515
|
+
const body = await this.pullRequestOverflowHandler.parseOverflow(openPullRequest);
|
|
516
|
+
if (body) {
|
|
517
|
+
// maybe replace with overflow body
|
|
518
|
+
openPullRequests.push({
|
|
519
|
+
...openPullRequest,
|
|
520
|
+
body: body.toString(),
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
this.logger.info(`found ${openPullRequests.length} open release pull requests.`);
|
|
526
|
+
return openPullRequests;
|
|
527
|
+
}
|
|
528
|
+
async findSnoozedReleasePullRequests() {
|
|
529
|
+
this.logger.info('Looking for snoozed release pull requests');
|
|
530
|
+
const snoozedPullRequests = [];
|
|
531
|
+
const closedGenerator = this.github.pullRequestIterator(this.targetBranch, 'CLOSED', 200, false);
|
|
532
|
+
for await (const closedPullRequest of closedGenerator) {
|
|
533
|
+
if (hasAllLabels([exports.SNOOZE_LABEL], closedPullRequest.labels) &&
|
|
534
|
+
branch_name_1.BranchName.parse(closedPullRequest.headBranchName, this.logger)) {
|
|
535
|
+
const body = await this.pullRequestOverflowHandler.parseOverflow(closedPullRequest);
|
|
536
|
+
if (body) {
|
|
537
|
+
// maybe replace with overflow body
|
|
538
|
+
snoozedPullRequests.push({
|
|
539
|
+
...closedPullRequest,
|
|
540
|
+
body: body.toString(),
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
this.logger.info(`found ${snoozedPullRequests.length} snoozed release pull requests.`);
|
|
546
|
+
return snoozedPullRequests;
|
|
547
|
+
}
|
|
548
|
+
async createOrUpdatePullRequest(pullRequest, openPullRequests, snoozedPullRequests) {
|
|
549
|
+
// look for existing, open pull request
|
|
550
|
+
const existing = openPullRequests.find(openPullRequest => openPullRequest.headBranchName === pullRequest.headRefName);
|
|
551
|
+
if (existing) {
|
|
552
|
+
return this.alwaysUpdate
|
|
553
|
+
? await this.updateExistingPullRequest(existing, pullRequest)
|
|
554
|
+
: await this.maybeUpdateExistingPullRequest(existing, pullRequest);
|
|
555
|
+
}
|
|
556
|
+
// look for closed, snoozed pull request
|
|
557
|
+
const snoozed = snoozedPullRequests.find(openPullRequest => openPullRequest.headBranchName === pullRequest.headRefName);
|
|
558
|
+
if (snoozed) {
|
|
559
|
+
return this.alwaysUpdate
|
|
560
|
+
? await this.updateExistingPullRequest(snoozed, pullRequest)
|
|
561
|
+
: await this.maybeUpdateSnoozedPullRequest(snoozed, pullRequest);
|
|
562
|
+
}
|
|
563
|
+
const body = await this.pullRequestOverflowHandler.handleOverflow(pullRequest);
|
|
564
|
+
const message = this.signoffUser
|
|
565
|
+
? (0, signoff_commit_message_1.signoffCommitMessage)(pullRequest.title.toString(), this.signoffUser)
|
|
566
|
+
: pullRequest.title.toString();
|
|
567
|
+
const newPullRequest = await this.github.createPullRequest({
|
|
568
|
+
headBranchName: pullRequest.headRefName,
|
|
569
|
+
baseBranchName: this.targetBranch,
|
|
570
|
+
number: -1,
|
|
571
|
+
title: pullRequest.title.toString(),
|
|
572
|
+
body,
|
|
573
|
+
labels: this.skipLabeling ? [] : pullRequest.labels,
|
|
574
|
+
files: [],
|
|
575
|
+
}, this.targetBranch, message, pullRequest.updates, {
|
|
576
|
+
fork: this.fork,
|
|
577
|
+
draft: pullRequest.draft,
|
|
578
|
+
});
|
|
579
|
+
return newPullRequest;
|
|
580
|
+
}
|
|
581
|
+
/// only update an existing pull request if it has release note changes
|
|
582
|
+
async maybeUpdateExistingPullRequest(existing, pullRequest) {
|
|
583
|
+
// If unchanged, no need to push updates
|
|
584
|
+
if (existing.body === pullRequest.body.toString()) {
|
|
585
|
+
this.logger.info(`PR https://github.com/${this.repository.owner}/${this.repository.repo}/pull/${existing.number} remained the same`);
|
|
586
|
+
return undefined;
|
|
587
|
+
}
|
|
588
|
+
return await this.updateExistingPullRequest(existing, pullRequest);
|
|
589
|
+
}
|
|
590
|
+
/// only update a snoozed pull request if it has release note changes
|
|
591
|
+
async maybeUpdateSnoozedPullRequest(snoozed, pullRequest) {
|
|
592
|
+
// If unchanged, no need to push updates
|
|
593
|
+
if (snoozed.body === pullRequest.body.toString()) {
|
|
594
|
+
this.logger.info(`PR https://github.com/${this.repository.owner}/${this.repository.repo}/pull/${snoozed.number} remained the same`);
|
|
595
|
+
return undefined;
|
|
596
|
+
}
|
|
597
|
+
const updatedPullRequest = await this.updateExistingPullRequest(snoozed, pullRequest);
|
|
598
|
+
// TODO: consider leaving the snooze label
|
|
599
|
+
await this.github.removeIssueLabels([exports.SNOOZE_LABEL], snoozed.number);
|
|
600
|
+
return updatedPullRequest;
|
|
601
|
+
}
|
|
602
|
+
/// force an update to an existing pull request
|
|
603
|
+
async updateExistingPullRequest(existing, pullRequest) {
|
|
604
|
+
return await this.github.updatePullRequest(existing.number, pullRequest, this.targetBranch, {
|
|
605
|
+
fork: this.fork,
|
|
606
|
+
signoffUser: this.signoffUser,
|
|
607
|
+
pullRequestOverflowHandler: this.pullRequestOverflowHandler,
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
async *findMergedReleasePullRequests() {
|
|
611
|
+
// Find merged release pull requests
|
|
612
|
+
const pullRequestGenerator = this.github.pullRequestIterator(this.targetBranch, 'MERGED', 200, false);
|
|
613
|
+
for await (const pullRequest of pullRequestGenerator) {
|
|
614
|
+
if (!hasAllLabels(this.labels, pullRequest.labels)) {
|
|
615
|
+
continue;
|
|
616
|
+
}
|
|
617
|
+
this.logger.debug(`Found pull request #${pullRequest.number}: '${pullRequest.title}'`);
|
|
618
|
+
// if the pull request body overflows, handle it
|
|
619
|
+
const pullRequestBody = await this.pullRequestOverflowHandler.parseOverflow(pullRequest);
|
|
620
|
+
if (!pullRequestBody) {
|
|
621
|
+
this.logger.debug('could not parse pull request body as a release PR');
|
|
622
|
+
continue;
|
|
623
|
+
}
|
|
624
|
+
// replace with the complete fetched body
|
|
625
|
+
yield {
|
|
626
|
+
...pullRequest,
|
|
627
|
+
body: pullRequestBody.toString(),
|
|
628
|
+
};
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
/**
|
|
632
|
+
* Find merged, untagged releases and build candidate releases to tag.
|
|
633
|
+
*
|
|
634
|
+
* @returns {CandidateRelease[]} List of release candidates
|
|
635
|
+
*/
|
|
636
|
+
async buildReleases() {
|
|
637
|
+
var _a;
|
|
638
|
+
this.logger.info('Building releases');
|
|
639
|
+
const strategiesByPath = await this.getStrategiesByPath();
|
|
640
|
+
// Find merged release pull requests
|
|
641
|
+
const generator = await this.findMergedReleasePullRequests();
|
|
642
|
+
const candidateReleases = [];
|
|
643
|
+
for await (const pullRequest of generator) {
|
|
644
|
+
for (const path in this.repositoryConfig) {
|
|
645
|
+
const config = this.repositoryConfig[path];
|
|
646
|
+
this.logger.info(`Building release for path: ${path}`);
|
|
647
|
+
this.logger.debug(`type: ${config.releaseType}`);
|
|
648
|
+
this.logger.debug(`targetBranch: ${this.targetBranch}`);
|
|
649
|
+
const strategy = strategiesByPath[path];
|
|
650
|
+
const releases = await strategy.buildReleases(pullRequest, {
|
|
651
|
+
groupPullRequestTitlePattern: this.groupPullRequestTitlePattern,
|
|
652
|
+
});
|
|
653
|
+
for (const release of releases) {
|
|
654
|
+
candidateReleases.push({
|
|
655
|
+
...release,
|
|
656
|
+
path,
|
|
657
|
+
pullRequest,
|
|
658
|
+
draft: (_a = config.draft) !== null && _a !== void 0 ? _a : this.draft,
|
|
659
|
+
forceTag: config.forceTag,
|
|
660
|
+
prerelease: config.prerelease &&
|
|
661
|
+
(!!release.tag.version.preRelease ||
|
|
662
|
+
release.tag.version.major === 0),
|
|
663
|
+
});
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
return candidateReleases;
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* Find merged, untagged releases. For each release, create a GitHub release,
|
|
671
|
+
* comment on the pull request used to generated it and update the pull request
|
|
672
|
+
* labels.
|
|
673
|
+
*
|
|
674
|
+
* @returns {GitHubRelease[]} List of created GitHub releases
|
|
675
|
+
*/
|
|
676
|
+
async createReleases() {
|
|
677
|
+
const releasesByPullRequest = {};
|
|
678
|
+
const pullRequestsByNumber = {};
|
|
679
|
+
for (const release of await this.buildReleases()) {
|
|
680
|
+
pullRequestsByNumber[release.pullRequest.number] = release.pullRequest;
|
|
681
|
+
if (releasesByPullRequest[release.pullRequest.number]) {
|
|
682
|
+
releasesByPullRequest[release.pullRequest.number].push(release);
|
|
683
|
+
}
|
|
684
|
+
else {
|
|
685
|
+
releasesByPullRequest[release.pullRequest.number] = [release];
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
if (this.sequentialCalls) {
|
|
689
|
+
const resultReleases = [];
|
|
690
|
+
for (const pullNumber in releasesByPullRequest) {
|
|
691
|
+
const releases = await this.createReleasesForPullRequest(releasesByPullRequest[pullNumber], pullRequestsByNumber[pullNumber]);
|
|
692
|
+
resultReleases.push(...releases);
|
|
693
|
+
}
|
|
694
|
+
return resultReleases;
|
|
695
|
+
}
|
|
696
|
+
else {
|
|
697
|
+
const promises = [];
|
|
698
|
+
for (const pullNumber in releasesByPullRequest) {
|
|
699
|
+
promises.push(this.createReleasesForPullRequest(releasesByPullRequest[pullNumber], pullRequestsByNumber[pullNumber]));
|
|
700
|
+
}
|
|
701
|
+
const releases = await Promise.all(promises);
|
|
702
|
+
return releases.reduce((collection, r) => collection.concat(r), []);
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
async createReleasesForPullRequest(releases, pullRequest) {
|
|
706
|
+
this.logger.info(`Creating ${releases.length} releases for pull #${pullRequest.number}`);
|
|
707
|
+
const duplicateReleases = [];
|
|
708
|
+
const githubReleases = [];
|
|
709
|
+
let error;
|
|
710
|
+
for (const release of releases) {
|
|
711
|
+
// stop releasing once we hit an error
|
|
712
|
+
if (error)
|
|
713
|
+
continue;
|
|
714
|
+
try {
|
|
715
|
+
githubReleases.push(await this.createRelease(release, pullRequest));
|
|
716
|
+
}
|
|
717
|
+
catch (err) {
|
|
718
|
+
if (err instanceof errors_1.DuplicateReleaseError) {
|
|
719
|
+
this.logger.warn(`Duplicate release tag: ${release.tag.toString()}`);
|
|
720
|
+
duplicateReleases.push(err);
|
|
721
|
+
}
|
|
722
|
+
else {
|
|
723
|
+
error = err;
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
if (githubReleases.length > 0) {
|
|
728
|
+
// comment on pull request about the successful releases
|
|
729
|
+
const releaseList = githubReleases
|
|
730
|
+
.map(({ tagName, url }) => `- [${tagName}](${url})`)
|
|
731
|
+
.join('\n');
|
|
732
|
+
const comment = `🤖 Created releases:\n\n${releaseList}\n\n:sunflower:`;
|
|
733
|
+
await this.github.commentOnIssue(comment, pullRequest.number);
|
|
734
|
+
}
|
|
735
|
+
if (error) {
|
|
736
|
+
throw error;
|
|
737
|
+
}
|
|
738
|
+
if (duplicateReleases.length > 0) {
|
|
739
|
+
if (duplicateReleases.length + githubReleases.length ===
|
|
740
|
+
releases.length) {
|
|
741
|
+
// we've either tagged all releases or they were duplicates:
|
|
742
|
+
// adjust tags on pullRequest
|
|
743
|
+
await this.github.removeIssueLabels(this.labels, pullRequest.number);
|
|
744
|
+
await this.github.addIssueLabels(this.releaseLabels, pullRequest.number);
|
|
745
|
+
}
|
|
746
|
+
if (githubReleases.length === 0) {
|
|
747
|
+
// If all releases were duplicate, throw a duplicate error
|
|
748
|
+
throw duplicateReleases[0];
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
else {
|
|
752
|
+
// adjust tags on pullRequest
|
|
753
|
+
await this.github.removeIssueLabels(this.labels, pullRequest.number);
|
|
754
|
+
await this.github.addIssueLabels(this.releaseLabels, pullRequest.number);
|
|
755
|
+
}
|
|
756
|
+
return githubReleases;
|
|
757
|
+
}
|
|
758
|
+
async createRelease(release, pullRequest) {
|
|
759
|
+
const githubRelease = await this.github.createRelease(release, {
|
|
760
|
+
draft: release.draft,
|
|
761
|
+
prerelease: release.prerelease,
|
|
762
|
+
forceTag: release.forceTag,
|
|
763
|
+
});
|
|
764
|
+
return {
|
|
765
|
+
...githubRelease,
|
|
766
|
+
path: release.path,
|
|
767
|
+
version: release.tag.version.toString(),
|
|
768
|
+
major: release.tag.version.major,
|
|
769
|
+
minor: release.tag.version.minor,
|
|
770
|
+
patch: release.tag.version.patch,
|
|
771
|
+
prNumber: pullRequest.number,
|
|
772
|
+
};
|
|
773
|
+
}
|
|
774
|
+
async getStrategiesByPath() {
|
|
775
|
+
if (!this._strategiesByPath) {
|
|
776
|
+
this.logger.info('Building strategies by path');
|
|
777
|
+
this._strategiesByPath = {};
|
|
778
|
+
for (const path in this.repositoryConfig) {
|
|
779
|
+
const config = this.repositoryConfig[path];
|
|
780
|
+
this.logger.debug(`${path}: ${config.releaseType}`);
|
|
781
|
+
const strategy = await (0, factory_1.buildStrategy)({
|
|
782
|
+
...config,
|
|
783
|
+
github: this.github,
|
|
784
|
+
path,
|
|
785
|
+
targetBranch: this.targetBranch,
|
|
786
|
+
});
|
|
787
|
+
this._strategiesByPath[path] = strategy;
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
return this._strategiesByPath;
|
|
791
|
+
}
|
|
792
|
+
async getPathsByComponent() {
|
|
793
|
+
if (!this._pathsByComponent) {
|
|
794
|
+
this._pathsByComponent = {};
|
|
795
|
+
const strategiesByPath = await this.getStrategiesByPath();
|
|
796
|
+
for (const path in this.repositoryConfig) {
|
|
797
|
+
const strategy = strategiesByPath[path];
|
|
798
|
+
const component = (await strategy.getComponent()) || '';
|
|
799
|
+
if (!this._pathsByComponent[component]) {
|
|
800
|
+
this._pathsByComponent[component] = [];
|
|
801
|
+
}
|
|
802
|
+
this._pathsByComponent[component].push(path);
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
return this._pathsByComponent;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
exports.Manifest = Manifest;
|
|
809
|
+
/**
|
|
810
|
+
* Helper to convert parsed JSON releaser config into ReleaserConfig for
|
|
811
|
+
* the Manifest.
|
|
812
|
+
*
|
|
813
|
+
* @param {ReleaserPackageConfig} config Parsed configuration from JSON file.
|
|
814
|
+
* @returns {ReleaserConfig}
|
|
815
|
+
*/
|
|
816
|
+
function extractReleaserConfig(config) {
|
|
817
|
+
var _a, _b, _c;
|
|
818
|
+
return {
|
|
819
|
+
releaseType: config['release-type'],
|
|
820
|
+
bumpMinorPreMajor: config['bump-minor-pre-major'],
|
|
821
|
+
bumpPatchForMinorPreMajor: config['bump-patch-for-minor-pre-major'],
|
|
822
|
+
prereleaseType: config['prerelease-type'],
|
|
823
|
+
versioning: config['versioning'],
|
|
824
|
+
changelogSections: config['changelog-sections'],
|
|
825
|
+
changelogPath: config['changelog-path'],
|
|
826
|
+
changelogHost: config['changelog-host'],
|
|
827
|
+
includeCommitAuthors: config['include-commit-authors'],
|
|
828
|
+
releaseAs: config['release-as'],
|
|
829
|
+
skipGithubRelease: config['skip-github-release'],
|
|
830
|
+
skipChangelog: config['skip-changelog'],
|
|
831
|
+
draft: config.draft,
|
|
832
|
+
forceTag: config['force-tag-creation'],
|
|
833
|
+
prerelease: config.prerelease,
|
|
834
|
+
draftPullRequest: config['draft-pull-request'],
|
|
835
|
+
component: config['component'],
|
|
836
|
+
packageName: config['package-name'],
|
|
837
|
+
versionFile: config['version-file'],
|
|
838
|
+
extraFiles: config['extra-files'],
|
|
839
|
+
includeComponentInTag: config['include-component-in-tag'],
|
|
840
|
+
includeVInTag: config['include-v-in-tag'],
|
|
841
|
+
includeVInReleaseName: config['include-v-in-release-name'],
|
|
842
|
+
changelogType: config['changelog-type'],
|
|
843
|
+
pullRequestTitlePattern: config['pull-request-title-pattern'],
|
|
844
|
+
pullRequestHeader: config['pull-request-header'],
|
|
845
|
+
pullRequestFooter: config['pull-request-footer'],
|
|
846
|
+
componentNoSpace: config['component-no-space'],
|
|
847
|
+
tagSeparator: config['tag-separator'],
|
|
848
|
+
separatePullRequests: config['separate-pull-requests'],
|
|
849
|
+
labels: (_a = config['label']) === null || _a === void 0 ? void 0 : _a.split(','),
|
|
850
|
+
releaseLabels: (_b = config['release-label']) === null || _b === void 0 ? void 0 : _b.split(','),
|
|
851
|
+
extraLabels: (_c = config['extra-label']) === null || _c === void 0 ? void 0 : _c.split(','),
|
|
852
|
+
skipSnapshot: config['skip-snapshot'],
|
|
853
|
+
initialVersion: config['initial-version'],
|
|
854
|
+
excludePaths: config['exclude-paths'],
|
|
855
|
+
dateFormat: config['date-format'],
|
|
856
|
+
};
|
|
857
|
+
}
|
|
858
|
+
/**
|
|
859
|
+
* Helper to convert fetch the manifest config from the repository and
|
|
860
|
+
* parse into configuration for the Manifest.
|
|
861
|
+
*
|
|
862
|
+
* @param {GitHub} github GitHub client
|
|
863
|
+
* @param {string} configFile Path in the repository to the manifest config
|
|
864
|
+
* @param {string} branch Branch to fetch the config file from
|
|
865
|
+
* @param {string} onlyPath Optional. Use only the given package
|
|
866
|
+
* @param {string} releaseAs Optional. Override release-as and use the given version
|
|
867
|
+
*/
|
|
868
|
+
async function parseConfig(github, configFile, branch, onlyPath, releaseAs) {
|
|
869
|
+
const config = await fetchManifestConfig(github, configFile, branch);
|
|
870
|
+
const defaultConfig = extractReleaserConfig(config);
|
|
871
|
+
const repositoryConfig = {};
|
|
872
|
+
for (const path in config.packages) {
|
|
873
|
+
if (onlyPath && onlyPath !== path)
|
|
874
|
+
continue;
|
|
875
|
+
repositoryConfig[path] = mergeReleaserConfig(defaultConfig, extractReleaserConfig(config.packages[path]));
|
|
876
|
+
if (releaseAs) {
|
|
877
|
+
repositoryConfig[path].releaseAs = releaseAs;
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
const configLabel = config['label'];
|
|
881
|
+
const configReleaseLabel = config['release-label'];
|
|
882
|
+
const configSnapshotLabel = config['snapshot-label'];
|
|
883
|
+
const configExtraLabel = config['extra-label'];
|
|
884
|
+
const manifestOptions = {
|
|
885
|
+
bootstrapSha: config['bootstrap-sha'],
|
|
886
|
+
lastReleaseSha: config['last-release-sha'],
|
|
887
|
+
alwaysLinkLocal: config['always-link-local'],
|
|
888
|
+
separatePullRequests: config['separate-pull-requests'],
|
|
889
|
+
alwaysUpdate: config['always-update'],
|
|
890
|
+
groupPullRequestTitlePattern: config['group-pull-request-title-pattern'],
|
|
891
|
+
plugins: config['plugins'],
|
|
892
|
+
signoff: config['signoff'],
|
|
893
|
+
labels: configLabel === null || configLabel === void 0 ? void 0 : configLabel.split(','),
|
|
894
|
+
releaseLabels: configReleaseLabel === null || configReleaseLabel === void 0 ? void 0 : configReleaseLabel.split(','),
|
|
895
|
+
snapshotLabels: configSnapshotLabel === null || configSnapshotLabel === void 0 ? void 0 : configSnapshotLabel.split(','),
|
|
896
|
+
extraLabels: configExtraLabel === null || configExtraLabel === void 0 ? void 0 : configExtraLabel.split(','),
|
|
897
|
+
releaseSearchDepth: config['release-search-depth'],
|
|
898
|
+
commitSearchDepth: config['commit-search-depth'],
|
|
899
|
+
commitBatchSize: config['commit-batch-size'],
|
|
900
|
+
sequentialCalls: config['sequential-calls'],
|
|
901
|
+
};
|
|
902
|
+
return { config: repositoryConfig, options: manifestOptions };
|
|
903
|
+
}
|
|
904
|
+
/**
|
|
905
|
+
* Helper to fetch manifest config
|
|
906
|
+
*
|
|
907
|
+
* @param {GitHub} github
|
|
908
|
+
* @param {string} configFile
|
|
909
|
+
* @param {string} branch
|
|
910
|
+
* @returns {ManifestConfig}
|
|
911
|
+
* @throws {ConfigurationError} if missing the manifest config file
|
|
912
|
+
*/
|
|
913
|
+
async function fetchManifestConfig(github, configFile, branch) {
|
|
914
|
+
try {
|
|
915
|
+
return await github.getFileJson(configFile, branch);
|
|
916
|
+
}
|
|
917
|
+
catch (e) {
|
|
918
|
+
if (e instanceof errors_1.FileNotFoundError) {
|
|
919
|
+
throw new errors_1.ConfigurationError(`Missing required manifest config: ${configFile}`, 'base', `${github.repository.owner}/${github.repository.repo}`);
|
|
920
|
+
}
|
|
921
|
+
else if (e instanceof SyntaxError) {
|
|
922
|
+
throw new errors_1.ConfigurationError(`Failed to parse manifest config JSON: ${configFile}\n${e.message}`, 'base', `${github.repository.owner}/${github.repository.repo}`);
|
|
923
|
+
}
|
|
924
|
+
throw e;
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
/**
|
|
928
|
+
* Helper to parse the manifest versions file.
|
|
929
|
+
*
|
|
930
|
+
* @param {GitHub} github GitHub client
|
|
931
|
+
* @param {string} manifestFile Path in the repository to the versions file
|
|
932
|
+
* @param {string} branch Branch to fetch the versions file from
|
|
933
|
+
* @returns {Record<string, string>}
|
|
934
|
+
*/
|
|
935
|
+
async function parseReleasedVersions(github, manifestFile, branch) {
|
|
936
|
+
const manifestJson = await fetchReleasedVersions(github, manifestFile, branch);
|
|
937
|
+
const releasedVersions = {};
|
|
938
|
+
for (const path in manifestJson) {
|
|
939
|
+
releasedVersions[path] = version_1.Version.parse(manifestJson[path]);
|
|
940
|
+
}
|
|
941
|
+
return releasedVersions;
|
|
942
|
+
}
|
|
943
|
+
/**
|
|
944
|
+
* Helper to fetch manifest config
|
|
945
|
+
*
|
|
946
|
+
* @param {GitHub} github
|
|
947
|
+
* @param {string} manifestFile
|
|
948
|
+
* @param {string} branch
|
|
949
|
+
* @throws {ConfigurationError} if missing the manifest config file
|
|
950
|
+
*/
|
|
951
|
+
async function fetchReleasedVersions(github, manifestFile, branch) {
|
|
952
|
+
try {
|
|
953
|
+
return await github.getFileJson(manifestFile, branch);
|
|
954
|
+
}
|
|
955
|
+
catch (e) {
|
|
956
|
+
if (e instanceof errors_1.FileNotFoundError) {
|
|
957
|
+
throw new errors_1.ConfigurationError(`Missing required manifest versions: ${manifestFile}`, 'base', `${github.repository.owner}/${github.repository.repo}`);
|
|
958
|
+
}
|
|
959
|
+
else if (e instanceof SyntaxError) {
|
|
960
|
+
throw new errors_1.ConfigurationError(`Failed to parse manifest versions JSON: ${manifestFile}\n${e.message}`, 'base', `${github.repository.owner}/${github.repository.repo}`);
|
|
961
|
+
}
|
|
962
|
+
throw e;
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
function isPublishedVersion(strategy, version) {
|
|
966
|
+
return strategy.isPublishedVersion
|
|
967
|
+
? strategy.isPublishedVersion(version)
|
|
968
|
+
: true;
|
|
969
|
+
}
|
|
970
|
+
/**
|
|
971
|
+
* Find the most recent matching release tag on the branch we're
|
|
972
|
+
* configured for.
|
|
973
|
+
*
|
|
974
|
+
* @param github GitHub client instance.
|
|
975
|
+
* @param {string} targetBranch Name of the scanned branch.
|
|
976
|
+
* @param releaseFilter Validator function for release version. Used to filter-out SNAPSHOT releases for Java strategy.
|
|
977
|
+
* @param {string} prefix Limit the release to a specific component.
|
|
978
|
+
*/
|
|
979
|
+
async function latestReleaseVersion(github, targetBranch, releaseFilter, config, prefix, logger = logger_1.logger) {
|
|
980
|
+
const branchPrefix = prefix
|
|
981
|
+
? prefix.endsWith('-')
|
|
982
|
+
? prefix.replace(/-$/, '')
|
|
983
|
+
: prefix
|
|
984
|
+
: undefined;
|
|
985
|
+
logger.info(`Looking for latest release on branch: ${targetBranch} with prefix: ${prefix}`);
|
|
986
|
+
// collect set of recent commit SHAs seen to verify that the release
|
|
987
|
+
// is in the current branch
|
|
988
|
+
const commitShas = new Set();
|
|
989
|
+
const candidateReleaseVersions = [];
|
|
990
|
+
// only look at the last 250 or so commits to find the latest tag - we
|
|
991
|
+
// don't want to scan the entire repository history if this repo has never
|
|
992
|
+
// been released
|
|
993
|
+
const generator = github.mergeCommitIterator(targetBranch, {
|
|
994
|
+
maxResults: 250,
|
|
995
|
+
});
|
|
996
|
+
for await (const commitWithPullRequest of generator) {
|
|
997
|
+
commitShas.add(commitWithPullRequest.sha);
|
|
998
|
+
const mergedPullRequest = commitWithPullRequest.pullRequest;
|
|
999
|
+
if (!(mergedPullRequest === null || mergedPullRequest === void 0 ? void 0 : mergedPullRequest.mergeCommitOid)) {
|
|
1000
|
+
logger.trace(`skipping commit: ${commitWithPullRequest.sha} missing merged pull request`);
|
|
1001
|
+
continue;
|
|
1002
|
+
}
|
|
1003
|
+
const branchName = branch_name_1.BranchName.parse(mergedPullRequest.headBranchName, logger);
|
|
1004
|
+
if (!branchName) {
|
|
1005
|
+
logger.trace(`skipping commit: ${commitWithPullRequest.sha} unrecognized branch name: ${mergedPullRequest.headBranchName}`);
|
|
1006
|
+
continue;
|
|
1007
|
+
}
|
|
1008
|
+
// If branchPrefix is specified, ensure it is found in the branch name.
|
|
1009
|
+
// If branchPrefix is not specified, component should also be undefined.
|
|
1010
|
+
if (branchName.getComponent() !== branchPrefix) {
|
|
1011
|
+
logger.trace(`skipping commit: ${commitWithPullRequest.sha} branch component ${branchName.getComponent()} doesn't match expected prefix: ${branchPrefix}`);
|
|
1012
|
+
continue;
|
|
1013
|
+
}
|
|
1014
|
+
const pullRequestTitle = pull_request_title_1.PullRequestTitle.parse(mergedPullRequest.title, config.pullRequestTitlePattern, config.componentNoSpace, logger);
|
|
1015
|
+
if (!pullRequestTitle) {
|
|
1016
|
+
logger.trace(`skipping commit: ${commitWithPullRequest.sha} couldn't parse pull request title: ${mergedPullRequest.title}`);
|
|
1017
|
+
continue;
|
|
1018
|
+
}
|
|
1019
|
+
const version = pullRequestTitle.getVersion();
|
|
1020
|
+
if (version && releaseFilter(version)) {
|
|
1021
|
+
logger.debug(`Found latest release pull request: ${mergedPullRequest.number} version: ${version}`);
|
|
1022
|
+
candidateReleaseVersions.push(version);
|
|
1023
|
+
break;
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
// If not found from recent pull requests, look at releases. Iterate
|
|
1027
|
+
// through releases finding valid tags, then cross reference
|
|
1028
|
+
const releaseGenerator = github.releaseIterator();
|
|
1029
|
+
for await (const release of releaseGenerator) {
|
|
1030
|
+
const tagName = tag_name_1.TagName.parse(release.tagName);
|
|
1031
|
+
if (!tagName) {
|
|
1032
|
+
continue;
|
|
1033
|
+
}
|
|
1034
|
+
if (tagMatchesConfig(tagName, branchPrefix, config.includeComponentInTag)) {
|
|
1035
|
+
logger.debug(`found release for ${prefix}`, tagName.version);
|
|
1036
|
+
if (!commitShas.has(release.sha)) {
|
|
1037
|
+
logger.debug(`SHA not found in recent commits to branch ${targetBranch}, skipping`);
|
|
1038
|
+
continue;
|
|
1039
|
+
}
|
|
1040
|
+
candidateReleaseVersions.push(tagName.version);
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
logger.debug(`found ${candidateReleaseVersions.length} possible releases.`, candidateReleaseVersions);
|
|
1044
|
+
if (candidateReleaseVersions.length > 0) {
|
|
1045
|
+
// Find largest release number (sort descending then return first)
|
|
1046
|
+
return candidateReleaseVersions.sort((a, b) => b.compare(a))[0];
|
|
1047
|
+
}
|
|
1048
|
+
// If not found from recent pull requests or releases, look at tags. Iterate
|
|
1049
|
+
// through tags and cross reference against SHAs in this branch
|
|
1050
|
+
const tagGenerator = github.tagIterator();
|
|
1051
|
+
const candidateTagVersion = [];
|
|
1052
|
+
for await (const tag of tagGenerator) {
|
|
1053
|
+
const tagName = tag_name_1.TagName.parse(tag.name);
|
|
1054
|
+
if (!tagName) {
|
|
1055
|
+
continue;
|
|
1056
|
+
}
|
|
1057
|
+
if (tagMatchesConfig(tagName, branchPrefix, config.includeComponentInTag)) {
|
|
1058
|
+
if (!commitShas.has(tag.sha)) {
|
|
1059
|
+
logger.debug(`SHA not found in recent commits to branch ${targetBranch}, skipping`);
|
|
1060
|
+
continue;
|
|
1061
|
+
}
|
|
1062
|
+
candidateTagVersion.push(tagName.version);
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
logger.debug(`found ${candidateTagVersion.length} possible tags.`, candidateTagVersion);
|
|
1066
|
+
// Find largest release number (sort descending then return first)
|
|
1067
|
+
return candidateTagVersion.sort((a, b) => b.compare(a))[0];
|
|
1068
|
+
}
|
|
1069
|
+
function mergeReleaserConfig(defaultConfig, pathConfig) {
|
|
1070
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11;
|
|
1071
|
+
return {
|
|
1072
|
+
releaseType: (_b = (_a = pathConfig.releaseType) !== null && _a !== void 0 ? _a : defaultConfig.releaseType) !== null && _b !== void 0 ? _b : 'node',
|
|
1073
|
+
bumpMinorPreMajor: (_c = pathConfig.bumpMinorPreMajor) !== null && _c !== void 0 ? _c : defaultConfig.bumpMinorPreMajor,
|
|
1074
|
+
bumpPatchForMinorPreMajor: (_d = pathConfig.bumpPatchForMinorPreMajor) !== null && _d !== void 0 ? _d : defaultConfig.bumpPatchForMinorPreMajor,
|
|
1075
|
+
prereleaseType: (_e = pathConfig.prereleaseType) !== null && _e !== void 0 ? _e : defaultConfig.prereleaseType,
|
|
1076
|
+
versioning: (_f = pathConfig.versioning) !== null && _f !== void 0 ? _f : defaultConfig.versioning,
|
|
1077
|
+
changelogSections: (_g = pathConfig.changelogSections) !== null && _g !== void 0 ? _g : defaultConfig.changelogSections,
|
|
1078
|
+
changelogPath: (_h = pathConfig.changelogPath) !== null && _h !== void 0 ? _h : defaultConfig.changelogPath,
|
|
1079
|
+
changelogHost: (_j = pathConfig.changelogHost) !== null && _j !== void 0 ? _j : defaultConfig.changelogHost,
|
|
1080
|
+
changelogType: (_k = pathConfig.changelogType) !== null && _k !== void 0 ? _k : defaultConfig.changelogType,
|
|
1081
|
+
includeCommitAuthors: (_l = pathConfig.includeCommitAuthors) !== null && _l !== void 0 ? _l : defaultConfig.includeCommitAuthors,
|
|
1082
|
+
releaseAs: (_m = pathConfig.releaseAs) !== null && _m !== void 0 ? _m : defaultConfig.releaseAs,
|
|
1083
|
+
skipGithubRelease: (_o = pathConfig.skipGithubRelease) !== null && _o !== void 0 ? _o : defaultConfig.skipGithubRelease,
|
|
1084
|
+
skipChangelog: (_p = pathConfig.skipChangelog) !== null && _p !== void 0 ? _p : defaultConfig.skipChangelog,
|
|
1085
|
+
draft: (_q = pathConfig.draft) !== null && _q !== void 0 ? _q : defaultConfig.draft,
|
|
1086
|
+
forceTag: (_r = pathConfig.forceTag) !== null && _r !== void 0 ? _r : defaultConfig.forceTag,
|
|
1087
|
+
draftPullRequest: (_s = pathConfig.draftPullRequest) !== null && _s !== void 0 ? _s : defaultConfig.draftPullRequest,
|
|
1088
|
+
prerelease: (_t = pathConfig.prerelease) !== null && _t !== void 0 ? _t : defaultConfig.prerelease,
|
|
1089
|
+
component: (_u = pathConfig.component) !== null && _u !== void 0 ? _u : defaultConfig.component,
|
|
1090
|
+
packageName: (_v = pathConfig.packageName) !== null && _v !== void 0 ? _v : defaultConfig.packageName,
|
|
1091
|
+
versionFile: (_w = pathConfig.versionFile) !== null && _w !== void 0 ? _w : defaultConfig.versionFile,
|
|
1092
|
+
extraFiles: (_x = pathConfig.extraFiles) !== null && _x !== void 0 ? _x : defaultConfig.extraFiles,
|
|
1093
|
+
includeComponentInTag: (_y = pathConfig.includeComponentInTag) !== null && _y !== void 0 ? _y : defaultConfig.includeComponentInTag,
|
|
1094
|
+
includeVInTag: (_z = pathConfig.includeVInTag) !== null && _z !== void 0 ? _z : defaultConfig.includeVInTag,
|
|
1095
|
+
includeVInReleaseName: (_0 = pathConfig.includeVInReleaseName) !== null && _0 !== void 0 ? _0 : defaultConfig.includeVInReleaseName,
|
|
1096
|
+
tagSeparator: (_1 = pathConfig.tagSeparator) !== null && _1 !== void 0 ? _1 : defaultConfig.tagSeparator,
|
|
1097
|
+
pullRequestTitlePattern: (_2 = pathConfig.pullRequestTitlePattern) !== null && _2 !== void 0 ? _2 : defaultConfig.pullRequestTitlePattern,
|
|
1098
|
+
pullRequestHeader: (_3 = pathConfig.pullRequestHeader) !== null && _3 !== void 0 ? _3 : defaultConfig.pullRequestHeader,
|
|
1099
|
+
pullRequestFooter: (_4 = pathConfig.pullRequestFooter) !== null && _4 !== void 0 ? _4 : defaultConfig.pullRequestFooter,
|
|
1100
|
+
componentNoSpace: (_5 = pathConfig.componentNoSpace) !== null && _5 !== void 0 ? _5 : defaultConfig.componentNoSpace,
|
|
1101
|
+
separatePullRequests: (_6 = pathConfig.separatePullRequests) !== null && _6 !== void 0 ? _6 : defaultConfig.separatePullRequests,
|
|
1102
|
+
skipSnapshot: (_7 = pathConfig.skipSnapshot) !== null && _7 !== void 0 ? _7 : defaultConfig.skipSnapshot,
|
|
1103
|
+
initialVersion: (_8 = pathConfig.initialVersion) !== null && _8 !== void 0 ? _8 : defaultConfig.initialVersion,
|
|
1104
|
+
extraLabels: (_9 = pathConfig.extraLabels) !== null && _9 !== void 0 ? _9 : defaultConfig.extraLabels,
|
|
1105
|
+
excludePaths: (_10 = pathConfig.excludePaths) !== null && _10 !== void 0 ? _10 : defaultConfig.excludePaths,
|
|
1106
|
+
dateFormat: (_11 = pathConfig.dateFormat) !== null && _11 !== void 0 ? _11 : defaultConfig.dateFormat,
|
|
1107
|
+
};
|
|
1108
|
+
}
|
|
1109
|
+
/**
|
|
1110
|
+
* Helper to compare if a list of labels fully contains another list of labels
|
|
1111
|
+
* @param {string[]} expected List of labels expected to be contained
|
|
1112
|
+
* @param {string[]} existing List of existing labels to consider
|
|
1113
|
+
*/
|
|
1114
|
+
function hasAllLabels(expected, existing) {
|
|
1115
|
+
const existingSet = new Set(existing);
|
|
1116
|
+
for (const label of expected) {
|
|
1117
|
+
if (!existingSet.has(label)) {
|
|
1118
|
+
return false;
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
return true;
|
|
1122
|
+
}
|
|
1123
|
+
function commitsAfterSha(commits, lastReleaseSha) {
|
|
1124
|
+
if (!commits) {
|
|
1125
|
+
return [];
|
|
1126
|
+
}
|
|
1127
|
+
const index = commits.findIndex(commit => commit.sha === lastReleaseSha);
|
|
1128
|
+
if (index === -1) {
|
|
1129
|
+
return commits;
|
|
1130
|
+
}
|
|
1131
|
+
return commits.slice(0, index);
|
|
1132
|
+
}
|
|
1133
|
+
/**
|
|
1134
|
+
* Returns true if the release tag matches the configured component. Returns
|
|
1135
|
+
* true if `includeComponentInTag` is false and there is no component in the
|
|
1136
|
+
* tag, OR if the tag's component matches the release component.
|
|
1137
|
+
*/
|
|
1138
|
+
function tagMatchesConfig(tag, branchComponent, includeComponentInTag) {
|
|
1139
|
+
return ((includeComponentInTag && tag.component === branchComponent) ||
|
|
1140
|
+
(!includeComponentInTag && !tag.component));
|
|
1141
|
+
}
|
|
1142
|
+
//# sourceMappingURL=manifest.js.map
|