release-please 13.0.0-candidate.3 → 13.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +59 -0
- package/README.md +33 -131
- package/build/src/bin/release-please.d.ts +0 -1
- package/build/src/bin/release-please.js +24 -6
- package/build/src/changelog-notes/default.d.ts +1 -3
- package/build/src/changelog-notes/default.js +2 -3
- package/build/src/changelog-notes/github.d.ts +8 -0
- package/build/src/changelog-notes/github.js +26 -0
- package/build/src/changelog-notes.d.ts +3 -0
- package/build/src/changelog-notes.js +24 -0
- package/build/src/commit.d.ts +1 -1
- package/build/src/commit.js +14 -1
- package/build/src/factory.d.ts +13 -0
- package/build/src/factory.js +26 -1
- package/build/src/github.d.ts +48 -7
- package/build/src/github.js +73 -19
- package/build/src/index.d.ts +5 -0
- package/build/src/index.js +27 -0
- package/build/src/manifest.d.ts +7 -3
- package/build/src/manifest.js +93 -24
- package/build/src/plugins/cargo-workspace.js +2 -2
- package/build/src/plugins/merge.js +4 -1
- package/build/src/plugins/node-workspace.js +2 -2
- package/build/src/pull-request.d.ts +8 -8
- package/build/src/release-pull-request.d.ts +6 -6
- package/build/src/strategies/base.d.ts +108 -0
- package/build/src/strategies/base.js +253 -0
- package/build/src/strategies/dart.d.ts +2 -2
- package/build/src/strategies/dart.js +2 -2
- package/build/src/strategies/elixir.d.ts +2 -2
- package/build/src/strategies/elixir.js +2 -2
- package/build/src/strategies/go-yoshi.d.ts +3 -3
- package/build/src/strategies/go-yoshi.js +10 -2
- package/build/src/strategies/go.d.ts +2 -2
- package/build/src/strategies/go.js +2 -2
- package/build/src/strategies/helm.d.ts +2 -2
- package/build/src/strategies/helm.js +2 -2
- package/build/src/strategies/java-yoshi.d.ts +5 -4
- package/build/src/strategies/java-yoshi.js +58 -2
- package/build/src/strategies/krm-blueprint.d.ts +2 -2
- package/build/src/strategies/krm-blueprint.js +3 -3
- package/build/src/strategies/node.d.ts +2 -2
- package/build/src/strategies/node.js +2 -2
- package/build/src/strategies/ocaml.d.ts +2 -2
- package/build/src/strategies/ocaml.js +2 -2
- package/build/src/strategies/php-yoshi.d.ts +3 -3
- package/build/src/strategies/php-yoshi.js +3 -2
- package/build/src/strategies/php.d.ts +3 -3
- package/build/src/strategies/php.js +2 -2
- package/build/src/strategies/python.d.ts +2 -2
- package/build/src/strategies/python.js +2 -2
- package/build/src/strategies/ruby-yoshi.d.ts +3 -3
- package/build/src/strategies/ruby-yoshi.js +7 -2
- package/build/src/strategies/ruby.d.ts +3 -3
- package/build/src/strategies/ruby.js +2 -2
- package/build/src/strategies/rust.d.ts +2 -2
- package/build/src/strategies/rust.js +2 -2
- package/build/src/strategies/simple.d.ts +2 -2
- package/build/src/strategies/simple.js +2 -2
- package/build/src/strategies/terraform-module.d.ts +2 -2
- package/build/src/strategies/terraform-module.js +2 -2
- package/build/src/strategy.d.ts +8 -70
- package/build/src/strategy.js +0 -226
- package/build/src/updaters/go/version-go.d.ts +4 -0
- package/build/src/updaters/go/version-go.js +24 -0
- package/build/src/updaters/rust/cargo-toml.js +5 -1
- package/build/src/util/branch-name.js +65 -7
- package/build/src/util/commit-split.js +3 -0
- package/build/src/util/pull-request-title.js +1 -0
- package/build/src/version.d.ts +28 -5
- package/build/src/version.js +26 -0
- package/build/src/versioning-strategies/always-bump-patch.d.ts +4 -0
- package/build/src/versioning-strategies/always-bump-patch.js +4 -0
- package/build/src/versioning-strategies/default.d.ts +31 -0
- package/build/src/versioning-strategies/default.js +31 -0
- package/build/src/versioning-strategies/dependency-manifest.d.ts +8 -0
- package/build/src/versioning-strategies/dependency-manifest.js +8 -0
- package/build/src/versioning-strategies/java-add-snapshot.d.ts +4 -0
- package/build/src/versioning-strategies/java-add-snapshot.js +6 -5
- package/build/src/versioning-strategies/java-snapshot.d.ts +4 -0
- package/build/src/versioning-strategies/java-snapshot.js +4 -1
- package/build/src/versioning-strategies/service-pack.d.ts +5 -0
- package/build/src/versioning-strategies/service-pack.js +10 -3
- package/build/src/versioning-strategy.d.ts +67 -5
- package/build/src/versioning-strategy.js +37 -10
- package/package.json +4 -4
- package/build/src/release-notes.d.ts +0 -29
- package/build/src/release-notes.js +0 -71
package/build/src/github.d.ts
CHANGED
|
@@ -36,6 +36,16 @@ export interface GitHubFileContents {
|
|
|
36
36
|
parsedContent: string;
|
|
37
37
|
}
|
|
38
38
|
declare type CommitFilter = (commit: Commit) => boolean;
|
|
39
|
+
interface CommitIteratorOptions {
|
|
40
|
+
maxResults?: number;
|
|
41
|
+
backfillFiles?: boolean;
|
|
42
|
+
}
|
|
43
|
+
interface ReleaseIteratorOptions {
|
|
44
|
+
maxResults?: number;
|
|
45
|
+
}
|
|
46
|
+
interface TagIteratorOptions {
|
|
47
|
+
maxResults?: number;
|
|
48
|
+
}
|
|
39
49
|
export interface GitHubRelease {
|
|
40
50
|
name?: string;
|
|
41
51
|
tagName: string;
|
|
@@ -44,6 +54,10 @@ export interface GitHubRelease {
|
|
|
44
54
|
url: string;
|
|
45
55
|
draft?: boolean;
|
|
46
56
|
}
|
|
57
|
+
export interface GitHubTag {
|
|
58
|
+
name: string;
|
|
59
|
+
sha: string;
|
|
60
|
+
}
|
|
47
61
|
export declare class GitHub {
|
|
48
62
|
readonly repository: Repository;
|
|
49
63
|
private octokit;
|
|
@@ -81,22 +95,28 @@ export declare class GitHub {
|
|
|
81
95
|
* @param {string} targetBranch Target branch of commit
|
|
82
96
|
* @param {CommitFilter} filter Callback function that returns whether a
|
|
83
97
|
* commit/pull request matches certain criteria
|
|
84
|
-
* @param {
|
|
98
|
+
* @param {CommitIteratorOptions} options Query options
|
|
99
|
+
* @param {number} options.maxResults Limit the number of results searched.
|
|
85
100
|
* Defaults to unlimited.
|
|
101
|
+
* @param {boolean} options.backfillFiles If set, use the REST API for
|
|
102
|
+
* fetching the list of touched files in this commit. Defaults to `false`.
|
|
86
103
|
* @returns {Commit[]} List of commits to current branch
|
|
87
104
|
* @throws {GitHubAPIError} on an API error
|
|
88
105
|
*/
|
|
89
|
-
commitsSince(targetBranch: string, filter: CommitFilter,
|
|
106
|
+
commitsSince(targetBranch: string, filter: CommitFilter, options?: CommitIteratorOptions): Promise<Commit[]>;
|
|
90
107
|
/**
|
|
91
108
|
* Iterate through commit history with a max number of results scanned.
|
|
92
109
|
*
|
|
93
110
|
* @param {string} targetBranch target branch of commit
|
|
94
|
-
* @param {
|
|
111
|
+
* @param {CommitIteratorOptions} options Query options
|
|
112
|
+
* @param {number} options.maxResults Limit the number of results searched.
|
|
95
113
|
* Defaults to unlimited.
|
|
114
|
+
* @param {boolean} options.backfillFiles If set, use the REST API for
|
|
115
|
+
* fetching the list of touched files in this commit. Defaults to `false`.
|
|
96
116
|
* @yields {Commit}
|
|
97
117
|
* @throws {GitHubAPIError} on an API error
|
|
98
118
|
*/
|
|
99
|
-
mergeCommitIterator(targetBranch: string,
|
|
119
|
+
mergeCommitIterator(targetBranch: string, options?: CommitIteratorOptions): AsyncGenerator<Commit, void, unknown>;
|
|
100
120
|
private mergeCommitsGraphQL;
|
|
101
121
|
/**
|
|
102
122
|
* Get the list of file paths modified in a given commit.
|
|
@@ -129,15 +149,29 @@ export declare class GitHub {
|
|
|
129
149
|
*/
|
|
130
150
|
private pullRequestsGraphQL;
|
|
131
151
|
/**
|
|
132
|
-
* Iterate through
|
|
152
|
+
* Iterate through releases with a max number of results scanned.
|
|
133
153
|
*
|
|
134
|
-
* @param {
|
|
154
|
+
* @param {ReleaseIteratorOptions} options Query options
|
|
155
|
+
* @param {number} options.maxResults Limit the number of results searched.
|
|
135
156
|
* Defaults to unlimited.
|
|
136
157
|
* @yields {GitHubRelease}
|
|
137
158
|
* @throws {GitHubAPIError} on an API error
|
|
138
159
|
*/
|
|
139
|
-
releaseIterator(
|
|
160
|
+
releaseIterator(options?: ReleaseIteratorOptions): AsyncGenerator<GitHubRelease, void, unknown>;
|
|
140
161
|
private releaseGraphQL;
|
|
162
|
+
/**
|
|
163
|
+
* Iterate through tags with a max number of results scanned.
|
|
164
|
+
*
|
|
165
|
+
* @param {TagIteratorOptions} options Query options
|
|
166
|
+
* @param {number} options.maxResults Limit the number of results searched.
|
|
167
|
+
* Defaults to unlimited.
|
|
168
|
+
* @yields {GitHubTag}
|
|
169
|
+
* @throws {GitHubAPIError} on an API error
|
|
170
|
+
*/
|
|
171
|
+
tagIterator(options?: TagIteratorOptions): AsyncGenerator<{
|
|
172
|
+
name: string;
|
|
173
|
+
sha: string;
|
|
174
|
+
}, void, unknown>;
|
|
141
175
|
/**
|
|
142
176
|
* Fetch the contents of a file from the configured branch
|
|
143
177
|
*
|
|
@@ -301,5 +335,12 @@ export declare class GitHub {
|
|
|
301
335
|
* @param {number} number The issue/pull request number.
|
|
302
336
|
*/
|
|
303
337
|
addIssueLabels: (labels: string[], number: number) => Promise<void>;
|
|
338
|
+
/**
|
|
339
|
+
* Generate release notes from GitHub at tag
|
|
340
|
+
* @param {string} tagName Name of new release tag
|
|
341
|
+
* @param {string} targetCommitish Target commitish for new tag
|
|
342
|
+
* @param {string} previousTag Optional. Name of previous tag to analyze commits since
|
|
343
|
+
*/
|
|
344
|
+
generateReleaseNotes(tagName: string, targetCommitish: string, previousTag?: string): Promise<string>;
|
|
304
345
|
}
|
|
305
346
|
export {};
|
package/build/src/github.js
CHANGED
|
@@ -139,7 +139,7 @@ class GitHub {
|
|
|
139
139
|
// match the filename
|
|
140
140
|
path.endsWith(filename) &&
|
|
141
141
|
// match the prefix if provided
|
|
142
|
-
(!prefix || path.startsWith(prefix)));
|
|
142
|
+
(!prefix || path.startsWith(`${prefix}/`)));
|
|
143
143
|
})
|
|
144
144
|
.map(file => {
|
|
145
145
|
let path = file.path;
|
|
@@ -277,7 +277,7 @@ class GitHub {
|
|
|
277
277
|
// match the file extension
|
|
278
278
|
path.endsWith(`.${extension}`) &&
|
|
279
279
|
// match the prefix if provided
|
|
280
|
-
(!prefix || path.startsWith(prefix)));
|
|
280
|
+
(!prefix || path.startsWith(`${prefix}/`)));
|
|
281
281
|
})
|
|
282
282
|
.map(file => {
|
|
283
283
|
let path = file.path;
|
|
@@ -454,14 +454,17 @@ class GitHub {
|
|
|
454
454
|
* @param {string} targetBranch Target branch of commit
|
|
455
455
|
* @param {CommitFilter} filter Callback function that returns whether a
|
|
456
456
|
* commit/pull request matches certain criteria
|
|
457
|
-
* @param {
|
|
457
|
+
* @param {CommitIteratorOptions} options Query options
|
|
458
|
+
* @param {number} options.maxResults Limit the number of results searched.
|
|
458
459
|
* Defaults to unlimited.
|
|
460
|
+
* @param {boolean} options.backfillFiles If set, use the REST API for
|
|
461
|
+
* fetching the list of touched files in this commit. Defaults to `false`.
|
|
459
462
|
* @returns {Commit[]} List of commits to current branch
|
|
460
463
|
* @throws {GitHubAPIError} on an API error
|
|
461
464
|
*/
|
|
462
|
-
async commitsSince(targetBranch, filter,
|
|
465
|
+
async commitsSince(targetBranch, filter, options = {}) {
|
|
463
466
|
const commits = [];
|
|
464
|
-
const generator = this.mergeCommitIterator(targetBranch,
|
|
467
|
+
const generator = this.mergeCommitIterator(targetBranch, options);
|
|
465
468
|
for await (const commit of generator) {
|
|
466
469
|
if (filter(commit)) {
|
|
467
470
|
break;
|
|
@@ -474,16 +477,21 @@ class GitHub {
|
|
|
474
477
|
* Iterate through commit history with a max number of results scanned.
|
|
475
478
|
*
|
|
476
479
|
* @param {string} targetBranch target branch of commit
|
|
477
|
-
* @param {
|
|
480
|
+
* @param {CommitIteratorOptions} options Query options
|
|
481
|
+
* @param {number} options.maxResults Limit the number of results searched.
|
|
478
482
|
* Defaults to unlimited.
|
|
483
|
+
* @param {boolean} options.backfillFiles If set, use the REST API for
|
|
484
|
+
* fetching the list of touched files in this commit. Defaults to `false`.
|
|
479
485
|
* @yields {Commit}
|
|
480
486
|
* @throws {GitHubAPIError} on an API error
|
|
481
487
|
*/
|
|
482
|
-
async *mergeCommitIterator(targetBranch,
|
|
488
|
+
async *mergeCommitIterator(targetBranch, options = {}) {
|
|
489
|
+
var _a;
|
|
490
|
+
const maxResults = (_a = options.maxResults) !== null && _a !== void 0 ? _a : Number.MAX_SAFE_INTEGER;
|
|
483
491
|
let cursor = undefined;
|
|
484
492
|
let results = 0;
|
|
485
493
|
while (results < maxResults) {
|
|
486
|
-
const response = await this.mergeCommitsGraphQL(targetBranch, cursor);
|
|
494
|
+
const response = await this.mergeCommitsGraphQL(targetBranch, cursor, options);
|
|
487
495
|
// no response usually means that the branch can't be found
|
|
488
496
|
if (!response) {
|
|
489
497
|
break;
|
|
@@ -498,7 +506,7 @@ class GitHub {
|
|
|
498
506
|
cursor = response.pageInfo.endCursor;
|
|
499
507
|
}
|
|
500
508
|
}
|
|
501
|
-
async mergeCommitsGraphQL(targetBranch, cursor) {
|
|
509
|
+
async mergeCommitsGraphQL(targetBranch, cursor, options = {}) {
|
|
502
510
|
logger_1.logger.debug(`Fetching merge commits on branch ${targetBranch} with cursor: ${cursor}`);
|
|
503
511
|
const response = await this.graphqlRequest({
|
|
504
512
|
query: `query pullRequestsSince($owner: String!, $repo: String!, $num: Int!, $maxFilesChanged: Int, $targetBranch: String!, $cursor: String) {
|
|
@@ -566,7 +574,6 @@ class GitHub {
|
|
|
566
574
|
const commit = {
|
|
567
575
|
sha: graphCommit.sha,
|
|
568
576
|
message: graphCommit.message,
|
|
569
|
-
files: [],
|
|
570
577
|
};
|
|
571
578
|
const pullRequest = graphCommit.associatedPullRequests.nodes.find(pr => {
|
|
572
579
|
return pr.mergeCommit && pr.mergeCommit.oid === graphCommit.sha;
|
|
@@ -587,7 +594,7 @@ class GitHub {
|
|
|
587
594
|
// information for commits with associated pull requests
|
|
588
595
|
commit.files = files;
|
|
589
596
|
}
|
|
590
|
-
else {
|
|
597
|
+
else if (options.backfillFiles) {
|
|
591
598
|
// In this case, there is no squashed merge commit. This could be a simple
|
|
592
599
|
// merge commit, a rebase merge commit, or a direct commit to the branch.
|
|
593
600
|
// Fallback to fetching the list of commits from the REST API. In the future
|
|
@@ -708,23 +715,28 @@ class GitHub {
|
|
|
708
715
|
};
|
|
709
716
|
}
|
|
710
717
|
/**
|
|
711
|
-
* Iterate through
|
|
718
|
+
* Iterate through releases with a max number of results scanned.
|
|
712
719
|
*
|
|
713
|
-
* @param {
|
|
720
|
+
* @param {ReleaseIteratorOptions} options Query options
|
|
721
|
+
* @param {number} options.maxResults Limit the number of results searched.
|
|
714
722
|
* Defaults to unlimited.
|
|
715
723
|
* @yields {GitHubRelease}
|
|
716
724
|
* @throws {GitHubAPIError} on an API error
|
|
717
725
|
*/
|
|
718
|
-
async *releaseIterator(
|
|
726
|
+
async *releaseIterator(options = {}) {
|
|
727
|
+
var _a;
|
|
728
|
+
const maxResults = (_a = options.maxResults) !== null && _a !== void 0 ? _a : Number.MAX_SAFE_INTEGER;
|
|
719
729
|
let results = 0;
|
|
720
730
|
let cursor = undefined;
|
|
721
|
-
while (
|
|
731
|
+
while (true) {
|
|
722
732
|
const response = await this.releaseGraphQL(cursor);
|
|
723
733
|
if (!response) {
|
|
724
734
|
break;
|
|
725
735
|
}
|
|
726
736
|
for (let i = 0; i < response.data.length; i++) {
|
|
727
|
-
results += 1
|
|
737
|
+
if ((results += 1) > maxResults) {
|
|
738
|
+
break;
|
|
739
|
+
}
|
|
728
740
|
yield response.data[i];
|
|
729
741
|
}
|
|
730
742
|
if (!response.pageInfo.hasNextPage) {
|
|
@@ -763,12 +775,11 @@ class GitHub {
|
|
|
763
775
|
repo: this.repository.repo,
|
|
764
776
|
num: 25,
|
|
765
777
|
});
|
|
766
|
-
if (!response.repository.releases) {
|
|
778
|
+
if (!response.repository.releases.nodes.length) {
|
|
767
779
|
logger_1.logger.warn('Could not find releases.');
|
|
768
780
|
return null;
|
|
769
781
|
}
|
|
770
|
-
const releases =
|
|
771
|
-
[]);
|
|
782
|
+
const releases = response.repository.releases.nodes;
|
|
772
783
|
return {
|
|
773
784
|
pageInfo: response.repository.releases.pageInfo,
|
|
774
785
|
data: releases
|
|
@@ -788,6 +799,33 @@ class GitHub {
|
|
|
788
799
|
}),
|
|
789
800
|
};
|
|
790
801
|
}
|
|
802
|
+
/**
|
|
803
|
+
* Iterate through tags with a max number of results scanned.
|
|
804
|
+
*
|
|
805
|
+
* @param {TagIteratorOptions} options Query options
|
|
806
|
+
* @param {number} options.maxResults Limit the number of results searched.
|
|
807
|
+
* Defaults to unlimited.
|
|
808
|
+
* @yields {GitHubTag}
|
|
809
|
+
* @throws {GitHubAPIError} on an API error
|
|
810
|
+
*/
|
|
811
|
+
async *tagIterator(options = {}) {
|
|
812
|
+
const maxResults = options.maxResults || Number.MAX_SAFE_INTEGER;
|
|
813
|
+
let results = 0;
|
|
814
|
+
for await (const response of this.octokit.paginate.iterator(this.octokit.rest.repos.listTags, {
|
|
815
|
+
owner: this.repository.owner,
|
|
816
|
+
repo: this.repository.repo,
|
|
817
|
+
})) {
|
|
818
|
+
for (const tag of response.data) {
|
|
819
|
+
if ((results += 1) > maxResults) {
|
|
820
|
+
break;
|
|
821
|
+
}
|
|
822
|
+
yield {
|
|
823
|
+
name: tag.name,
|
|
824
|
+
sha: tag.commit.sha,
|
|
825
|
+
};
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
}
|
|
791
829
|
/**
|
|
792
830
|
* Fetch the contents of a file from the configured branch
|
|
793
831
|
*
|
|
@@ -924,6 +962,22 @@ class GitHub {
|
|
|
924
962
|
async findFilesByExtension(extension, prefix) {
|
|
925
963
|
return this.findFilesByExtensionAndRef(extension, this.repository.defaultBranch, prefix);
|
|
926
964
|
}
|
|
965
|
+
/**
|
|
966
|
+
* Generate release notes from GitHub at tag
|
|
967
|
+
* @param {string} tagName Name of new release tag
|
|
968
|
+
* @param {string} targetCommitish Target commitish for new tag
|
|
969
|
+
* @param {string} previousTag Optional. Name of previous tag to analyze commits since
|
|
970
|
+
*/
|
|
971
|
+
async generateReleaseNotes(tagName, targetCommitish, previousTag) {
|
|
972
|
+
const resp = await this.octokit.repos.generateReleaseNotes({
|
|
973
|
+
owner: this.repository.owner,
|
|
974
|
+
repo: this.repository.repo,
|
|
975
|
+
tag_name: tagName,
|
|
976
|
+
previous_tag_name: previousTag,
|
|
977
|
+
target_commitish: targetCommitish,
|
|
978
|
+
});
|
|
979
|
+
return resp.data.body;
|
|
980
|
+
}
|
|
927
981
|
}
|
|
928
982
|
exports.GitHub = GitHub;
|
|
929
983
|
// Takes a potentially unqualified branch name, and turns it
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export * as Errors from './errors';
|
|
2
|
+
export { Manifest, ReleaserConfig, ManifestOptions } from './manifest';
|
|
3
|
+
export { ReleaseType, getReleaserTypes, VersioningStrategyType, getVersioningStrategyTypes, ChangelogNotesType, getChangelogTypes, } from './factory';
|
|
4
|
+
export { Logger, setLogger } from './util/logger';
|
|
5
|
+
export { GitHub } from './github';
|
|
@@ -0,0 +1,27 @@
|
|
|
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.Errors = require("./errors");
|
|
17
|
+
var manifest_1 = require("./manifest");
|
|
18
|
+
Object.defineProperty(exports, "Manifest", { enumerable: true, get: function () { return manifest_1.Manifest; } });
|
|
19
|
+
var factory_1 = require("./factory");
|
|
20
|
+
Object.defineProperty(exports, "getReleaserTypes", { enumerable: true, get: function () { return factory_1.getReleaserTypes; } });
|
|
21
|
+
Object.defineProperty(exports, "getVersioningStrategyTypes", { enumerable: true, get: function () { return factory_1.getVersioningStrategyTypes; } });
|
|
22
|
+
Object.defineProperty(exports, "getChangelogTypes", { enumerable: true, get: function () { return factory_1.getChangelogTypes; } });
|
|
23
|
+
var logger_1 = require("./util/logger");
|
|
24
|
+
Object.defineProperty(exports, "setLogger", { enumerable: true, get: function () { return logger_1.setLogger; } });
|
|
25
|
+
var github_1 = require("./github");
|
|
26
|
+
Object.defineProperty(exports, "GitHub", { enumerable: true, get: function () { return github_1.GitHub; } });
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
package/build/src/manifest.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { GitHub, GitHubRelease } from './github';
|
|
|
3
3
|
import { Version } from './version';
|
|
4
4
|
import { PullRequest } from './pull-request';
|
|
5
5
|
import { ReleasePullRequest } from './release-pull-request';
|
|
6
|
-
import { ReleaseType, VersioningStrategyType } from './factory';
|
|
6
|
+
import { ReleaseType, VersioningStrategyType, ChangelogNotesType } from './factory';
|
|
7
7
|
import { Release } from './release';
|
|
8
8
|
/**
|
|
9
9
|
* These are configurations provided to each strategy per-path.
|
|
@@ -13,8 +13,6 @@ export interface ReleaserConfig {
|
|
|
13
13
|
versioning?: VersioningStrategyType;
|
|
14
14
|
bumpMinorPreMajor?: boolean;
|
|
15
15
|
bumpPatchForMinorPreMajor?: boolean;
|
|
16
|
-
changelogSections?: ChangelogSection[];
|
|
17
|
-
changelogPath?: string;
|
|
18
16
|
releaseAs?: string;
|
|
19
17
|
skipGithubRelease?: boolean;
|
|
20
18
|
draft?: boolean;
|
|
@@ -22,6 +20,10 @@ export interface ReleaserConfig {
|
|
|
22
20
|
component?: string;
|
|
23
21
|
packageName?: string;
|
|
24
22
|
includeComponentInTag?: boolean;
|
|
23
|
+
pullRequestTitlePattern?: string;
|
|
24
|
+
changelogSections?: ChangelogSection[];
|
|
25
|
+
changelogPath?: string;
|
|
26
|
+
changelogType?: ChangelogNotesType;
|
|
25
27
|
versionFile?: string;
|
|
26
28
|
extraFiles?: string[];
|
|
27
29
|
}
|
|
@@ -47,6 +49,8 @@ interface ReleaserConfigJson {
|
|
|
47
49
|
label?: string;
|
|
48
50
|
'release-label'?: string;
|
|
49
51
|
'include-component-in-tag'?: boolean;
|
|
52
|
+
'changelog-type'?: ChangelogNotesType;
|
|
53
|
+
'pull-request-title-pattern'?: string;
|
|
50
54
|
'version-file'?: string;
|
|
51
55
|
'extra-files'?: string[];
|
|
52
56
|
}
|
package/build/src/manifest.js
CHANGED
|
@@ -58,6 +58,7 @@ class Manifest {
|
|
|
58
58
|
* pull request. Defaults to `[autorelease: tagged]`
|
|
59
59
|
*/
|
|
60
60
|
constructor(github, targetBranch, repositoryConfig, releasedVersions, manifestOptions) {
|
|
61
|
+
var _a;
|
|
61
62
|
this.repository = github.repository;
|
|
62
63
|
this.github = github;
|
|
63
64
|
this.targetBranch = targetBranch;
|
|
@@ -65,7 +66,7 @@ class Manifest {
|
|
|
65
66
|
this.releasedVersions = releasedVersions;
|
|
66
67
|
this.manifestPath =
|
|
67
68
|
(manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.manifestPath) || exports.DEFAULT_RELEASE_PLEASE_MANIFEST;
|
|
68
|
-
this.separatePullRequests = (manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.separatePullRequests)
|
|
69
|
+
this.separatePullRequests = (_a = manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.separatePullRequests) !== null && _a !== void 0 ? _a : Object.keys(repositoryConfig).length === 1;
|
|
69
70
|
this.plugins = (manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.plugins) || [];
|
|
70
71
|
this.fork = (manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.fork) || false;
|
|
71
72
|
this.signoffUser = manifestOptions === null || manifestOptions === void 0 ? void 0 : manifestOptions.signoff;
|
|
@@ -127,11 +128,14 @@ class Manifest {
|
|
|
127
128
|
});
|
|
128
129
|
const component = await strategy.getComponent();
|
|
129
130
|
const releasedVersions = {};
|
|
130
|
-
const latestVersion = await latestReleaseVersion(github, targetBranch, config.includeComponentInTag ? component : '');
|
|
131
|
+
const latestVersion = await latestReleaseVersion(github, targetBranch, config.includeComponentInTag ? component : '', config.pullRequestTitlePattern);
|
|
131
132
|
if (latestVersion) {
|
|
132
133
|
releasedVersions[path] = latestVersion;
|
|
133
134
|
}
|
|
134
|
-
return new Manifest(github, targetBranch, repositoryConfig, releasedVersions,
|
|
135
|
+
return new Manifest(github, targetBranch, repositoryConfig, releasedVersions, {
|
|
136
|
+
separatePullRequests: true,
|
|
137
|
+
...manifestOptions,
|
|
138
|
+
});
|
|
135
139
|
}
|
|
136
140
|
/**
|
|
137
141
|
* Build all candidate pull requests for this repository.
|
|
@@ -154,7 +158,9 @@ class Manifest {
|
|
|
154
158
|
const releaseShasByPath = {};
|
|
155
159
|
// Releases by path
|
|
156
160
|
const releasesByPath = {};
|
|
157
|
-
for await (const release of this.github.releaseIterator(
|
|
161
|
+
for await (const release of this.github.releaseIterator({
|
|
162
|
+
maxResults: 400,
|
|
163
|
+
})) {
|
|
158
164
|
// logger.debug(release);
|
|
159
165
|
const tagName = tag_name_1.TagName.parse(release.tagName);
|
|
160
166
|
if (!tagName) {
|
|
@@ -198,7 +204,10 @@ class Manifest {
|
|
|
198
204
|
// seen all release commits
|
|
199
205
|
logger_1.logger.info('Collecting commits since all latest releases');
|
|
200
206
|
const commits = [];
|
|
201
|
-
const commitGenerator = this.github.mergeCommitIterator(this.targetBranch,
|
|
207
|
+
const commitGenerator = this.github.mergeCommitIterator(this.targetBranch, {
|
|
208
|
+
maxResults: 500,
|
|
209
|
+
backfillFiles: true,
|
|
210
|
+
});
|
|
202
211
|
const releaseShas = new Set(Object.values(releaseShasByPath));
|
|
203
212
|
logger_1.logger.debug(releaseShas);
|
|
204
213
|
const expectedShas = releaseShas.size;
|
|
@@ -260,7 +269,19 @@ class Manifest {
|
|
|
260
269
|
logger_1.logger.warn('No latest release pull request found.');
|
|
261
270
|
}
|
|
262
271
|
const strategy = strategiesByPath[path];
|
|
263
|
-
|
|
272
|
+
let latestRelease = releasesByPath[path];
|
|
273
|
+
if (!latestRelease &&
|
|
274
|
+
this.releasedVersions[path] &&
|
|
275
|
+
this.releasedVersions[path].toString() !== '0.0.0') {
|
|
276
|
+
const version = this.releasedVersions[path];
|
|
277
|
+
const component = await strategy.getComponent();
|
|
278
|
+
logger_1.logger.info(`No latest release found for path: ${path}, component: ${component}, but a previous version (${version.toString()}) was specified in the manifest.`);
|
|
279
|
+
latestRelease = {
|
|
280
|
+
tag: new tag_name_1.TagName(version, component),
|
|
281
|
+
sha: '',
|
|
282
|
+
notes: '',
|
|
283
|
+
};
|
|
284
|
+
}
|
|
264
285
|
const releasePullRequest = await strategy.buildReleasePullRequest(pathCommits, latestRelease, (_a = config.draftPullRequest) !== null && _a !== void 0 ? _a : this.draftPullRequest, this.labels);
|
|
265
286
|
if (releasePullRequest) {
|
|
266
287
|
if (releasePullRequest.version) {
|
|
@@ -523,7 +544,7 @@ exports.Manifest = Manifest;
|
|
|
523
544
|
*/
|
|
524
545
|
function extractReleaserConfig(config) {
|
|
525
546
|
return {
|
|
526
|
-
releaseType: config['release-type']
|
|
547
|
+
releaseType: config['release-type'],
|
|
527
548
|
bumpMinorPreMajor: config['bump-minor-pre-major'],
|
|
528
549
|
bumpPatchForMinorPreMajor: config['bump-patch-for-minor-pre-major'],
|
|
529
550
|
changelogSections: config['changelog-sections'],
|
|
@@ -537,6 +558,8 @@ function extractReleaserConfig(config) {
|
|
|
537
558
|
versionFile: config['version-file'],
|
|
538
559
|
extraFiles: config['extra-files'],
|
|
539
560
|
includeComponentInTag: config['include-component-in-tag'],
|
|
561
|
+
changelogType: config['changelog-type'],
|
|
562
|
+
pullRequestTitlePattern: config['pull-request-title-pattern'],
|
|
540
563
|
};
|
|
541
564
|
}
|
|
542
565
|
/**
|
|
@@ -586,7 +609,7 @@ async function parseReleasedVersions(github, manifestFile, branch) {
|
|
|
586
609
|
* @param {boolean} preRelease - Whether or not to return pre-release
|
|
587
610
|
* versions. Defaults to false.
|
|
588
611
|
*/
|
|
589
|
-
async function latestReleaseVersion(github, targetBranch, prefix) {
|
|
612
|
+
async function latestReleaseVersion(github, targetBranch, prefix, pullRequestTitlePattern) {
|
|
590
613
|
var _a;
|
|
591
614
|
const branchPrefix = prefix
|
|
592
615
|
? prefix.endsWith('-')
|
|
@@ -594,11 +617,15 @@ async function latestReleaseVersion(github, targetBranch, prefix) {
|
|
|
594
617
|
: prefix
|
|
595
618
|
: undefined;
|
|
596
619
|
logger_1.logger.info(`Looking for latest release on branch: ${targetBranch} with prefix: ${prefix}`);
|
|
620
|
+
// collect set of recent commit SHAs seen to verify that the release
|
|
621
|
+
// is in the current branch
|
|
622
|
+
const commitShas = new Set();
|
|
597
623
|
// only look at the last 250 or so commits to find the latest tag - we
|
|
598
624
|
// don't want to scan the entire repository history if this repo has never
|
|
599
625
|
// been released
|
|
600
|
-
const generator = github.mergeCommitIterator(targetBranch, 250);
|
|
626
|
+
const generator = github.mergeCommitIterator(targetBranch, { maxResults: 250 });
|
|
601
627
|
for await (const commitWithPullRequest of generator) {
|
|
628
|
+
commitShas.add(commitWithPullRequest.sha);
|
|
602
629
|
const mergedPullRequest = commitWithPullRequest.pullRequest;
|
|
603
630
|
if (!mergedPullRequest) {
|
|
604
631
|
continue;
|
|
@@ -612,7 +639,7 @@ async function latestReleaseVersion(github, targetBranch, prefix) {
|
|
|
612
639
|
if (branchName.getComponent() !== branchPrefix) {
|
|
613
640
|
continue;
|
|
614
641
|
}
|
|
615
|
-
const pullRequestTitle = pull_request_title_1.PullRequestTitle.parse(mergedPullRequest.title);
|
|
642
|
+
const pullRequestTitle = pull_request_title_1.PullRequestTitle.parse(mergedPullRequest.title, pullRequestTitlePattern);
|
|
616
643
|
if (!pullRequestTitle) {
|
|
617
644
|
continue;
|
|
618
645
|
}
|
|
@@ -623,23 +650,65 @@ async function latestReleaseVersion(github, targetBranch, prefix) {
|
|
|
623
650
|
}
|
|
624
651
|
return version;
|
|
625
652
|
}
|
|
626
|
-
|
|
653
|
+
// If not found from recent pull requests, look at releases. Iterate
|
|
654
|
+
// through releases finding valid tags, then cross reference
|
|
655
|
+
const releaseGenerator = github.releaseIterator();
|
|
656
|
+
const candidateReleaseVersions = [];
|
|
657
|
+
for await (const release of releaseGenerator) {
|
|
658
|
+
const tagName = tag_name_1.TagName.parse(release.tagName);
|
|
659
|
+
if (!tagName) {
|
|
660
|
+
continue;
|
|
661
|
+
}
|
|
662
|
+
if (tagName.component === branchPrefix) {
|
|
663
|
+
logger_1.logger.debug(`found release for ${prefix}`, tagName.version);
|
|
664
|
+
if (!commitShas.has(release.sha)) {
|
|
665
|
+
logger_1.logger.debug(`SHA not found in recent commits to branch ${targetBranch}, skipping`);
|
|
666
|
+
continue;
|
|
667
|
+
}
|
|
668
|
+
candidateReleaseVersions.push(tagName.version);
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
logger_1.logger.debug(`found ${candidateReleaseVersions.length} possible releases.`, candidateReleaseVersions);
|
|
672
|
+
if (candidateReleaseVersions.length > 0) {
|
|
673
|
+
// Find largest release number (sort descending then return first)
|
|
674
|
+
return candidateReleaseVersions.sort((a, b) => b.compare(a))[0];
|
|
675
|
+
}
|
|
676
|
+
// If not found from recent pull requests or releases, look at tags. Iterate
|
|
677
|
+
// through tags and cross reference against SHAs in this branch
|
|
678
|
+
const tagGenerator = github.tagIterator();
|
|
679
|
+
const candidateTagVersion = [];
|
|
680
|
+
for await (const tag of tagGenerator) {
|
|
681
|
+
const tagName = tag_name_1.TagName.parse(tag.name);
|
|
682
|
+
if (!tagName) {
|
|
683
|
+
continue;
|
|
684
|
+
}
|
|
685
|
+
if (tagName.component === branchPrefix) {
|
|
686
|
+
if (!commitShas.has(tag.sha)) {
|
|
687
|
+
logger_1.logger.debug(`SHA not found in recent commits to branch ${targetBranch}, skipping`);
|
|
688
|
+
continue;
|
|
689
|
+
}
|
|
690
|
+
candidateTagVersion.push(tagName.version);
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
logger_1.logger.debug(`found ${candidateTagVersion.length} possible tags.`, candidateTagVersion);
|
|
694
|
+
// Find largest release number (sort descending then return first)
|
|
695
|
+
return candidateTagVersion.sort((a, b) => b.compare(a))[0];
|
|
627
696
|
}
|
|
628
697
|
function mergeReleaserConfig(defaultConfig, pathConfig) {
|
|
629
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
698
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
630
699
|
return {
|
|
631
|
-
releaseType: (_a = pathConfig.releaseType) !== null && _a !== void 0 ? _a : defaultConfig.releaseType,
|
|
632
|
-
bumpMinorPreMajor: (
|
|
633
|
-
bumpPatchForMinorPreMajor: (
|
|
634
|
-
changelogSections: (
|
|
635
|
-
changelogPath: (
|
|
636
|
-
releaseAs: (
|
|
637
|
-
skipGithubRelease: (
|
|
638
|
-
draft: (
|
|
639
|
-
component: (
|
|
640
|
-
packageName: (
|
|
641
|
-
versionFile: (
|
|
642
|
-
extraFiles: (
|
|
700
|
+
releaseType: (_b = (_a = pathConfig.releaseType) !== null && _a !== void 0 ? _a : defaultConfig.releaseType) !== null && _b !== void 0 ? _b : 'node',
|
|
701
|
+
bumpMinorPreMajor: (_c = pathConfig.bumpMinorPreMajor) !== null && _c !== void 0 ? _c : defaultConfig.bumpMinorPreMajor,
|
|
702
|
+
bumpPatchForMinorPreMajor: (_d = pathConfig.bumpPatchForMinorPreMajor) !== null && _d !== void 0 ? _d : defaultConfig.bumpPatchForMinorPreMajor,
|
|
703
|
+
changelogSections: (_e = pathConfig.changelogSections) !== null && _e !== void 0 ? _e : defaultConfig.changelogSections,
|
|
704
|
+
changelogPath: (_f = pathConfig.changelogPath) !== null && _f !== void 0 ? _f : defaultConfig.changelogPath,
|
|
705
|
+
releaseAs: (_g = pathConfig.releaseAs) !== null && _g !== void 0 ? _g : defaultConfig.releaseAs,
|
|
706
|
+
skipGithubRelease: (_h = pathConfig.skipGithubRelease) !== null && _h !== void 0 ? _h : defaultConfig.skipGithubRelease,
|
|
707
|
+
draft: (_j = pathConfig.draft) !== null && _j !== void 0 ? _j : defaultConfig.draft,
|
|
708
|
+
component: (_k = pathConfig.component) !== null && _k !== void 0 ? _k : defaultConfig.component,
|
|
709
|
+
packageName: (_l = pathConfig.packageName) !== null && _l !== void 0 ? _l : defaultConfig.packageName,
|
|
710
|
+
versionFile: (_m = pathConfig.versionFile) !== null && _m !== void 0 ? _m : defaultConfig.versionFile,
|
|
711
|
+
extraFiles: (_o = pathConfig.extraFiles) !== null && _o !== void 0 ? _o : defaultConfig.extraFiles,
|
|
643
712
|
};
|
|
644
713
|
}
|
|
645
714
|
/**
|
|
@@ -25,6 +25,7 @@ const changelog_1 = require("../updaters/changelog");
|
|
|
25
25
|
const pull_request_title_1 = require("../util/pull-request-title");
|
|
26
26
|
const pull_request_body_1 = require("../util/pull-request-body");
|
|
27
27
|
const branch_name_1 = require("../util/branch-name");
|
|
28
|
+
const versioning_strategy_1 = require("../versioning-strategy");
|
|
28
29
|
/**
|
|
29
30
|
* The plugin analyzed a cargo workspace and will bump dependencies
|
|
30
31
|
* of managed packages if those dependencies are being updated.
|
|
@@ -84,8 +85,7 @@ class CargoWorkspace extends workspace_1.WorkspacePlugin {
|
|
|
84
85
|
}
|
|
85
86
|
bumpVersion(pkg) {
|
|
86
87
|
const version = version_1.Version.parse(pkg.version);
|
|
87
|
-
|
|
88
|
-
return version;
|
|
88
|
+
return new versioning_strategy_1.PatchVersionUpdate().bump(version);
|
|
89
89
|
}
|
|
90
90
|
updateCandidate(existingCandidate, pkg, updatedVersions) {
|
|
91
91
|
const version = updatedVersions.get(pkg.name);
|
|
@@ -28,7 +28,7 @@ const composite_1 = require("../updaters/composite");
|
|
|
28
28
|
*/
|
|
29
29
|
class Merge extends plugin_1.ManifestPlugin {
|
|
30
30
|
async run(candidates) {
|
|
31
|
-
if (candidates.length <
|
|
31
|
+
if (candidates.length < 1) {
|
|
32
32
|
return candidates;
|
|
33
33
|
}
|
|
34
34
|
const updatesByPath = {};
|
|
@@ -44,6 +44,9 @@ class Merge extends plugin_1.ManifestPlugin {
|
|
|
44
44
|
updatesByPath[update.path] = [update];
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
+
for (const label of pullRequest.labels) {
|
|
48
|
+
labels.add(label);
|
|
49
|
+
}
|
|
47
50
|
releaseData.push(...pullRequest.body.releaseData);
|
|
48
51
|
}
|
|
49
52
|
const updates = [];
|
|
@@ -26,6 +26,7 @@ const branch_name_1 = require("../util/branch-name");
|
|
|
26
26
|
const json_stringify_1 = require("../util/json-stringify");
|
|
27
27
|
const changelog_1 = require("../updaters/changelog");
|
|
28
28
|
const workspace_1 = require("./workspace");
|
|
29
|
+
const versioning_strategy_1 = require("../versioning-strategy");
|
|
29
30
|
class Package extends package_1.Package {
|
|
30
31
|
constructor(rawContent, location, pkg) {
|
|
31
32
|
super(pkg !== null && pkg !== void 0 ? pkg : JSON.parse(rawContent), location);
|
|
@@ -92,8 +93,7 @@ class NodeWorkspace extends workspace_1.WorkspacePlugin {
|
|
|
92
93
|
}
|
|
93
94
|
bumpVersion(pkg) {
|
|
94
95
|
const version = version_1.Version.parse(pkg.version);
|
|
95
|
-
|
|
96
|
-
return version;
|
|
96
|
+
return new versioning_strategy_1.PatchVersionUpdate().bump(version);
|
|
97
97
|
}
|
|
98
98
|
updateCandidate(existingCandidate, pkg, updatedVersions) {
|
|
99
99
|
var _a;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export interface PullRequest {
|
|
2
|
-
headBranchName: string;
|
|
3
|
-
baseBranchName: string;
|
|
4
|
-
number: number;
|
|
5
|
-
title: string;
|
|
6
|
-
body: string;
|
|
7
|
-
labels: string[];
|
|
8
|
-
files: string[];
|
|
9
|
-
sha?: string;
|
|
2
|
+
readonly headBranchName: string;
|
|
3
|
+
readonly baseBranchName: string;
|
|
4
|
+
readonly number: number;
|
|
5
|
+
readonly title: string;
|
|
6
|
+
readonly body: string;
|
|
7
|
+
readonly labels: string[];
|
|
8
|
+
readonly files: string[];
|
|
9
|
+
readonly sha?: string;
|
|
10
10
|
}
|