@semantic-release/github 9.1.0 → 9.2.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
@@ -79,22 +79,23 @@ When using the _GITHUB_TOKEN_, the **minimum required permissions** are:
79
79
 
80
80
  ### Options
81
81
 
82
- | Option | Description | Default |
83
- | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
84
- | `githubUrl` | The GitHub Enterprise endpoint. | `GH_URL` or `GITHUB_URL` environment variable. |
85
- | `githubApiPathPrefix` | The GitHub Enterprise API prefix. | `GH_PREFIX` or `GITHUB_PREFIX` environment variable. |
86
- | `proxy` | The proxy to use to access the GitHub API. Set to `false` to disable usage of proxy. See [proxy](#proxy). | `HTTP_PROXY` environment variable. |
87
- | `assets` | An array of files to upload to the release. See [assets](#assets). | - |
88
- | `successComment` | The comment to add to each issue and pull request resolved by the release. Set to `false` to disable commenting on issues and pull requests. See [successComment](#successcomment). | `:tada: This issue has been resolved in version ${nextRelease.version} :tada:\n\nThe release is available on [GitHub release](<github_release_url>)` |
89
- | `failComment` | The content of the issue created when a release fails. Set to `false` to disable opening an issue when a release fails. See [failComment](#failcomment). | Friendly message with links to **semantic-release** documentation and support, with the list of errors that caused the release to fail. |
90
- | `failTitle` | The title of the issue created when a release fails. Set to `false` to disable opening an issue when a release fails. | `The automated release is failing 🚨` |
91
- | `labels` | The [labels](https://help.github.com/articles/about-labels) to add to the issue created when a release fails. Set to `false` to not add any label. | `['semantic-release']` |
92
- | `assignees` | The [assignees](https://help.github.com/articles/assigning-issues-and-pull-requests-to-other-github-users) to add to the issue created when a release fails. | - |
93
- | `releasedLabels` | The [labels](https://help.github.com/articles/about-labels) to add to each issue and pull request resolved by the release. Set to `false` to not add any label. See [releasedLabels](#releasedlabels). | `['released<%= nextRelease.channel ? \` on @\${nextRelease.channel}\` : "" %>']- |
94
- | `addReleases` | Will add release links to the GitHub Release. Can be `false`, `"bottom"` or `"top"`. See [addReleases](#addReleases). | `false` |
95
- | `draftRelease` | A boolean indicating if a GitHub Draft Release should be created instead of publishing an actual GitHub Release. | `false` |
96
- | `releaseNameTemplate` | A [Lodash template](https://lodash.com/docs#template) to customize the github release's name | `<%= nextverison.name %>` |
97
- | `releaseBodyTemplate` | A [Lodash template](https://lodash.com/docs#template) to customize the github release's body | `<%= nextverison.notes %>` |
82
+ | Option | Description | Default |
83
+ | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
84
+ | `githubUrl` | The GitHub Enterprise endpoint. | `GH_URL` or `GITHUB_URL` environment variable. |
85
+ | `githubApiPathPrefix` | The GitHub Enterprise API prefix. | `GH_PREFIX` or `GITHUB_PREFIX` environment variable. |
86
+ | `proxy` | The proxy to use to access the GitHub API. Set to `false` to disable usage of proxy. See [proxy](#proxy). | `HTTP_PROXY` environment variable. |
87
+ | `assets` | An array of files to upload to the release. See [assets](#assets). | - |
88
+ | `successComment` | The comment to add to each issue and pull request resolved by the release. Set to `false` to disable commenting on issues and pull requests. See [successComment](#successcomment). | `:tada: This issue has been resolved in version ${nextRelease.version} :tada:\n\nThe release is available on [GitHub release](<github_release_url>)` |
89
+ | `failComment` | The content of the issue created when a release fails. Set to `false` to disable opening an issue when a release fails. See [failComment](#failcomment). | Friendly message with links to **semantic-release** documentation and support, with the list of errors that caused the release to fail. |
90
+ | `failTitle` | The title of the issue created when a release fails. Set to `false` to disable opening an issue when a release fails. | `The automated release is failing 🚨` |
91
+ | `labels` | The [labels](https://help.github.com/articles/about-labels) to add to the issue created when a release fails. Set to `false` to not add any label. | `['semantic-release']` |
92
+ | `assignees` | The [assignees](https://help.github.com/articles/assigning-issues-and-pull-requests-to-other-github-users) to add to the issue created when a release fails. | - |
93
+ | `releasedLabels` | The [labels](https://help.github.com/articles/about-labels) to add to each issue and pull request resolved by the release. Set to `false` to not add any label. See [releasedLabels](#releasedlabels). | `['released<%= nextRelease.channel ? \` on @\${nextRelease.channel}\` : "" %>']- |
94
+ | `addReleases` | Will add release links to the GitHub Release. Can be `false`, `"bottom"` or `"top"`. See [addReleases](#addReleases). | `false` |
95
+ | `draftRelease` | A boolean indicating if a GitHub Draft Release should be created instead of publishing an actual GitHub Release. | `false` |
96
+ | `releaseNameTemplate` | A [Lodash template](https://lodash.com/docs#template) to customize the github release's name | `<%= nextverison.name %>` |
97
+ | `releaseBodyTemplate` | A [Lodash template](https://lodash.com/docs#template) to customize the github release's body | `<%= nextverison.notes %>` |
98
+ | `discussionCategoryName` | The category name in which to create a linked discussion to the release. Set to `false` to disable creating discussion for a release. | `false` |
98
99
 
99
100
  #### proxy
100
101
 
package/index.js CHANGED
@@ -17,7 +17,7 @@ export async function verifyConditions(
17
17
  { Octokit = SemanticReleaseOctokit } = {},
18
18
  ) {
19
19
  const { options } = context;
20
- // If the GitHub publish plugin is used and has `assets`, `successComment`, `failComment`, `failTitle`, `labels` or `assignees` configured, validate it now in order to prevent any release if the configuration is wrong
20
+ // If the GitHub publish plugin is used and has `assets`, `successComment`, `failComment`, `failTitle`, `labels`, `discussionCategoryName` or `assignees` configured, validate it now in order to prevent any release if the configuration is wrong
21
21
  if (options.publish) {
22
22
  const publishPlugin =
23
23
  castArray(options.publish).find(
@@ -42,6 +42,10 @@ export async function verifyConditions(
42
42
  pluginConfig.assignees,
43
43
  publishPlugin.assignees,
44
44
  );
45
+ pluginConfig.discussionCategoryName = defaultTo(
46
+ pluginConfig.discussionCategoryName,
47
+ publishPlugin.discussionCategoryName,
48
+ );
45
49
  }
46
50
 
47
51
  await verifyGitHub(pluginConfig, context, { Octokit });
@@ -221,3 +221,16 @@ Your configuration for the \`releaseNameTemplate\` option is \`${stringify(
221
221
  )}\`.`,
222
222
  };
223
223
  }
224
+
225
+ export function EINVALIDDISCUSSIONCATEGORYNAME({ discussionCategoryName }) {
226
+ return {
227
+ message: "Invalid `discussionCategoryName` option.",
228
+ details: `The [discussionCategoryName option](${linkify(
229
+ "README.md#discussionCategoryName",
230
+ )}) if defined, must be a non empty \`String\`.
231
+
232
+ Your configuration for the \`discussionCategoryName\` option is \`${stringify(
233
+ discussionCategoryName,
234
+ )}\`.`,
235
+ };
236
+ }
package/lib/publish.js CHANGED
@@ -31,6 +31,7 @@ export default async function publish(pluginConfig, context, { Octokit }) {
31
31
  draftRelease,
32
32
  releaseNameTemplate,
33
33
  releaseBodyTemplate,
34
+ discussionCategoryName,
34
35
  } = resolveConfig(pluginConfig, context);
35
36
  const { owner, repo } = parseGithubUrl(repositoryUrl);
36
37
  const octokit = new Octokit(
@@ -70,12 +71,22 @@ export default async function publish(pluginConfig, context, { Octokit }) {
70
71
  return { url, name: RELEASE_NAME, id: releaseId };
71
72
  }
72
73
 
74
+ // add discussion_category_name if discussionCategoryName is not undefined or false
75
+ if (discussionCategoryName) {
76
+ release.discussion_category_name = discussionCategoryName;
77
+ }
78
+
73
79
  const {
74
- data: { html_url: url, id: releaseId },
80
+ data: { html_url: url, id: releaseId, discussion_url },
75
81
  } = await octokit.request("POST /repos/{owner}/{repo}/releases", release);
76
82
 
77
83
  logger.log("Published GitHub release: %s", url);
78
- return { url, name: RELEASE_NAME, id: releaseId };
84
+
85
+ if (discussionCategoryName) {
86
+ logger.log("Created GitHub release discussion: %s", discussion_url);
87
+ }
88
+
89
+ return { url, name: RELEASE_NAME, id: releaseId, discussion_url };
79
90
  }
80
91
 
81
92
  // We'll create a draft release, append the assets to it, and then publish it.
@@ -146,18 +157,30 @@ export default async function publish(pluginConfig, context, { Octokit }) {
146
157
  return { url: draftUrl, name: RELEASE_NAME, id: releaseId };
147
158
  }
148
159
 
160
+ const patchRelease = {
161
+ owner,
162
+ repo,
163
+ release_id: releaseId,
164
+ draft: false,
165
+ };
166
+
167
+ // add discussion_category_name if discussionCategoryName is not undefined or false
168
+ if (discussionCategoryName) {
169
+ patchRelease.discussion_category_name = discussionCategoryName;
170
+ }
171
+
149
172
  const {
150
- data: { html_url: url },
173
+ data: { html_url: url, discussion_url },
151
174
  } = await octokit.request(
152
175
  "PATCH /repos/{owner}/{repo}/releases/{release_id}",
153
- {
154
- owner,
155
- repo,
156
- release_id: releaseId,
157
- draft: false,
158
- },
176
+ patchRelease,
159
177
  );
160
178
 
161
179
  logger.log("Published GitHub release: %s", url);
162
- return { url, name: RELEASE_NAME, id: releaseId };
180
+
181
+ if (discussionCategoryName) {
182
+ logger.log("Created GitHub release discussion: %s", discussion_url);
183
+ }
184
+
185
+ return { url, name: RELEASE_NAME, id: releaseId, discussion_url };
163
186
  }
@@ -16,6 +16,7 @@ export default function resolveConfig(
16
16
  draftRelease,
17
17
  releaseNameTemplate,
18
18
  releaseBodyTemplate,
19
+ discussionCategoryName,
19
20
  },
20
21
  { env },
21
22
  ) {
@@ -52,5 +53,8 @@ export default function resolveConfig(
52
53
  releaseNameTemplate: !isNil(releaseNameTemplate)
53
54
  ? releaseNameTemplate
54
55
  : "<%= nextRelease.name %>",
56
+ discussionCategoryName: isNil(discussionCategoryName)
57
+ ? false
58
+ : discussionCategoryName,
55
59
  };
56
60
  }
package/lib/verify.js CHANGED
@@ -47,6 +47,7 @@ const VALIDATORS = {
47
47
  draftRelease: isBoolean,
48
48
  releaseBodyTemplate: isNonEmptyString,
49
49
  releaseNameTemplate: isNonEmptyString,
50
+ discussionCategoryName: canBeDisabled(isNonEmptyString),
50
51
  };
51
52
 
52
53
  export default async function verify(pluginConfig, context, { Octokit }) {
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": "9.1.0",
4
+ "version": "9.2.1",
5
5
  "type": "module",
6
6
  "author": "Pierre Vanduynslager (https://twitter.com/@pvdlg_)",
7
7
  "ava": {