diff --git a/README.md b/README.md index b72b0d22..9fd0e8dc 100644 --- a/README.md +++ b/README.md @@ -168,14 +168,14 @@ files. The message for the issue comments is generated with [Lodash template](https://lodash.com/docs#template). The following variables are available: -| Parameter | Description | -| ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `branch` | `Object` with `name`, `type`, `channel`, `range` and `prerelease` properties of the branch from which the release is done. | -| `lastRelease` | `Object` with `version`, `channel`, `gitTag` and `gitHead` of the last release. | -| `nextRelease` | `Object` with `version`, `channel`, `gitTag`, `gitHead` and `notes` of the release being done. | -| `commits` | `Array` of commit `Object`s with `hash`, `subject`, `body` `message` and `author`. | -| `releases` | `Array` with a release `Object`s for each release published, with optional release data such as `name` and `url`. | -| `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) | +| Parameter | Description | +| ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `branch` | `Object` with `name`, `type`, `channel`, `range` and `prerelease` properties of the branch from which the release is done. | +| `lastRelease` | `Object` with `version`, `channel`, `gitTag` and `gitHead` of the last release. | +| `nextRelease` | `Object` with `version`, `channel`, `gitTag`, `gitHead` and `notes` of the release being done. | +| `commits` | `Array` of commit `Object`s with `hash`, `subject`, `body` `message` and `author`. | +| `releases` | `Array` with a release `Object`s for each release published, with optional release data such as `name` and `url`. | +| `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) | ##### successComment example @@ -187,14 +187,14 @@ The `successComment` `This ${issue.pull_request ? 'pull request' : 'issue'} is i The message for the issue comments is generated with [Lodash template](https://lodash.com/docs#template). The following variables are available: -| Parameter | Description | -| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `branch` | `Object` with `name`, `type`, `channel`, `range` and `prerelease` properties of the branch from which the release is done. | -| `lastRelease` | `Object` with `version`, `channel`, `gitTag` and `gitHead` of the last release. | -| `nextRelease` | `Object` with `version`, `channel`, `gitTag`, `gitHead` and `notes` of the release being done. | -| `commits` | `Array` of commit `Object`s with `hash`, `subject`, `body` `message` and `author`. | -| `releases` | `Array` with a release `Object`s for each release published, with optional release data such as `name` and `url`. | -| `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) | +| Parameter | Description | +| ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `branch` | `Object` with `name`, `type`, `channel`, `range` and `prerelease` properties of the branch from which the release is done. | +| `lastRelease` | `Object` with `version`, `channel`, `gitTag` and `gitHead` of the last release. | +| `nextRelease` | `Object` with `version`, `channel`, `gitTag`, `gitHead` and `notes` of the release being done. | +| `commits` | `Array` of commit `Object`s with `hash`, `subject`, `body` `message` and `author`. | +| `releases` | `Array` with a release `Object`s for each release published, with optional release data such as `name` and `url`. | +| `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 | ##### successCommentCondition example @@ -202,7 +202,7 @@ The message for the issue comments is generated with [Lodash template](https://l - to only comment on issues: `"<% return !issue.pull_request; %>"` - to only comment on pull requests: `"<% return issue.pull_request; %>"` - to avoid comment on PRs or issues created by Bots: `"<% return issue.user.type !== 'Bot'; %>"` -- you can use labels to filter issues: `"<% return issue.labels?.includes('semantic-release-relevant'); %>"` +- you can use labels to filter issues: `"<% return issue.labels?.some((label) => { return label.name === ('semantic-release-relevant'); }); %>"` > 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 @@ -228,14 +228,14 @@ The `failComment` `This release from branch ${branch.name} had failed due to the The message for the issue content is generated with [Lodash template](https://lodash.com/docs#template). The following variables are available: -| Parameter | Description | -| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `branch` | `Object` with `name`, `type`, `channel`, `range` and `prerelease` properties of the branch from which the release is done. | -| `lastRelease` | `Object` with `version`, `channel`, `gitTag` and `gitHead` of the last release. | -| `nextRelease` | `Object` with `version`, `channel`, `gitTag`, `gitHead` and `notes` of the release being done. | -| `commits` | `Array` of commit `Object`s with `hash`, `subject`, `body` `message` and `author`. | -| `releases` | `Array` with a release `Object`s for each release published, with optional release data such as `name` and `url`. | -| `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) | +| Parameter | Description | +| ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `branch` | `Object` with `name`, `type`, `channel`, `range` and `prerelease` properties of the branch from which the release is done. | +| `lastRelease` | `Object` with `version`, `channel`, `gitTag` and `gitHead` of the last release. | +| `nextRelease` | `Object` with `version`, `channel`, `gitTag`, `gitHead` and `notes` of the release being done. | +| `commits` | `Array` of commit `Object`s with `hash`, `subject`, `body` `message` and `author`. | +| `releases` | `Array` with a release `Object`s for each release published, with optional release data such as `name` and `url`. | +| `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) | ##### failCommentCondition example @@ -249,14 +249,14 @@ The message for the issue content is generated with [Lodash template](https://lo Each label name is generated with [Lodash template](https://lodash.com/docs#template). The following variables are available: -| Parameter | Description | -| ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `branch` | `Object` with `name`, `type`, `channel`, `range` and `prerelease` properties of the branch from which the release is done. | -| `lastRelease` | `Object` with `version`, `channel`, `gitTag` and `gitHead` of the last release. | -| `nextRelease` | `Object` with `version`, `channel`, `gitTag`, `gitHead` and `notes` of the release being done. | -| `commits` | `Array` of commit `Object`s with `hash`, `subject`, `body` `message` and `author`. | -| `releases` | `Array` with a release `Object`s for each release published, with optional release data such as `name` and `url`. | -| `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) | +| Parameter | Description | +| ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `branch` | `Object` with `name`, `type`, `channel`, `range` and `prerelease` properties of the branch from which the release is done. | +| `lastRelease` | `Object` with `version`, `channel`, `gitTag` and `gitHead` of the last release. | +| `nextRelease` | `Object` with `version`, `channel`, `gitTag`, `gitHead` and `notes` of the release being done. | +| `commits` | `Array` of commit `Object`s with `hash`, `subject`, `body` `message` and `author`. | +| `releases` | `Array` with a release `Object`s for each release published, with optional release data such as `name` and `url`. | +| `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) | ##### releasedLabels example diff --git a/lib/fail.js b/lib/fail.js index 723b0510..b5b43a3f 100644 --- a/lib/fail.js +++ b/lib/fail.js @@ -32,8 +32,7 @@ export default async function fail(pluginConfig, context, { Octokit }) { if (failComment === false || failTitle === false) { logger.log("Skip issue creation."); - // TODO: use logger.warn() instead of logger.log() - logger.log( + logger.warn( `DEPRECATION: 'false' for 'failComment' or 'failTitle' is deprecated and will be removed in a future major version. Use 'failCommentCondition' instead.`, ); } else if (failCommentCondition === false) { diff --git a/lib/success.js b/lib/success.js index 705f02aa..4e3e2b71 100644 --- a/lib/success.js +++ b/lib/success.js @@ -62,8 +62,7 @@ export default async function success(pluginConfig, context, { Octokit }) { logger.log("No commits found in release"); } logger.log("Skip commenting on issues and pull requests."); - // TODO: use logger.warn() instead of logger.log() - logger.log( + logger.warn( `DEPRECATION: 'false' for 'successComment' is deprecated and will be removed in a future major version. Use 'successCommentCondition' instead.`, ); } else if (successCommentCondition === false) { @@ -387,6 +386,8 @@ const baseFields = ` url name color + description + isDefault } } milestone { @@ -522,7 +523,16 @@ function buildIssuesOrPRsFromResponseNode(responseNodes, type = "ISSUE") { number: node.number, title: node.title, body: node.body, - labels: node.labels?.nodes.map((label) => label.name), + labels: node.labels?.nodes.map((label) => { + return { + id: label.id, + url: label.url, + name: label.name, + color: label.color, + description: label.description, + default: label.isDefault, + }; + }), html_url: node.url, created_at: node.createdAt, updated_at: node.updatedAt, diff --git a/package-lock.json b/package-lock.json index 170deb82..55c7fc1c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -45,7 +45,7 @@ "node": ">=20.8.1" }, "peerDependencies": { - "semantic-release": ">=20.1.0" + "semantic-release": ">=24.1.0" } }, "node_modules/@ampproject/remapping": { diff --git a/package.json b/package.json index 720b46ae..74c63aec 100644 --- a/package.json +++ b/package.json @@ -101,7 +101,7 @@ ] }, "peerDependencies": { - "semantic-release": ">=20.1.0" + "semantic-release": ">=24.1.0" }, "publishConfig": { "access": "public", diff --git a/test/add-channel.test.js b/test/add-channel.test.js index 19b2a285..e14d696d 100644 --- a/test/add-channel.test.js +++ b/test/add-channel.test.js @@ -12,7 +12,12 @@ test.beforeEach((t) => { // Mock logger t.context.log = sinon.stub(); t.context.error = sinon.stub(); - t.context.logger = { log: t.context.log, error: t.context.error }; + t.context.warn = sinon.stub(); + t.context.logger = { + log: t.context.log, + error: t.context.error, + warn: t.context.warn, + }; }); test("Update a release", async (t) => { diff --git a/test/fail.test.js b/test/fail.test.js index 37ceb6bd..6daa543d 100644 --- a/test/fail.test.js +++ b/test/fail.test.js @@ -14,7 +14,12 @@ test.beforeEach((t) => { // Mock logger t.context.log = sinon.stub(); t.context.error = sinon.stub(); - t.context.logger = { log: t.context.log, error: t.context.error }; + t.context.warn = sinon.stub(); + t.context.logger = { + log: t.context.log, + error: t.context.error, + warn: t.context.warn, + }; }); test("Open a new issue with the list of errors", async (t) => { diff --git a/test/find-sr-issue.test.js b/test/find-sr-issue.test.js index fc10c2f0..3916e859 100644 --- a/test/find-sr-issue.test.js +++ b/test/find-sr-issue.test.js @@ -10,7 +10,12 @@ test.beforeEach((t) => { // Mock logger t.context.log = sinon.stub(); t.context.error = sinon.stub(); - t.context.logger = { log: t.context.log, error: t.context.error }; + t.context.warn = sinon.stub(); + t.context.logger = { + log: t.context.log, + error: t.context.error, + warn: t.context.warn, + }; }); test("Filter out issues without ID", async (t) => { diff --git a/test/integration.test.js b/test/integration.test.js index 91400d35..872aa08b 100644 --- a/test/integration.test.js +++ b/test/integration.test.js @@ -14,7 +14,12 @@ test.beforeEach(async (t) => { // Stub the logger t.context.log = sinon.stub(); t.context.error = sinon.stub(); - t.context.logger = { log: t.context.log, error: t.context.error }; + t.context.warn = sinon.stub(); + t.context.logger = { + log: t.context.log, + error: t.context.error, + warn: t.context.warn, + }; }); test("Verify GitHub auth", async (t) => { diff --git a/test/publish.test.js b/test/publish.test.js index 8b28c037..3009068a 100644 --- a/test/publish.test.js +++ b/test/publish.test.js @@ -15,7 +15,12 @@ test.beforeEach((t) => { // Mock logger t.context.log = sinon.stub(); t.context.error = sinon.stub(); - t.context.logger = { log: t.context.log, error: t.context.error }; + t.context.warn = sinon.stub(); + t.context.logger = { + log: t.context.log, + error: t.context.error, + warn: t.context.warn, + }; }); test("Publish a release without creating discussion", async (t) => { diff --git a/test/success.test.js b/test/success.test.js index 29f0c892..b34494e5 100644 --- a/test/success.test.js +++ b/test/success.test.js @@ -16,7 +16,12 @@ test.beforeEach((t) => { // Mock logger t.context.log = sinon.stub(); t.context.error = sinon.stub(); - t.context.logger = { log: t.context.log, error: t.context.error }; + t.context.warn = sinon.stub(); + t.context.logger = { + log: t.context.log, + error: t.context.error, + warn: t.context.warn, + }; }); test("Add comment and labels to PRs associated with release commits and issues solved by PR/commits comments", async (t) => { @@ -125,6 +130,8 @@ test("Add comment and labels to PRs associated with release commits and issues s url: "label_url", name: "label_name", color: "ededed", + description: "this is a label description", + isDefault: false, }, ], }, @@ -159,6 +166,8 @@ test("Add comment and labels to PRs associated with release commits and issues s url: "label_url", name: "label_name", color: "ededed", + description: "this is a label description", + isDefault: false, }, ], }, @@ -432,6 +441,8 @@ test("Add comment and labels to PRs associated with release commits and issues ( url: "label_url", name: "label_name", color: "ededed", + description: "this is a label description", + isDefault: false, }, ], }, @@ -466,6 +477,8 @@ test("Add comment and labels to PRs associated with release commits and issues ( url: "label_url", name: "label_name", color: "ededed", + description: "this is a label description", + isDefault: false, }, ], }, @@ -685,6 +698,8 @@ test("Add comment and labels to PRs associated with release commits and issues c url: "label_url", name: "label_name", color: "ededed", + description: "this is a label description", + isDefault: false, }, ], }, @@ -719,6 +734,8 @@ test("Add comment and labels to PRs associated with release commits and issues c url: "label_url", name: "label_name", color: "ededed", + description: "this is a label description", + isDefault: false, }, ], }, @@ -1578,6 +1595,8 @@ test("Do not add comment and labels to PR/issues from other repo", async (t) => url: "label_url", name: "label_name", color: "ededed", + description: "this is a label description", + isDefault: false, }, ], }, @@ -1758,6 +1777,8 @@ test("Ignore missing and forbidden issues/PRs", async (t) => { url: "label_url", name: "label_name", color: "ededed", + description: "this is a label description", + isDefault: false, }, ], }, @@ -1792,6 +1813,8 @@ test("Ignore missing and forbidden issues/PRs", async (t) => { url: "label_url", name: "label_name", color: "ededed", + description: "this is a label description", + isDefault: false, }, ], }, @@ -1826,6 +1849,8 @@ test("Ignore missing and forbidden issues/PRs", async (t) => { url: "label_url", name: "label_name", color: "ededed", + description: "this is a label description", + isDefault: false, }, ], }, @@ -3478,7 +3503,7 @@ test('Add comment and label to found issues/associatedPR using the "successComme failTitle, // Issues with the label "semantic-release-relevant" will be commented and labeled successCommentCondition: - "<% return issue.labels.includes('semantic-release-relevant'); %>", + "<% return issue.labels?.some((label) => { return label.name === ('semantic-release-relevant'); }); %>", }; const options = { repositoryUrl: `https://github.com/${owner}/${repo}.git`, @@ -3527,6 +3552,8 @@ test('Add comment and label to found issues/associatedPR using the "successComme url: "https://github.com/babblebey/sr-github/labels/released", name: "semantic-release-relevant", color: "ededed", + description: "This issue is relevant to semantic-release", + isDefault: false, }, ], }, @@ -3575,6 +3602,8 @@ test('Add comment and label to found issues/associatedPR using the "successComme url: "https://github.com/babblebey/sr-github/labels/released", name: "released", color: "ededed", + description: "this is a label description", + isDefault: false, }, ], }, @@ -3773,6 +3802,8 @@ test('Does not comment/label associatedPR and relatedIssues created by "Bots"', url: "label_url", name: "label_name", color: "ededed", + description: "this is a label description", + isDefault: false, }, ], }, @@ -3819,6 +3850,8 @@ test('Does not comment/label associatedPR and relatedIssues created by "Bots"', url: "label_url", name: "label_name", color: "ededed", + description: "this is a label description", + isDefault: false, }, ], }, @@ -3910,6 +3943,8 @@ test('Does not comment/label associatedPR and relatedIssues created by "Bots"', url: "label_url", name: "label_name", color: "ededed", + description: "this is a label description", + isDefault: false, }, ], }, @@ -3944,6 +3979,8 @@ test('Does not comment/label associatedPR and relatedIssues created by "Bots"', url: "label_url", name: "label_name", color: "ededed", + description: "this is a label description", + isDefault: false, }, ], }, @@ -4158,6 +4195,8 @@ test('Does not comment/label "associatedPR" when "successCommentCondition" disab url: "label_url", name: "label_name", color: "ededed", + description: "this is a label description", + isDefault: false, }, ], }, diff --git a/test/verify.test.js b/test/verify.test.js index 495c7b1b..d5154c36 100644 --- a/test/verify.test.js +++ b/test/verify.test.js @@ -12,7 +12,12 @@ test.beforeEach((t) => { // Mock logger t.context.log = sinon.stub(); t.context.error = sinon.stub(); - t.context.logger = { log: t.context.log, error: t.context.error }; + t.context.warn = sinon.stub(); + t.context.logger = { + log: t.context.log, + error: t.context.error, + warn: t.context.warn, + }; }); test("Verify package, token and repository access", async (t) => {