@semantic-release/github 9.0.7 → 9.2.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 +17 -14
- package/index.js +5 -1
- package/lib/definitions/errors.js +39 -0
- package/lib/publish.js +11 -3
- package/lib/resolve-config.js +12 -0
- package/lib/verify.js +3 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -79,20 +79,23 @@ When using the _GITHUB_TOKEN_, the **minimum required permissions** are:
|
|
|
79
79
|
|
|
80
80
|
### Options
|
|
81
81
|
|
|
82
|
-
| Option
|
|
83
|
-
|
|
|
84
|
-
| `githubUrl`
|
|
85
|
-
| `githubApiPathPrefix`
|
|
86
|
-
| `proxy`
|
|
87
|
-
| `assets`
|
|
88
|
-
| `successComment`
|
|
89
|
-
| `failComment`
|
|
90
|
-
| `failTitle`
|
|
91
|
-
| `labels`
|
|
92
|
-
| `assignees`
|
|
93
|
-
| `releasedLabels`
|
|
94
|
-
| `addReleases`
|
|
95
|
-
| `draftRelease`
|
|
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` |
|
|
96
99
|
|
|
97
100
|
#### proxy
|
|
98
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 });
|
|
@@ -195,3 +195,42 @@ export function ENOGHTOKEN({ owner, repo }) {
|
|
|
195
195
|
Please make sure to create a [GitHub personal token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line) and to set it in the \`GH_TOKEN\` or \`GITHUB_TOKEN\` environment variable on your CI environment. The token must allow to push to the repository ${owner}/${repo}.`,
|
|
196
196
|
};
|
|
197
197
|
}
|
|
198
|
+
|
|
199
|
+
export function EINVALIDRELEASEBODYTEMPLATE({ releaseBodyTemplate }) {
|
|
200
|
+
return {
|
|
201
|
+
message: "Invalid `releaseBodyTemplate` option.",
|
|
202
|
+
details: `The [releaseBodyTemplate option](${linkify(
|
|
203
|
+
"README.md#releaseBodyTemplate",
|
|
204
|
+
)}) must be a non empty \`String\`.
|
|
205
|
+
|
|
206
|
+
Your configuration for the \`releaseBodyTemplate\` option is \`${stringify(
|
|
207
|
+
releaseBodyTemplate,
|
|
208
|
+
)}\`.`,
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export function EINVALIDRELEASENAMETEMPLATE({ releaseNameTemplate }) {
|
|
213
|
+
return {
|
|
214
|
+
message: "Invalid `releaseNameTemplate` option.",
|
|
215
|
+
details: `The [releaseNameTemplate option](${linkify(
|
|
216
|
+
"README.md#releaseNameTemplate",
|
|
217
|
+
)}) must be a non empty \`String\`.
|
|
218
|
+
|
|
219
|
+
Your configuration for the \`releaseNameTemplate\` option is \`${stringify(
|
|
220
|
+
releaseNameTemplate,
|
|
221
|
+
)}\`.`,
|
|
222
|
+
};
|
|
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
|
@@ -19,7 +19,7 @@ export default async function publish(pluginConfig, context, { Octokit }) {
|
|
|
19
19
|
cwd,
|
|
20
20
|
options: { repositoryUrl },
|
|
21
21
|
branch,
|
|
22
|
-
nextRelease: {
|
|
22
|
+
nextRelease: { gitTag },
|
|
23
23
|
logger,
|
|
24
24
|
} = context;
|
|
25
25
|
const {
|
|
@@ -29,6 +29,9 @@ export default async function publish(pluginConfig, context, { Octokit }) {
|
|
|
29
29
|
proxy,
|
|
30
30
|
assets,
|
|
31
31
|
draftRelease,
|
|
32
|
+
releaseNameTemplate,
|
|
33
|
+
releaseBodyTemplate,
|
|
34
|
+
discussionCategoryName,
|
|
32
35
|
} = resolveConfig(pluginConfig, context);
|
|
33
36
|
const { owner, repo } = parseGithubUrl(repositoryUrl);
|
|
34
37
|
const octokit = new Octokit(
|
|
@@ -44,13 +47,18 @@ export default async function publish(pluginConfig, context, { Octokit }) {
|
|
|
44
47
|
repo,
|
|
45
48
|
tag_name: gitTag,
|
|
46
49
|
target_commitish: branch.name,
|
|
47
|
-
name,
|
|
48
|
-
body:
|
|
50
|
+
name: template(releaseNameTemplate)(context),
|
|
51
|
+
body: template(releaseBodyTemplate)(context),
|
|
49
52
|
prerelease: isPrerelease(branch),
|
|
50
53
|
};
|
|
51
54
|
|
|
52
55
|
debug("release object: %O", release);
|
|
53
56
|
|
|
57
|
+
// If discussionCategoryName is not undefined or false
|
|
58
|
+
if (discussionCategoryName) {
|
|
59
|
+
release.discussion_category_name = discussionCategoryName;
|
|
60
|
+
}
|
|
61
|
+
|
|
54
62
|
const draftReleaseOptions = { ...release, draft: true };
|
|
55
63
|
|
|
56
64
|
// When there are no assets, we publish a release directly.
|
package/lib/resolve-config.js
CHANGED
|
@@ -14,6 +14,9 @@ export default function resolveConfig(
|
|
|
14
14
|
releasedLabels,
|
|
15
15
|
addReleases,
|
|
16
16
|
draftRelease,
|
|
17
|
+
releaseNameTemplate,
|
|
18
|
+
releaseBodyTemplate,
|
|
19
|
+
discussionCategoryName,
|
|
17
20
|
},
|
|
18
21
|
{ env },
|
|
19
22
|
) {
|
|
@@ -44,5 +47,14 @@ export default function resolveConfig(
|
|
|
44
47
|
: castArray(releasedLabels),
|
|
45
48
|
addReleases: isNil(addReleases) ? false : addReleases,
|
|
46
49
|
draftRelease: isNil(draftRelease) ? false : draftRelease,
|
|
50
|
+
releaseBodyTemplate: !isNil(releaseBodyTemplate)
|
|
51
|
+
? releaseBodyTemplate
|
|
52
|
+
: "<%= nextRelease.notes %>",
|
|
53
|
+
releaseNameTemplate: !isNil(releaseNameTemplate)
|
|
54
|
+
? releaseNameTemplate
|
|
55
|
+
: "<%= nextRelease.name %>",
|
|
56
|
+
discussionCategoryName: isNil(discussionCategoryName)
|
|
57
|
+
? false
|
|
58
|
+
: discussionCategoryName,
|
|
47
59
|
};
|
|
48
60
|
}
|
package/lib/verify.js
CHANGED
|
@@ -45,6 +45,9 @@ const VALIDATORS = {
|
|
|
45
45
|
releasedLabels: canBeDisabled(isArrayOf(isNonEmptyString)),
|
|
46
46
|
addReleases: canBeDisabled(oneOf(["bottom", "top"])),
|
|
47
47
|
draftRelease: isBoolean,
|
|
48
|
+
releaseBodyTemplate: isNonEmptyString,
|
|
49
|
+
releaseNameTemplate: isNonEmptyString,
|
|
50
|
+
discussionCategoryName: canBeDisabled(isNonEmptyString),
|
|
48
51
|
};
|
|
49
52
|
|
|
50
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.0
|
|
4
|
+
"version": "9.2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Pierre Vanduynslager (https://twitter.com/@pvdlg_)",
|
|
7
7
|
"ava": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"cpy": "10.1.0",
|
|
44
44
|
"fetch-mock": "npm:@gr2m/fetch-mock@9.11.0-pull-request-644.1",
|
|
45
45
|
"prettier": "3.0.3",
|
|
46
|
-
"semantic-release": "22.0.
|
|
46
|
+
"semantic-release": "22.0.5",
|
|
47
47
|
"sinon": "16.0.0",
|
|
48
48
|
"tempy": "3.1.0"
|
|
49
49
|
},
|