@semantic-release/github 10.0.6 → 10.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/is-prerelease.js +10 -2
- package/lib/success.js +58 -36
- package/package.json +6 -6
- package/lib/get-search-queries.js +0 -16
package/lib/is-prerelease.js
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
-
export default function isPrerelease({ type, main }) {
|
|
2
|
-
|
|
1
|
+
export default function isPrerelease({ type, main, prerelease }) {
|
|
2
|
+
if (prerelease === false) {
|
|
3
|
+
return false;
|
|
4
|
+
}
|
|
5
|
+
return (
|
|
6
|
+
type === "prerelease" ||
|
|
7
|
+
(type === "release" && !main) ||
|
|
8
|
+
typeof prerelease == "string" ||
|
|
9
|
+
prerelease === true
|
|
10
|
+
);
|
|
3
11
|
}
|
package/lib/success.js
CHANGED
|
@@ -7,7 +7,6 @@ import debugFactory from "debug";
|
|
|
7
7
|
import parseGithubUrl from "./parse-github-url.js";
|
|
8
8
|
import resolveConfig from "./resolve-config.js";
|
|
9
9
|
import { toOctokitOptions } from "./octokit.js";
|
|
10
|
-
import getSearchQueries from "./get-search-queries.js";
|
|
11
10
|
import getSuccessComment from "./get-success-comment.js";
|
|
12
11
|
import findSRIssues from "./find-sr-issues.js";
|
|
13
12
|
import { RELEASE_NAME } from "./definitions/constants.js";
|
|
@@ -65,44 +64,38 @@ export default async function success(pluginConfig, context, { Octokit }) {
|
|
|
65
64
|
const releaseInfos = releases.filter((release) => Boolean(release.name));
|
|
66
65
|
const shas = commits.map(({ hash }) => hash);
|
|
67
66
|
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
).map(
|
|
72
|
-
async (q) =>
|
|
73
|
-
(await octokit.request("GET /search/issues", { q })).data.items,
|
|
67
|
+
const { repository } = await octokit.graphql(
|
|
68
|
+
buildAssociatedPRsQuery(shas),
|
|
69
|
+
{ owner, repo },
|
|
74
70
|
);
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const uniqueSearchQueriesResults = uniqBy(
|
|
78
|
-
flatten(searchQueriesResults),
|
|
79
|
-
"number",
|
|
71
|
+
const associatedPRs = Object.values(repository).map(
|
|
72
|
+
(item) => item.associatedPullRequests.nodes,
|
|
80
73
|
);
|
|
81
|
-
const prs = await pFilter(
|
|
82
|
-
uniqueSearchQueriesResults,
|
|
83
|
-
async ({ number }) => {
|
|
84
|
-
const commits = await octokit.paginate(
|
|
85
|
-
"GET /repos/{owner}/{repo}/pulls/{pull_number}/commits",
|
|
86
|
-
{
|
|
87
|
-
owner,
|
|
88
|
-
repo,
|
|
89
|
-
pull_number: number,
|
|
90
|
-
},
|
|
91
|
-
);
|
|
92
|
-
const matchingCommit = commits.find(({ sha }) => shas.includes(sha));
|
|
93
|
-
if (matchingCommit) return matchingCommit;
|
|
94
74
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
75
|
+
const uniqueAssociatedPRs = uniqBy(flatten(associatedPRs), "number");
|
|
76
|
+
|
|
77
|
+
const prs = await pFilter(uniqueAssociatedPRs, async ({ number }) => {
|
|
78
|
+
const commits = await octokit.paginate(
|
|
79
|
+
"GET /repos/{owner}/{repo}/pulls/{pull_number}/commits",
|
|
80
|
+
{
|
|
81
|
+
owner,
|
|
82
|
+
repo,
|
|
83
|
+
pull_number: number,
|
|
84
|
+
},
|
|
85
|
+
);
|
|
86
|
+
const matchingCommit = commits.find(({ sha }) => shas.includes(sha));
|
|
87
|
+
if (matchingCommit) return matchingCommit;
|
|
88
|
+
|
|
89
|
+
const { data: pullRequest } = await octokit.request(
|
|
90
|
+
"GET /repos/{owner}/{repo}/pulls/{pull_number}",
|
|
91
|
+
{
|
|
92
|
+
owner,
|
|
93
|
+
repo,
|
|
94
|
+
pull_number: number,
|
|
95
|
+
},
|
|
96
|
+
);
|
|
97
|
+
return shas.includes(pullRequest.merge_commit_sha);
|
|
98
|
+
});
|
|
106
99
|
|
|
107
100
|
debug(
|
|
108
101
|
"found pull requests: %O",
|
|
@@ -250,3 +243,32 @@ export default async function success(pluginConfig, context, { Octokit }) {
|
|
|
250
243
|
throw new AggregateError(errors);
|
|
251
244
|
}
|
|
252
245
|
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Builds GraphQL query for fetching associated PRs to a list of commit hash (sha)
|
|
249
|
+
* @param {Array<string>} shas
|
|
250
|
+
* @returns {string}
|
|
251
|
+
*/
|
|
252
|
+
export function buildAssociatedPRsQuery(shas) {
|
|
253
|
+
return `#graphql
|
|
254
|
+
query getAssociatedPRs($owner: String!, $repo: String!) {
|
|
255
|
+
repository(owner: $owner, name: $repo) {
|
|
256
|
+
${shas
|
|
257
|
+
.map((sha) => {
|
|
258
|
+
return `commit${sha.slice(0, 6)}: object(oid: "${sha}") {
|
|
259
|
+
...on Commit {
|
|
260
|
+
associatedPullRequests(first: 100) {
|
|
261
|
+
nodes {
|
|
262
|
+
url
|
|
263
|
+
number
|
|
264
|
+
body
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}`;
|
|
269
|
+
})
|
|
270
|
+
.join("")}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
`;
|
|
274
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semantic-release/github",
|
|
3
3
|
"description": "semantic-release plugin to publish a GitHub release and comment on released Pull Requests/Issues",
|
|
4
|
-
"version": "10.0
|
|
4
|
+
"version": "10.1.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Pierre Vanduynslager (https://twitter.com/@pvdlg_)",
|
|
7
7
|
"ava": {
|
|
@@ -41,14 +41,14 @@
|
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"ava": "6.1.3",
|
|
44
|
-
"c8": "
|
|
44
|
+
"c8": "10.1.2",
|
|
45
45
|
"cpy": "11.0.1",
|
|
46
46
|
"cz-conventional-changelog": "3.3.0",
|
|
47
47
|
"fetch-mock": "npm:@gr2m/fetch-mock@9.11.0-pull-request-644.1",
|
|
48
|
-
"lockfile-lint": "4.
|
|
49
|
-
"ls-engines": "0.9.
|
|
50
|
-
"npm-run-all2": "6.2.
|
|
51
|
-
"prettier": "3.3.
|
|
48
|
+
"lockfile-lint": "4.14.0",
|
|
49
|
+
"ls-engines": "0.9.2",
|
|
50
|
+
"npm-run-all2": "6.2.2",
|
|
51
|
+
"prettier": "3.3.2",
|
|
52
52
|
"publint": "0.2.8",
|
|
53
53
|
"semantic-release": "24.0.0",
|
|
54
54
|
"sinon": "18.0.0",
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export default function getSearchQueries(base, commits, separator = "+") {
|
|
2
|
-
return commits.reduce((searches, commit) => {
|
|
3
|
-
const lastSearch = searches[searches.length - 1];
|
|
4
|
-
|
|
5
|
-
if (
|
|
6
|
-
lastSearch &&
|
|
7
|
-
lastSearch.length + commit.length <= 256 - separator.length
|
|
8
|
-
) {
|
|
9
|
-
searches[searches.length - 1] = `${lastSearch}${separator}${commit}`;
|
|
10
|
-
} else {
|
|
11
|
-
searches.push(`${base}${separator}${commit}`);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return searches;
|
|
15
|
-
}, []);
|
|
16
|
-
}
|