@semantic-release/github 10.3.4 → 11.0.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/README.md +33 -33
- package/lib/definitions/constants.js +2 -0
- package/lib/fail.js +11 -5
- package/lib/find-sr-issues.js +58 -6
- package/lib/success.js +22 -4
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -168,14 +168,14 @@ files.
|
|
|
168
168
|
|
|
169
169
|
The message for the issue comments is generated with [Lodash template](https://lodash.com/docs#template). The following variables are available:
|
|
170
170
|
|
|
171
|
-
| Parameter | Description
|
|
172
|
-
| ------------- |
|
|
173
|
-
| `branch` | `Object` with `name`, `type`, `channel`, `range` and `prerelease` properties of the branch from which the release is done.
|
|
174
|
-
| `lastRelease` | `Object` with `version`, `channel`, `gitTag` and `gitHead` of the last release.
|
|
175
|
-
| `nextRelease` | `Object` with `version`, `channel`, `gitTag`, `gitHead` and `notes` of the release being done.
|
|
176
|
-
| `commits` | `Array` of commit `Object`s with `hash`, `subject`, `body` `message` and `author`.
|
|
177
|
-
| `releases` | `Array` with a release `Object`s for each release published, with optional release data such as `name` and `url`.
|
|
178
|
-
| `issue` | A [GitHub API pull request object](https://developer.github.com/v3/search/#search-issues) for pull requests related to a commit, or
|
|
171
|
+
| Parameter | Description |
|
|
172
|
+
| ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
173
|
+
| `branch` | `Object` with `name`, `type`, `channel`, `range` and `prerelease` properties of the branch from which the release is done. |
|
|
174
|
+
| `lastRelease` | `Object` with `version`, `channel`, `gitTag` and `gitHead` of the last release. |
|
|
175
|
+
| `nextRelease` | `Object` with `version`, `channel`, `gitTag`, `gitHead` and `notes` of the release being done. |
|
|
176
|
+
| `commits` | `Array` of commit `Object`s with `hash`, `subject`, `body` `message` and `author`. |
|
|
177
|
+
| `releases` | `Array` with a release `Object`s for each release published, with optional release data such as `name` and `url`. |
|
|
178
|
+
| `issue` | A [GitHub API pull request object](https://developer.github.com/v3/search/#search-issues) for pull requests related to a commit, or [GitHub API issue object](https://docs.github.com/en/rest/issues/issues?apiVersion=2022-11-28#get-an-issue) for issues resolved via [keywords](https://help.github.com/articles/closing-issues-using-keywords) |
|
|
179
179
|
|
|
180
180
|
##### successComment example
|
|
181
181
|
|
|
@@ -187,14 +187,14 @@ The `successComment` `This ${issue.pull_request ? 'pull request' : 'issue'} is i
|
|
|
187
187
|
|
|
188
188
|
The message for the issue comments is generated with [Lodash template](https://lodash.com/docs#template). The following variables are available:
|
|
189
189
|
|
|
190
|
-
| Parameter | Description
|
|
191
|
-
| ------------- |
|
|
192
|
-
| `branch` | `Object` with `name`, `type`, `channel`, `range` and `prerelease` properties of the branch from which the release is done.
|
|
193
|
-
| `lastRelease` | `Object` with `version`, `channel`, `gitTag` and `gitHead` of the last release.
|
|
194
|
-
| `nextRelease` | `Object` with `version`, `channel`, `gitTag`, `gitHead` and `notes` of the release being done.
|
|
195
|
-
| `commits` | `Array` of commit `Object`s with `hash`, `subject`, `body` `message` and `author`.
|
|
196
|
-
| `releases` | `Array` with a release `Object`s for each release published, with optional release data such as `name` and `url`.
|
|
197
|
-
| `issue` | A [GitHub API Pull Request object](https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#get-a-pull-request) for pull requests related to a commit
|
|
190
|
+
| Parameter | Description |
|
|
191
|
+
| ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
192
|
+
| `branch` | `Object` with `name`, `type`, `channel`, `range` and `prerelease` properties of the branch from which the release is done. |
|
|
193
|
+
| `lastRelease` | `Object` with `version`, `channel`, `gitTag` and `gitHead` of the last release. |
|
|
194
|
+
| `nextRelease` | `Object` with `version`, `channel`, `gitTag`, `gitHead` and `notes` of the release being done. |
|
|
195
|
+
| `commits` | `Array` of commit `Object`s with `hash`, `subject`, `body` `message` and `author`. |
|
|
196
|
+
| `releases` | `Array` with a release `Object`s for each release published, with optional release data such as `name` and `url`. |
|
|
197
|
+
| `issue` | A [GitHub API Pull Request object](https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#get-a-pull-request) for pull requests related to a commit |
|
|
198
198
|
|
|
199
199
|
##### successCommentCondition example
|
|
200
200
|
|
|
@@ -202,7 +202,7 @@ The message for the issue comments is generated with [Lodash template](https://l
|
|
|
202
202
|
- to only comment on issues: `"<% return !issue.pull_request; %>"`
|
|
203
203
|
- to only comment on pull requests: `"<% return issue.pull_request; %>"`
|
|
204
204
|
- to avoid comment on PRs or issues created by Bots: `"<% return issue.user.type !== 'Bot'; %>"`
|
|
205
|
-
- you can use labels to filter issues: `"<% return issue.labels?.
|
|
205
|
+
- you can use labels to filter issues: `"<% return issue.labels?.some((label) => { return label.name === ('semantic-release-relevant'); }); %>"`
|
|
206
206
|
|
|
207
207
|
> check the [GitHub API issue object](https://docs.github.com/en/rest/issues/issues?apiVersion=2022-11-28#get-an-issue) for properties which can be used for the filter
|
|
208
208
|
|
|
@@ -228,14 +228,14 @@ The `failComment` `This release from branch ${branch.name} had failed due to the
|
|
|
228
228
|
|
|
229
229
|
The message for the issue content is generated with [Lodash template](https://lodash.com/docs#template). The following variables are available:
|
|
230
230
|
|
|
231
|
-
| Parameter | Description
|
|
232
|
-
| ------------- |
|
|
233
|
-
| `branch` | `Object` with `name`, `type`, `channel`, `range` and `prerelease` properties of the branch from which the release is done.
|
|
234
|
-
| `lastRelease` | `Object` with `version`, `channel`, `gitTag` and `gitHead` of the last release.
|
|
235
|
-
| `nextRelease` | `Object` with `version`, `channel`, `gitTag`, `gitHead` and `notes` of the release being done.
|
|
236
|
-
| `commits` | `Array` of commit `Object`s with `hash`, `subject`, `body` `message` and `author`.
|
|
237
|
-
| `releases` | `Array` with a release `Object`s for each release published, with optional release data such as `name` and `url`.
|
|
238
|
-
| `issue` | A [GitHub API pull request object](https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#get-a-pull-request) for pull requests related to a commit, or
|
|
231
|
+
| Parameter | Description |
|
|
232
|
+
| ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
233
|
+
| `branch` | `Object` with `name`, `type`, `channel`, `range` and `prerelease` properties of the branch from which the release is done. |
|
|
234
|
+
| `lastRelease` | `Object` with `version`, `channel`, `gitTag` and `gitHead` of the last release. |
|
|
235
|
+
| `nextRelease` | `Object` with `version`, `channel`, `gitTag`, `gitHead` and `notes` of the release being done. |
|
|
236
|
+
| `commits` | `Array` of commit `Object`s with `hash`, `subject`, `body` `message` and `author`. |
|
|
237
|
+
| `releases` | `Array` with a release `Object`s for each release published, with optional release data such as `name` and `url`. |
|
|
238
|
+
| `issue` | A [GitHub API pull request object](https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#get-a-pull-request) for pull requests related to a commit, or [GitHub API issue object](https://docs.github.com/en/rest/issues/issues?apiVersion=2022-11-28#get-an-issue) for issues resolved via [keywords](https://help.github.com/articles/closing-issues-using-keywords) |
|
|
239
239
|
|
|
240
240
|
##### failCommentCondition example
|
|
241
241
|
|
|
@@ -249,14 +249,14 @@ The message for the issue content is generated with [Lodash template](https://lo
|
|
|
249
249
|
|
|
250
250
|
Each label name is generated with [Lodash template](https://lodash.com/docs#template). The following variables are available:
|
|
251
251
|
|
|
252
|
-
| Parameter | Description
|
|
253
|
-
| ------------- |
|
|
254
|
-
| `branch` | `Object` with `name`, `type`, `channel`, `range` and `prerelease` properties of the branch from which the release is done.
|
|
255
|
-
| `lastRelease` | `Object` with `version`, `channel`, `gitTag` and `gitHead` of the last release.
|
|
256
|
-
| `nextRelease` | `Object` with `version`, `channel`, `gitTag`, `gitHead` and `notes` of the release being done.
|
|
257
|
-
| `commits` | `Array` of commit `Object`s with `hash`, `subject`, `body` `message` and `author`.
|
|
258
|
-
| `releases` | `Array` with a release `Object`s for each release published, with optional release data such as `name` and `url`.
|
|
259
|
-
| `issue` | A [GitHub API pull request object](https://developer.github.com/v3/search/#search-issues) for pull requests related to a commit, or
|
|
252
|
+
| Parameter | Description |
|
|
253
|
+
| ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
254
|
+
| `branch` | `Object` with `name`, `type`, `channel`, `range` and `prerelease` properties of the branch from which the release is done. |
|
|
255
|
+
| `lastRelease` | `Object` with `version`, `channel`, `gitTag` and `gitHead` of the last release. |
|
|
256
|
+
| `nextRelease` | `Object` with `version`, `channel`, `gitTag`, `gitHead` and `notes` of the release being done. |
|
|
257
|
+
| `commits` | `Array` of commit `Object`s with `hash`, `subject`, `body` `message` and `author`. |
|
|
258
|
+
| `releases` | `Array` with a release `Object`s for each release published, with optional release data such as `name` and `url`. |
|
|
259
|
+
| `issue` | A [GitHub API pull request object](https://developer.github.com/v3/search/#search-issues) for pull requests related to a commit, or [GitHub API issue object](https://docs.github.com/en/rest/issues/issues?apiVersion=2022-11-28#get-an-issue) for issues resolved via [keywords](https://help.github.com/articles/closing-issues-using-keywords) |
|
|
260
260
|
|
|
261
261
|
##### releasedLabels example
|
|
262
262
|
|
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";
|
|
@@ -32,8 +32,7 @@ export default async function fail(pluginConfig, context, { Octokit }) {
|
|
|
32
32
|
|
|
33
33
|
if (failComment === false || failTitle === false) {
|
|
34
34
|
logger.log("Skip issue creation.");
|
|
35
|
-
|
|
36
|
-
logger.log(
|
|
35
|
+
logger.warn(
|
|
37
36
|
`DEPRECATION: 'false' for 'failComment' or 'failTitle' is deprecated and will be removed in a future major version. Use 'failCommentCondition' instead.`,
|
|
38
37
|
);
|
|
39
38
|
} else if (failCommentCondition === false) {
|
|
@@ -57,7 +56,14 @@ export default async function fail(pluginConfig, context, { Octokit }) {
|
|
|
57
56
|
const body = failComment
|
|
58
57
|
? template(failComment)({ branch, errors })
|
|
59
58
|
: getFailComment(branch, errors);
|
|
60
|
-
const [srIssue] = await findSRIssues(
|
|
59
|
+
const [srIssue] = await findSRIssues(
|
|
60
|
+
octokit,
|
|
61
|
+
logger,
|
|
62
|
+
failTitle,
|
|
63
|
+
labels,
|
|
64
|
+
owner,
|
|
65
|
+
repo,
|
|
66
|
+
);
|
|
61
67
|
|
|
62
68
|
const canCommentOnOrCreateIssue = failCommentCondition
|
|
63
69
|
? template(failCommentCondition)({ ...context, issue: srIssue })
|
|
@@ -85,7 +91,7 @@ export default async function fail(pluginConfig, context, { Octokit }) {
|
|
|
85
91
|
repo,
|
|
86
92
|
title: failTitle,
|
|
87
93
|
body: `${body}\n\n${ISSUE_ID}`,
|
|
88
|
-
labels: labels || [],
|
|
94
|
+
labels: (labels || []).concat([RELEASE_FAIL_LABEL]),
|
|
89
95
|
assignees,
|
|
90
96
|
};
|
|
91
97
|
debug("create issue: %O", newIssue);
|
package/lib/find-sr-issues.js
CHANGED
|
@@ -1,11 +1,63 @@
|
|
|
1
|
-
import {
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
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
|
+
`;
|
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,
|
|
@@ -61,8 +62,7 @@ export default async function success(pluginConfig, context, { Octokit }) {
|
|
|
61
62
|
logger.log("No commits found in release");
|
|
62
63
|
}
|
|
63
64
|
logger.log("Skip commenting on issues and pull requests.");
|
|
64
|
-
|
|
65
|
-
logger.log(
|
|
65
|
+
logger.warn(
|
|
66
66
|
`DEPRECATION: 'false' for 'successComment' is deprecated and will be removed in a future major version. Use 'successCommentCondition' instead.`,
|
|
67
67
|
);
|
|
68
68
|
} else if (successCommentCondition === false) {
|
|
@@ -266,7 +266,14 @@ export default async function success(pluginConfig, context, { Octokit }) {
|
|
|
266
266
|
if (failComment === false || failTitle === false) {
|
|
267
267
|
logger.log("Skip closing issue.");
|
|
268
268
|
} else {
|
|
269
|
-
const srIssues = await findSRIssues(
|
|
269
|
+
const srIssues = await findSRIssues(
|
|
270
|
+
octokit,
|
|
271
|
+
logger,
|
|
272
|
+
failTitle,
|
|
273
|
+
labels,
|
|
274
|
+
owner,
|
|
275
|
+
repo,
|
|
276
|
+
);
|
|
270
277
|
|
|
271
278
|
debug("found semantic-release issues: %O", srIssues);
|
|
272
279
|
|
|
@@ -379,6 +386,8 @@ const baseFields = `
|
|
|
379
386
|
url
|
|
380
387
|
name
|
|
381
388
|
color
|
|
389
|
+
description
|
|
390
|
+
isDefault
|
|
382
391
|
}
|
|
383
392
|
}
|
|
384
393
|
milestone {
|
|
@@ -514,7 +523,16 @@ function buildIssuesOrPRsFromResponseNode(responseNodes, type = "ISSUE") {
|
|
|
514
523
|
number: node.number,
|
|
515
524
|
title: node.title,
|
|
516
525
|
body: node.body,
|
|
517
|
-
labels: node.labels?.nodes.map((label) =>
|
|
526
|
+
labels: node.labels?.nodes.map((label) => {
|
|
527
|
+
return {
|
|
528
|
+
id: label.id,
|
|
529
|
+
url: label.url,
|
|
530
|
+
name: label.name,
|
|
531
|
+
color: label.color,
|
|
532
|
+
description: label.description,
|
|
533
|
+
default: label.isDefault,
|
|
534
|
+
};
|
|
535
|
+
}),
|
|
518
536
|
html_url: node.url,
|
|
519
537
|
created_at: node.createdAt,
|
|
520
538
|
updated_at: node.updatedAt,
|
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": "
|
|
4
|
+
"version": "11.0.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Pierre Vanduynslager (https://twitter.com/@pvdlg_)",
|
|
7
7
|
"ava": {
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"ls-engines": "0.9.3",
|
|
50
50
|
"npm-run-all2": "6.2.3",
|
|
51
51
|
"prettier": "3.3.3",
|
|
52
|
-
"publint": "0.2.
|
|
52
|
+
"publint": "0.2.11",
|
|
53
53
|
"semantic-release": "24.1.1",
|
|
54
54
|
"sinon": "19.0.2",
|
|
55
55
|
"tempy": "3.1.0"
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
]
|
|
102
102
|
},
|
|
103
103
|
"peerDependencies": {
|
|
104
|
-
"semantic-release": ">=
|
|
104
|
+
"semantic-release": ">=24.1.0"
|
|
105
105
|
},
|
|
106
106
|
"publishConfig": {
|
|
107
107
|
"access": "public",
|