@semantic-release/github 10.3.5 → 11.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/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 an `Object` with the `number` property for issues resolved via [keywords](https://help.github.com/articles/closing-issues-using-keywords) |
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, or an `Object` with the `number` property for issues resolved via [keywords](https://help.github.com/articles/closing-issues-using-keywords) |
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?.includes('semantic-release-relevant'); %>"`
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 an `Object` with the `number` property for issues resolved via [keywords](https://help.github.com/articles/closing-issues-using-keywords) |
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 an `Object` with the `number` property for issues resolved via [keywords](https://help.github.com/articles/closing-issues-using-keywords) |
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
@@ -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
- // TODO: use logger.warn() instead of logger.log()
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) {
package/lib/success.js CHANGED
@@ -62,8 +62,7 @@ export default async function success(pluginConfig, context, { Octokit }) {
62
62
  logger.log("No commits found in release");
63
63
  }
64
64
  logger.log("Skip commenting on issues and pull requests.");
65
- // TODO: use logger.warn() instead of logger.log()
66
- logger.log(
65
+ logger.warn(
67
66
  `DEPRECATION: 'false' for 'successComment' is deprecated and will be removed in a future major version. Use 'successCommentCondition' instead.`,
68
67
  );
69
68
  } else if (successCommentCondition === false) {
@@ -89,7 +88,7 @@ export default async function success(pluginConfig, context, { Octokit }) {
89
88
  for (const { nodes, pageInfo } of responseAssociatedPRs) {
90
89
  if (nodes.length === 0) continue;
91
90
 
92
- responsePRs.push(...buildIssuesOrPRsFromResponseNode(nodes, "PR"));
91
+ responsePRs.push(...buildIssuesOrPRsFromResponseNode(nodes));
93
92
  if (pageInfo.hasNextPage) {
94
93
  let cursor = pageInfo.endCursor;
95
94
  let hasNextPage = true;
@@ -172,7 +171,7 @@ export default async function success(pluginConfig, context, { Octokit }) {
172
171
  if (!isEmpty(parsedIssues)) {
173
172
  const uniqueParsedIssues = uniqBy(flatten(parsedIssues), "number");
174
173
 
175
- // Get relatedIssues
174
+ // Get relatedIssues (or relatedPRs i.e. Issues/PRs that are closed by an associatedPR)
176
175
  issues = await inChunks(uniqueParsedIssues, 100, async (chunk) => {
177
176
  const { repository } = await octokit.graphql(
178
177
  buildRelatedIssuesQuery(chunk.map((issue) => issue.number)),
@@ -361,6 +360,7 @@ async function inChunks(items, chunkSize, callback) {
361
360
  * Fields common accross PRs and Issue
362
361
  */
363
362
  const baseFields = `
363
+ __typename
364
364
  id
365
365
  title
366
366
  body
@@ -387,6 +387,8 @@ const baseFields = `
387
387
  url
388
388
  name
389
389
  color
390
+ description
391
+ isDefault
390
392
  }
391
393
  }
392
394
  milestone {
@@ -419,8 +421,25 @@ function buildRelatedIssuesQuery(numbers) {
419
421
  repository(owner: $owner, name: $repo) {
420
422
  ${numbers
421
423
  .map((num) => {
422
- return `issue${num}: issue(number: ${num}) {
423
- ${baseFields}
424
+ return `issue${num}: issueOrPullRequest(number: ${num}) {
425
+ ... on Issue {
426
+ ${baseFields}
427
+ }
428
+ ... on PullRequest {
429
+ ${baseFields}
430
+ mergeable
431
+ changedFiles
432
+ mergedAt
433
+ isDraft
434
+ mergedBy {
435
+ login
436
+ avatarUrl
437
+ url
438
+ }
439
+ commits {
440
+ totalCount
441
+ }
442
+ }
424
443
  }`;
425
444
  })
426
445
  .join("")}
@@ -512,17 +531,25 @@ const loadSingleCommitAssociatedPRs = `#graphql
512
531
  /**
513
532
  * Build associatedPRs or RelatedIssues object (into issue-like object with `pull_request` property) from the GraphQL repository response
514
533
  * @param {object} responseNodes
515
- * @param {"ISSUE" | "PR"} type
516
534
  * @returns {object[]}
517
535
  */
518
- function buildIssuesOrPRsFromResponseNode(responseNodes, type = "ISSUE") {
536
+ function buildIssuesOrPRsFromResponseNode(responseNodes) {
519
537
  const resultArray = [];
520
538
  for (const node of responseNodes) {
521
539
  let baseProps = {
522
540
  number: node.number,
523
541
  title: node.title,
524
542
  body: node.body,
525
- labels: node.labels?.nodes.map((label) => label.name),
543
+ labels: node.labels?.nodes.map((label) => {
544
+ return {
545
+ id: label.id,
546
+ url: label.url,
547
+ name: label.name,
548
+ color: label.color,
549
+ description: label.description,
550
+ default: label.isDefault,
551
+ };
552
+ }),
526
553
  html_url: node.url,
527
554
  created_at: node.createdAt,
528
555
  updated_at: node.updatedAt,
@@ -559,7 +586,7 @@ function buildIssuesOrPRsFromResponseNode(responseNodes, type = "ISSUE") {
559
586
 
560
587
  let result = baseProps;
561
588
 
562
- if (type === "PR") {
589
+ if (node.__typename === "PullRequest") {
563
590
  const prProps = {
564
591
  pull_request: true,
565
592
  mergeable: node.mergeable,
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.5",
4
+ "version": "11.0.1",
5
5
  "type": "module",
6
6
  "author": "Pierre Vanduynslager (https://twitter.com/@pvdlg_)",
7
7
  "ava": {
@@ -40,17 +40,17 @@
40
40
  "url-join": "^5.0.0"
41
41
  },
42
42
  "devDependencies": {
43
- "ava": "6.1.3",
43
+ "ava": "6.2.0",
44
44
  "c8": "10.1.2",
45
45
  "cpy": "11.1.0",
46
46
  "cz-conventional-changelog": "3.3.0",
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.3",
50
+ "npm-run-all2": "7.0.1",
51
51
  "prettier": "3.3.3",
52
- "publint": "0.2.11",
53
- "semantic-release": "24.1.1",
52
+ "publint": "0.2.12",
53
+ "semantic-release": "24.2.0",
54
54
  "sinon": "19.0.2",
55
55
  "tempy": "3.1.0"
56
56
  },
@@ -101,7 +101,7 @@
101
101
  ]
102
102
  },
103
103
  "peerDependencies": {
104
- "semantic-release": ">=20.1.0"
104
+ "semantic-release": ">=24.1.0"
105
105
  },
106
106
  "publishConfig": {
107
107
  "access": "public",
@@ -127,5 +127,5 @@
127
127
  "github>semantic-release/.github:renovate-config"
128
128
  ]
129
129
  },
130
- "packageManager": "npm@10.8.3"
130
+ "packageManager": "npm@10.9.0"
131
131
  }