@semantic-release/github 10.3.3 → 10.3.5

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.
@@ -1,3 +1,5 @@
1
1
  export const ISSUE_ID = "<!-- semantic-release:github -->";
2
2
 
3
3
  export const RELEASE_NAME = "GitHub release";
4
+
5
+ export const RELEASE_FAIL_LABEL = "semantic-release";
package/lib/fail.js CHANGED
@@ -2,7 +2,7 @@ import { template } from "lodash-es";
2
2
  import debugFactory from "debug";
3
3
 
4
4
  import parseGithubUrl from "./parse-github-url.js";
5
- import { ISSUE_ID } from "./definitions/constants.js";
5
+ import { ISSUE_ID, RELEASE_FAIL_LABEL } from "./definitions/constants.js";
6
6
  import resolveConfig from "./resolve-config.js";
7
7
  import { toOctokitOptions } from "./octokit.js";
8
8
  import findSRIssues from "./find-sr-issues.js";
@@ -57,7 +57,14 @@ export default async function fail(pluginConfig, context, { Octokit }) {
57
57
  const body = failComment
58
58
  ? template(failComment)({ branch, errors })
59
59
  : getFailComment(branch, errors);
60
- const [srIssue] = await findSRIssues(octokit, failTitle, owner, repo);
60
+ const [srIssue] = await findSRIssues(
61
+ octokit,
62
+ logger,
63
+ failTitle,
64
+ labels,
65
+ owner,
66
+ repo,
67
+ );
61
68
 
62
69
  const canCommentOnOrCreateIssue = failCommentCondition
63
70
  ? template(failCommentCondition)({ ...context, issue: srIssue })
@@ -85,7 +92,7 @@ export default async function fail(pluginConfig, context, { Octokit }) {
85
92
  repo,
86
93
  title: failTitle,
87
94
  body: `${body}\n\n${ISSUE_ID}`,
88
- labels: labels || [],
95
+ labels: (labels || []).concat([RELEASE_FAIL_LABEL]),
89
96
  assignees,
90
97
  };
91
98
  debug("create issue: %O", newIssue);
@@ -1,11 +1,63 @@
1
- import { ISSUE_ID } from "./definitions/constants.js";
1
+ import { uniqBy } from "lodash-es";
2
+ import { ISSUE_ID, RELEASE_FAIL_LABEL } from "./definitions/constants.js";
3
+
4
+ export default async (octokit, logger, title, labels, owner, repo) => {
5
+ let issues = [];
2
6
 
3
- export default async (octokit, title, owner, repo) => {
4
7
  const {
5
- data: { items: issues },
6
- } = await octokit.request("GET /search/issues", {
7
- q: `in:title+repo:${owner}/${repo}+type:issue+state:open+${title}`,
8
+ repository: {
9
+ issues: { nodes: issueNodes },
10
+ },
11
+ } = await octokit.graphql(loadGetSRIssuesQuery, {
12
+ owner,
13
+ repo,
14
+ filter: {
15
+ labels: (labels || []).concat([RELEASE_FAIL_LABEL]),
16
+ },
8
17
  });
9
18
 
10
- return issues.filter((issue) => issue.body && issue.body.includes(ISSUE_ID));
19
+ issues.push(...issueNodes);
20
+
21
+ /**
22
+ * BACKWARD COMPATIBILITY: Fallback to the search API if the issue was not found in the GraphQL response.
23
+ * This fallback will be removed in a future release
24
+ */
25
+ if (issueNodes.length === 0) {
26
+ try {
27
+ const {
28
+ data: { items: backwardIssues },
29
+ } = await octokit.request("GET /search/issues", {
30
+ q: `in:title+repo:${owner}/${repo}+type:issue+state:open+${title}`,
31
+ });
32
+ issues.push(...backwardIssues);
33
+ } catch (error) {
34
+ logger.log(
35
+ "An error occured fetching issue via fallback (with GH SearchAPI)",
36
+ );
37
+ }
38
+ }
39
+
40
+ const uniqueSRIssues = uniqBy(
41
+ issues.filter((issue) => issue.body && issue.body.includes(ISSUE_ID)),
42
+ "number",
43
+ );
44
+
45
+ return uniqueSRIssues;
11
46
  };
47
+
48
+ /**
49
+ * GraphQL Query to et the semantic-release issues for a repository.
50
+ */
51
+ const loadGetSRIssuesQuery = `#graphql
52
+ query getSRIssues($owner: String!, $repo: String!, $filter: IssueFilters) {
53
+ repository(owner: $owner, name: $repo) {
54
+ issues(first: 100, states: OPEN, filterBy: $filter) {
55
+ nodes {
56
+ number
57
+ title
58
+ body
59
+ }
60
+ }
61
+ }
62
+ }
63
+ `;
@@ -30,7 +30,6 @@ export default async function globAssets({ cwd }, assets) {
30
30
  const globbed = await globby(glob, {
31
31
  cwd,
32
32
  expandDirectories: false, // TODO Temporary workaround for https://github.com/mrmlnc/fast-glob/issues/47
33
- gitignore: false,
34
33
  dot: true,
35
34
  onlyFiles: false,
36
35
  });
package/lib/success.js CHANGED
@@ -28,6 +28,7 @@ export default async function success(pluginConfig, context, { Octokit }) {
28
28
  githubApiPathPrefix,
29
29
  githubApiUrl,
30
30
  proxy,
31
+ labels,
31
32
  successComment,
32
33
  successCommentCondition,
33
34
  failTitle,
@@ -266,7 +267,14 @@ export default async function success(pluginConfig, context, { Octokit }) {
266
267
  if (failComment === false || failTitle === false) {
267
268
  logger.log("Skip closing issue.");
268
269
  } else {
269
- const srIssues = await findSRIssues(octokit, failTitle, owner, repo);
270
+ const srIssues = await findSRIssues(
271
+ octokit,
272
+ logger,
273
+ failTitle,
274
+ labels,
275
+ owner,
276
+ repo,
277
+ );
270
278
 
271
279
  debug("found semantic-release issues: %O", srIssues);
272
280
 
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.3.3",
4
+ "version": "10.3.5",
5
5
  "type": "module",
6
6
  "author": "Pierre Vanduynslager (https://twitter.com/@pvdlg_)",
7
7
  "ava": {
@@ -47,11 +47,11 @@
47
47
  "fetch-mock": "npm:@gr2m/fetch-mock@9.11.0-pull-request-644.1",
48
48
  "lockfile-lint": "4.14.0",
49
49
  "ls-engines": "0.9.3",
50
- "npm-run-all2": "6.2.2",
50
+ "npm-run-all2": "6.2.3",
51
51
  "prettier": "3.3.3",
52
- "publint": "0.2.10",
53
- "semantic-release": "24.1.0",
54
- "sinon": "18.0.0",
52
+ "publint": "0.2.11",
53
+ "semantic-release": "24.1.1",
54
+ "sinon": "19.0.2",
55
55
  "tempy": "3.1.0"
56
56
  },
57
57
  "engines": {