@semantic-release/github 8.0.9 → 8.1.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 +2 -1
- package/lib/definitions/errors.js +6 -0
- package/lib/publish.js +25 -6
- package/lib/resolve-config.js +2 -0
- package/lib/verify.js +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -89,6 +89,7 @@ When using the _GITHUB_TOKEN_, the **minimum required permissions** are:
|
|
|
89
89
|
| `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. | - |
|
|
90
90
|
| `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}\` : "" %>']- |
|
|
91
91
|
| `addReleases` | Will add release links to the GitHub Release. Can be `false`, `"bottom"` or `"top"`. See [addReleases](#addReleases). | `false` |
|
|
92
|
+
| `draftRelease` | A boolean indicating if a GitHub Draft Release should be created instead of publishing an actual GitHub Release. | `false` |
|
|
92
93
|
|
|
93
94
|
#### proxy
|
|
94
95
|
|
|
@@ -218,4 +219,4 @@ Valid values for this option are `false`, `"top"` or `"bottom"`.
|
|
|
218
219
|
|
|
219
220
|
##### addReleases example
|
|
220
221
|
|
|
221
|
-
See [The introducing PR](https://github.com/semantic-release/github/pull/282) for an example on how it will look.
|
|
222
|
+
See [The introducing PR](https://github.com/semantic-release/github/pull/282) for an example on how it will look.
|
|
@@ -63,6 +63,12 @@ Your configuration for the \`releasedLabels\` option is \`${stringify(releasedLa
|
|
|
63
63
|
details: `The [addReleases option](${linkify('README.md#options')}) if defined, must be one of \`false|top|bottom\`.
|
|
64
64
|
|
|
65
65
|
Your configuration for the \`addReleases\` option is \`${stringify(addReleases)}\`.`,
|
|
66
|
+
}),
|
|
67
|
+
EINVALIDDRAFTRELEASE: ({draftRelease}) => ({
|
|
68
|
+
message: 'Invalid `draftRelease` option.',
|
|
69
|
+
details: `The [draftRelease option](${linkify('README.md#options')}) if defined, must be a \`Boolean\`.
|
|
70
|
+
|
|
71
|
+
Your configuration for the \`draftRelease\` option is \`${stringify(draftRelease)}\`.`,
|
|
66
72
|
}),
|
|
67
73
|
EINVALIDGITHUBURL: () => ({
|
|
68
74
|
message: 'The git repository URL is not a valid GitHub URL.',
|
package/lib/publish.js
CHANGED
|
@@ -18,7 +18,10 @@ module.exports = async (pluginConfig, context) => {
|
|
|
18
18
|
nextRelease: {name, gitTag, notes},
|
|
19
19
|
logger,
|
|
20
20
|
} = context;
|
|
21
|
-
const {githubToken, githubUrl, githubApiPathPrefix, proxy, assets} = resolveConfig(
|
|
21
|
+
const {githubToken, githubUrl, githubApiPathPrefix, proxy, assets, draftRelease} = resolveConfig(
|
|
22
|
+
pluginConfig,
|
|
23
|
+
context
|
|
24
|
+
);
|
|
22
25
|
const {owner, repo} = parseGithubUrl(repositoryUrl);
|
|
23
26
|
const octokit = getClient({githubToken, githubUrl, githubApiPathPrefix, proxy});
|
|
24
27
|
const release = {
|
|
@@ -33,8 +36,20 @@ module.exports = async (pluginConfig, context) => {
|
|
|
33
36
|
|
|
34
37
|
debug('release object: %O', release);
|
|
35
38
|
|
|
36
|
-
|
|
39
|
+
const draftReleaseOptions = {...release, draft: true};
|
|
40
|
+
|
|
41
|
+
// When there are no assets, we publish a release directly.
|
|
37
42
|
if (!assets || assets.length === 0) {
|
|
43
|
+
// If draftRelease is true we create a draft release instead.
|
|
44
|
+
if (draftRelease) {
|
|
45
|
+
const {
|
|
46
|
+
data: {html_url: url, id: releaseId},
|
|
47
|
+
} = await octokit.request('POST /repos/{owner}/{repo}/releases', draftReleaseOptions);
|
|
48
|
+
|
|
49
|
+
logger.log('Created GitHub draft release: %s', url);
|
|
50
|
+
return {url, name: RELEASE_NAME, id: releaseId};
|
|
51
|
+
}
|
|
52
|
+
|
|
38
53
|
const {
|
|
39
54
|
data: {html_url: url, id: releaseId},
|
|
40
55
|
} = await octokit.request('POST /repos/{owner}/{repo}/releases', release);
|
|
@@ -45,11 +60,9 @@ module.exports = async (pluginConfig, context) => {
|
|
|
45
60
|
|
|
46
61
|
// We'll create a draft release, append the assets to it, and then publish it.
|
|
47
62
|
// This is so that the assets are available when we get a Github release event.
|
|
48
|
-
const draftRelease = {...release, draft: true};
|
|
49
|
-
|
|
50
63
|
const {
|
|
51
|
-
data: {upload_url: uploadUrl, id: releaseId},
|
|
52
|
-
} = await octokit.request('POST /repos/{owner}/{repo}/releases',
|
|
64
|
+
data: {upload_url: uploadUrl, html_url: draftUrl, id: releaseId},
|
|
65
|
+
} = await octokit.request('POST /repos/{owner}/{repo}/releases', draftReleaseOptions);
|
|
53
66
|
|
|
54
67
|
// Append assets to the release
|
|
55
68
|
const globbedAssets = await globAssets(context, assets);
|
|
@@ -98,6 +111,12 @@ module.exports = async (pluginConfig, context) => {
|
|
|
98
111
|
})
|
|
99
112
|
);
|
|
100
113
|
|
|
114
|
+
// If we want to create a draft we don't need to update the release again
|
|
115
|
+
if (draftRelease) {
|
|
116
|
+
logger.log('Created GitHub draft release: %s', draftUrl);
|
|
117
|
+
return {url: draftUrl, name: RELEASE_NAME, id: releaseId};
|
|
118
|
+
}
|
|
119
|
+
|
|
101
120
|
const {
|
|
102
121
|
data: {html_url: url},
|
|
103
122
|
} = await octokit.request('PATCH /repos/{owner}/{repo}/releases/{release_id}', {
|
package/lib/resolve-config.js
CHANGED
|
@@ -13,6 +13,7 @@ module.exports = (
|
|
|
13
13
|
assignees,
|
|
14
14
|
releasedLabels,
|
|
15
15
|
addReleases,
|
|
16
|
+
draftRelease,
|
|
16
17
|
},
|
|
17
18
|
{env}
|
|
18
19
|
) => ({
|
|
@@ -32,4 +33,5 @@ module.exports = (
|
|
|
32
33
|
? false
|
|
33
34
|
: castArray(releasedLabels),
|
|
34
35
|
addReleases: isNil(addReleases) ? false : addReleases,
|
|
36
|
+
draftRelease: isNil(draftRelease) ? false : draftRelease,
|
|
35
37
|
});
|
package/lib/verify.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const {isString, isPlainObject, isNil, isArray, isNumber} = require('lodash');
|
|
1
|
+
const {isString, isPlainObject, isNil, isArray, isNumber, isBoolean} = require('lodash');
|
|
2
2
|
const urlJoin = require('url-join');
|
|
3
3
|
const AggregateError = require('aggregate-error');
|
|
4
4
|
const parseGithubUrl = require('./parse-github-url');
|
|
@@ -27,6 +27,7 @@ const VALIDATORS = {
|
|
|
27
27
|
assignees: isArrayOf(isNonEmptyString),
|
|
28
28
|
releasedLabels: canBeDisabled(isArrayOf(isNonEmptyString)),
|
|
29
29
|
addReleases: canBeDisabled(oneOf(['bottom', 'top'])),
|
|
30
|
+
draftRelease: isBoolean,
|
|
30
31
|
};
|
|
31
32
|
|
|
32
33
|
module.exports = async (pluginConfig, context) => {
|
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": "8.0
|
|
4
|
+
"version": "8.1.0",
|
|
5
5
|
"author": "Pierre Vanduynslager (https://twitter.com/@pvdlg_)",
|
|
6
6
|
"ava": {
|
|
7
7
|
"files": [
|