@semantic-release/github 5.4.0-beta.1 → 5.4.3
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 +21 -42
- package/index.js +1 -11
- package/lib/definitions/sr-issue-id.js +1 -0
- package/lib/fail.js +2 -3
- package/lib/find-sr-issues.js +1 -1
- package/lib/get-fail-comment.js +7 -8
- package/lib/glob-assets.js +0 -1
- package/lib/publish.js +31 -12
- package/lib/resolve-config.js +1 -5
- package/lib/success.js +27 -21
- package/lib/verify.js +9 -0
- package/package.json +22 -18
- package/lib/add-channel.js +0 -62
- package/lib/definitions/constants.js +0 -5
- package/lib/is-prerelease.js +0 -1
package/README.md
CHANGED
|
@@ -9,15 +9,13 @@
|
|
|
9
9
|
|
|
10
10
|
[](https://www.npmjs.com/package/@semantic-release/github)
|
|
11
11
|
[](https://www.npmjs.com/package/@semantic-release/github)
|
|
12
|
-
[](https://www.npmjs.com/package/@semantic-release/github)
|
|
13
12
|
|
|
14
13
|
| Step | Description |
|
|
15
14
|
|--------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
16
15
|
| `verifyConditions` | Verify the presence and the validity of the authentication (set via [environment variables](#environment-variables)) and the [assets](#assets) option configuration. |
|
|
17
16
|
| `publish` | Publish a [GitHub release](https://help.github.com/articles/about-releases), optionally uploading file assets. |
|
|
18
|
-
| `addChannel` | Update a [GitHub release](https://help.github.com/articles/about-releases)'s `pre-release` field. |
|
|
19
17
|
| `success` | Add a comment to each [GitHub Issue](https://help.github.com/articles/about-issues) or [Pull Request](https://help.github.com/articles/about-pull-requests) resolved by the release and close issues previously open by the `fail` step. |
|
|
20
|
-
| `fail` | Open or update a [GitHub Issue](https://help.github.com/articles/about-issues) with
|
|
18
|
+
| `fail` | Open or update a [GitHub Issue](https://help.github.com/articles/about-issues) with information about the errors that caused the release to fail. |
|
|
21
19
|
|
|
22
20
|
## Install
|
|
23
21
|
|
|
@@ -69,18 +67,18 @@ When creating the token, the **minimum required scopes** are:
|
|
|
69
67
|
|
|
70
68
|
### Options
|
|
71
69
|
|
|
72
|
-
| Option | Description
|
|
73
|
-
|
|
74
|
-
| `githubUrl` | The GitHub Enterprise endpoint.
|
|
75
|
-
| `githubApiPathPrefix` | The GitHub Enterprise API prefix.
|
|
76
|
-
| `proxy` | The proxy to use to access the GitHub API. See [proxy](#proxy).
|
|
77
|
-
| `assets` | An array of files to upload to the release. See [assets](#assets).
|
|
78
|
-
| `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).
|
|
79
|
-
| `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).
|
|
80
|
-
| `failTitle` | The title of the issue created when a release fails. Set to `false` to disable opening an issue when a release fails.
|
|
81
|
-
| `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.
|
|
82
|
-
| `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.
|
|
83
|
-
| `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.
|
|
70
|
+
| Option | Description | Default |
|
|
71
|
+
|-----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
72
|
+
| `githubUrl` | The GitHub Enterprise endpoint. | `GH_URL` or `GITHUB_URL` environment variable. |
|
|
73
|
+
| `githubApiPathPrefix` | The GitHub Enterprise API prefix. | `GH_PREFIX` or `GITHUB_PREFIX` environment variable. |
|
|
74
|
+
| `proxy` | The proxy to use to access the GitHub API. See [proxy](#proxy). | `HTTP_PROXY` environment variable. |
|
|
75
|
+
| `assets` | An array of files to upload to the release. See [assets](#assets). | - |
|
|
76
|
+
| `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>)` |
|
|
77
|
+
| `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. |
|
|
78
|
+
| `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 🚨` |
|
|
79
|
+
| `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']` |
|
|
80
|
+
| `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. | - |
|
|
81
|
+
| `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. | `['released']` |
|
|
84
82
|
|
|
85
83
|
#### proxy
|
|
86
84
|
|
|
@@ -140,14 +138,14 @@ The message for the issue comments is generated with [Lodash template](https://l
|
|
|
140
138
|
|
|
141
139
|
| Parameter | Description |
|
|
142
140
|
|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
143
|
-
| `branch` |
|
|
144
|
-
| `lastRelease` | `Object` with `version`, `
|
|
145
|
-
| `nextRelease` | `Object` with `version`, `
|
|
141
|
+
| `branch` | The branch from which the release is done. |
|
|
142
|
+
| `lastRelease` | `Object` with `version`, `gitTag` and `gitHead` of the last release. |
|
|
143
|
+
| `nextRelease` | `Object` with `version`, `gitTag`, `gitHead` and `notes` of the release being done. |
|
|
146
144
|
| `commits` | `Array` of commit `Object`s with `hash`, `subject`, `body` `message` and `author`. |
|
|
147
145
|
| `releases` | `Array` with a release `Object`s for each release published, with optional release data such as `name` and `url`. |
|
|
148
146
|
| `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) |
|
|
149
147
|
|
|
150
|
-
##### successComment
|
|
148
|
+
##### successComment examples
|
|
151
149
|
|
|
152
150
|
The `successComment` `This ${issue.pull_request ? 'pull request' : 'issue'} is included in version ${nextRelease.version}` will generate the comment:
|
|
153
151
|
|
|
@@ -159,32 +157,13 @@ The message for the issue content is generated with [Lodash template](https://lo
|
|
|
159
157
|
|
|
160
158
|
| Parameter | Description |
|
|
161
159
|
|-----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
162
|
-
| `branch` |
|
|
163
|
-
| `errors` | An `Array` of [SemanticReleaseError](https://github.com/semantic-release/error). Each error has the `message`, `code`, `pluginName` and `details` properties.<br>`pluginName` contains the package name of the plugin that threw the error.<br>`details` contains a
|
|
160
|
+
| `branch` | The branch from which the release had failed. |
|
|
161
|
+
| `errors` | An `Array` of [SemanticReleaseError](https://github.com/semantic-release/error). Each error has the `message`, `code`, `pluginName` and `details` properties.<br>`pluginName` contains the package name of the plugin that threw the error.<br>`details` contains a information about the error formatted in markdown. |
|
|
164
162
|
|
|
165
|
-
##### failComment
|
|
163
|
+
##### failComment examples
|
|
166
164
|
|
|
167
|
-
The `failComment` `This release from branch ${branch
|
|
165
|
+
The `failComment` `This release from branch ${branch} had failed due to the following errors:\n- ${errors.map(err => err.message).join('\\n- ')}` will generate the comment:
|
|
168
166
|
|
|
169
167
|
> This release from branch master had failed due to the following errors:
|
|
170
168
|
> - Error message 1
|
|
171
169
|
> - Error message 2
|
|
172
|
-
|
|
173
|
-
#### releasedLabels
|
|
174
|
-
|
|
175
|
-
Each label name is generated with [Lodash template](https://lodash.com/docs#template). The following variables are available:
|
|
176
|
-
|
|
177
|
-
| Parameter | Description |
|
|
178
|
-
|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
179
|
-
| `branch` | `Object` with `name`, `type`, `channel`, `range` and `prerelease` properties of the branch from which the release is done. |
|
|
180
|
-
| `lastRelease` | `Object` with `version`, `channel`, `gitTag` and `gitHead` of the last release. |
|
|
181
|
-
| `nextRelease` | `Object` with `version`, `channel`, `gitTag`, `gitHead` and `notes` of the release being done. |
|
|
182
|
-
| `commits` | `Array` of commit `Object`s with `hash`, `subject`, `body` `message` and `author`. |
|
|
183
|
-
| `releases` | `Array` with a release `Object`s for each release published, with optional release data such as `name` and `url`. |
|
|
184
|
-
| `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) |
|
|
185
|
-
|
|
186
|
-
##### releasedLabels example
|
|
187
|
-
|
|
188
|
-
The `releasedLabels` `['released<%= nextRelease.channel ? \` on @\${nextRelease.channel}\` : "" %> from <%= branch.name %>']` will generate the label:
|
|
189
|
-
|
|
190
|
-
> released on @next from branch next
|
package/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const {defaultTo, castArray} = require('lodash');
|
|
2
2
|
const verifyGitHub = require('./lib/verify');
|
|
3
|
-
const addChannelGitHub = require('./lib/add-channel');
|
|
4
3
|
const publishGitHub = require('./lib/publish');
|
|
5
4
|
const successGitHub = require('./lib/success');
|
|
6
5
|
const failGitHub = require('./lib/fail');
|
|
@@ -35,15 +34,6 @@ async function publish(pluginConfig, context) {
|
|
|
35
34
|
return publishGitHub(pluginConfig, context);
|
|
36
35
|
}
|
|
37
36
|
|
|
38
|
-
async function addChannel(pluginConfig, context) {
|
|
39
|
-
if (!verified) {
|
|
40
|
-
await verifyGitHub(pluginConfig, context);
|
|
41
|
-
verified = true;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return addChannelGitHub(pluginConfig, context);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
37
|
async function success(pluginConfig, context) {
|
|
48
38
|
if (!verified) {
|
|
49
39
|
await verifyGitHub(pluginConfig, context);
|
|
@@ -62,4 +52,4 @@ async function fail(pluginConfig, context) {
|
|
|
62
52
|
await failGitHub(pluginConfig, context);
|
|
63
53
|
}
|
|
64
54
|
|
|
65
|
-
module.exports = {verifyConditions,
|
|
55
|
+
module.exports = {verifyConditions, publish, success, fail};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = '<!-- semantic-release:github -->';
|
package/lib/fail.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const {template} = require('lodash');
|
|
2
2
|
const parseGithubUrl = require('parse-github-url');
|
|
3
3
|
const debug = require('debug')('semantic-release:github');
|
|
4
|
-
const
|
|
4
|
+
const ISSUE_ID = require('./definitions/sr-issue-id');
|
|
5
5
|
const resolveConfig = require('./resolve-config');
|
|
6
6
|
const getClient = require('./get-client');
|
|
7
7
|
const findSRIssues = require('./find-sr-issues');
|
|
@@ -9,8 +9,7 @@ const getFailComment = require('./get-fail-comment');
|
|
|
9
9
|
|
|
10
10
|
module.exports = async (pluginConfig, context) => {
|
|
11
11
|
const {
|
|
12
|
-
options: {repositoryUrl},
|
|
13
|
-
branch,
|
|
12
|
+
options: {branch, repositoryUrl},
|
|
14
13
|
errors,
|
|
15
14
|
logger,
|
|
16
15
|
} = context;
|
package/lib/find-sr-issues.js
CHANGED
package/lib/get-fail-comment.js
CHANGED
|
@@ -7,15 +7,16 @@ const NEW_ISSUE_URL = `${HOME_URL}/issues/new`;
|
|
|
7
7
|
const formatError = error => `### ${error.message}
|
|
8
8
|
|
|
9
9
|
${error.details ||
|
|
10
|
-
`
|
|
10
|
+
`Unfortunately this error doesn't have any additional information.${
|
|
11
11
|
error.pluginName
|
|
12
|
-
? ` Feel free to kindly ask the author of the \`${error.pluginName}\` plugin to add more helpful
|
|
12
|
+
? ` Feel free to kindly ask the author of the \`${error.pluginName}\` plugin to add more helpful information.`
|
|
13
13
|
: ''
|
|
14
14
|
}`}`;
|
|
15
15
|
|
|
16
|
-
module.exports = (
|
|
17
|
-
branch
|
|
18
|
-
|
|
16
|
+
module.exports = (
|
|
17
|
+
branch,
|
|
18
|
+
errors
|
|
19
|
+
) => `## :rotating_light: The automated release from the \`${branch}\` branch failed. :rotating_light:
|
|
19
20
|
|
|
20
21
|
I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.
|
|
21
22
|
|
|
@@ -23,9 +24,7 @@ You can find below the list of errors reported by **semantic-release**. Each one
|
|
|
23
24
|
|
|
24
25
|
Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.
|
|
25
26
|
|
|
26
|
-
Once all the errors are resolved, **semantic-release** will release your package the next time you push a commit to the \`${
|
|
27
|
-
branch.name
|
|
28
|
-
}\` branch. You can also manually restart the failed CI job that runs **semantic-release**.
|
|
27
|
+
Once all the errors are resolved, **semantic-release** will release your package the next time you push a commit to the \`${branch}\` branch. You can also manually restart the failed CI job that runs **semantic-release**.
|
|
29
28
|
|
|
30
29
|
If you are not sure how to resolve this, here is some links that can help you:
|
|
31
30
|
- [Usage documentation](${USAGE_DOC_URL})
|
package/lib/glob-assets.js
CHANGED
|
@@ -13,7 +13,6 @@ module.exports = async ({cwd}, assets) =>
|
|
|
13
13
|
assets.map(async asset => {
|
|
14
14
|
// Wrap single glob definition in Array
|
|
15
15
|
let glob = castArray(isPlainObject(asset) ? asset.path : asset);
|
|
16
|
-
|
|
17
16
|
// TODO Temporary workaround for https://github.com/mrmlnc/fast-glob/issues/47
|
|
18
17
|
glob = uniq([...(await dirGlob(glob, {cwd})), ...glob]);
|
|
19
18
|
|
package/lib/publish.js
CHANGED
|
@@ -4,40 +4,50 @@ const {isPlainObject} = require('lodash');
|
|
|
4
4
|
const parseGithubUrl = require('parse-github-url');
|
|
5
5
|
const mime = require('mime');
|
|
6
6
|
const debug = require('debug')('semantic-release:github');
|
|
7
|
-
const {RELEASE_NAME} = require('./definitions/constants');
|
|
8
7
|
const globAssets = require('./glob-assets.js');
|
|
9
8
|
const resolveConfig = require('./resolve-config');
|
|
10
9
|
const getClient = require('./get-client');
|
|
11
|
-
const isPrerelease = require('./is-prerelease');
|
|
12
10
|
|
|
13
11
|
module.exports = async (pluginConfig, context) => {
|
|
14
12
|
const {
|
|
15
13
|
cwd,
|
|
16
|
-
options: {repositoryUrl},
|
|
17
|
-
|
|
18
|
-
nextRelease: {name, gitTag, notes},
|
|
14
|
+
options: {branch, repositoryUrl},
|
|
15
|
+
nextRelease: {gitTag, notes},
|
|
19
16
|
logger,
|
|
20
17
|
} = context;
|
|
21
18
|
const {githubToken, githubUrl, githubApiPathPrefix, proxy, assets} = resolveConfig(pluginConfig, context);
|
|
22
19
|
const {name: repo, owner} = parseGithubUrl(repositoryUrl);
|
|
23
20
|
const github = getClient({githubToken, githubUrl, githubApiPathPrefix, proxy});
|
|
24
|
-
const release = {owner, repo, tag_name: gitTag, name, body: notes, prerelease: isPrerelease(branch)};
|
|
25
21
|
|
|
26
|
-
|
|
22
|
+
/* eslint-disable camelcase */
|
|
23
|
+
const releaseData = {
|
|
24
|
+
owner,
|
|
25
|
+
repo,
|
|
26
|
+
tag_name: gitTag,
|
|
27
|
+
name: gitTag,
|
|
28
|
+
target_commitish: branch,
|
|
29
|
+
body: notes,
|
|
30
|
+
};
|
|
31
|
+
/* eslint-enable */
|
|
32
|
+
|
|
33
|
+
debug('release owner: %o', owner);
|
|
34
|
+
debug('release repo: %o', repo);
|
|
35
|
+
debug('release name: %o', gitTag);
|
|
36
|
+
debug('release branch: %o', branch);
|
|
27
37
|
|
|
28
38
|
// When there are no assets, we publish a release directly
|
|
29
39
|
if (!assets || assets.length === 0) {
|
|
30
40
|
const {
|
|
31
41
|
data: {html_url: url},
|
|
32
|
-
} = await github.repos.createRelease(
|
|
42
|
+
} = await github.repos.createRelease(releaseData);
|
|
33
43
|
|
|
34
44
|
logger.log('Published GitHub release: %s', url);
|
|
35
|
-
return {url, name:
|
|
45
|
+
return {url, name: 'GitHub release'};
|
|
36
46
|
}
|
|
37
47
|
|
|
38
48
|
// We'll create a draft release, append the assets to it, and then publish it.
|
|
39
49
|
// This is so that the assets are available when we get a Github release event.
|
|
40
|
-
const draftRelease = {...
|
|
50
|
+
const draftRelease = {...releaseData, draft: true};
|
|
41
51
|
|
|
42
52
|
const {
|
|
43
53
|
data: {html_url: url, upload_url: uploadUrl, id: releaseId},
|
|
@@ -89,8 +99,17 @@ module.exports = async (pluginConfig, context) => {
|
|
|
89
99
|
})
|
|
90
100
|
);
|
|
91
101
|
|
|
92
|
-
|
|
102
|
+
/* eslint-disable camelcase */
|
|
103
|
+
const release = {
|
|
104
|
+
owner,
|
|
105
|
+
repo,
|
|
106
|
+
release_id: releaseId,
|
|
107
|
+
draft: false,
|
|
108
|
+
};
|
|
109
|
+
/* eslint-enable */
|
|
110
|
+
|
|
111
|
+
await github.repos.updateRelease(release);
|
|
93
112
|
|
|
94
113
|
logger.log('Published GitHub release: %s', url);
|
|
95
|
-
return {url, name:
|
|
114
|
+
return {url, name: 'GitHub release'};
|
|
96
115
|
};
|
package/lib/resolve-config.js
CHANGED
|
@@ -25,9 +25,5 @@ module.exports = (
|
|
|
25
25
|
failComment,
|
|
26
26
|
labels: isNil(labels) ? ['semantic-release'] : labels === false ? false : castArray(labels),
|
|
27
27
|
assignees: assignees ? castArray(assignees) : assignees,
|
|
28
|
-
releasedLabels: isNil(releasedLabels)
|
|
29
|
-
? [`released<%= nextRelease.channel ? \` on @\${nextRelease.channel}\` : "" %>`]
|
|
30
|
-
: releasedLabels === false
|
|
31
|
-
? false
|
|
32
|
-
: castArray(releasedLabels),
|
|
28
|
+
releasedLabels: isNil(releasedLabels) ? ['released'] : releasedLabels === false ? false : castArray(releasedLabels),
|
|
33
29
|
});
|
package/lib/success.js
CHANGED
|
@@ -12,7 +12,8 @@ const findSRIssues = require('./find-sr-issues');
|
|
|
12
12
|
|
|
13
13
|
module.exports = async (pluginConfig, context) => {
|
|
14
14
|
const {
|
|
15
|
-
options: {repositoryUrl},
|
|
15
|
+
options: {branch, repositoryUrl},
|
|
16
|
+
lastRelease,
|
|
16
17
|
commits,
|
|
17
18
|
nextRelease,
|
|
18
19
|
releases,
|
|
@@ -73,31 +74,36 @@ module.exports = async (pluginConfig, context) => {
|
|
|
73
74
|
await Promise.all(
|
|
74
75
|
uniqBy([...prs, ...issues], 'number').map(async issue => {
|
|
75
76
|
const body = successComment
|
|
76
|
-
? template(successComment)({
|
|
77
|
+
? template(successComment)({branch, lastRelease, commits, nextRelease, releases, issue})
|
|
77
78
|
: getSuccessComment(issue, releaseInfos, nextRelease);
|
|
78
79
|
try {
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
repo,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
80
|
+
const state = issue.state || (await github.issues.get({owner, repo, issue_number: issue.number})).data.state;
|
|
81
|
+
|
|
82
|
+
if (state === 'closed') {
|
|
83
|
+
const comment = {owner, repo, issue_number: issue.number, body};
|
|
84
|
+
debug('create comment: %O', comment);
|
|
85
|
+
const {
|
|
86
|
+
data: {html_url: url},
|
|
87
|
+
} = await github.issues.createComment(comment);
|
|
88
|
+
logger.log('Added comment to issue #%d: %s', issue.number, url);
|
|
89
|
+
|
|
90
|
+
if (releasedLabels) {
|
|
91
|
+
// Don’t use .issues.addLabels for GHE < 2.16 support
|
|
92
|
+
// https://github.com/semantic-release/github/issues/138
|
|
93
|
+
await github.request('POST /repos/:owner/:repo/issues/:number/labels', {
|
|
94
|
+
owner,
|
|
95
|
+
repo,
|
|
96
|
+
number: issue.number,
|
|
97
|
+
data: releasedLabels,
|
|
98
|
+
});
|
|
99
|
+
logger.log('Added labels %O to issue #%d', releasedLabels, issue.number);
|
|
100
|
+
}
|
|
101
|
+
} else {
|
|
102
|
+
logger.log("Skip comment and labels on issue #%d as it's open: %s", issue.number);
|
|
97
103
|
}
|
|
98
104
|
} catch (error) {
|
|
99
105
|
if (error.status === 404) {
|
|
100
|
-
logger.error("Failed to add a comment to the issue #%d as it doesn't
|
|
106
|
+
logger.error("Failed to add a comment to the issue #%d as it doesn't exist.", issue.number);
|
|
101
107
|
} else {
|
|
102
108
|
errors.push(error);
|
|
103
109
|
logger.error('Failed to add a comment to the issue #%d.', issue.number);
|
package/lib/verify.js
CHANGED
|
@@ -27,6 +27,7 @@ const VALIDATORS = {
|
|
|
27
27
|
|
|
28
28
|
module.exports = async (pluginConfig, context) => {
|
|
29
29
|
const {
|
|
30
|
+
env,
|
|
30
31
|
options: {repositoryUrl},
|
|
31
32
|
logger,
|
|
32
33
|
} = context;
|
|
@@ -52,6 +53,14 @@ module.exports = async (pluginConfig, context) => {
|
|
|
52
53
|
} else if (githubToken && !errors.find(({code}) => code === 'EINVALIDPROXY')) {
|
|
53
54
|
const github = getClient({githubToken, githubUrl, githubApiPathPrefix, proxy});
|
|
54
55
|
|
|
56
|
+
// https://github.com/semantic-release/github/issues/182
|
|
57
|
+
// Do not check for permissions in GitHub actions, as the provided token is an installation access token.
|
|
58
|
+
// github.repos.get({repo, owner}) does not return the "permissions" key in that case. But GitHub Actions
|
|
59
|
+
// have all permissions required for @semantic-release/github to work
|
|
60
|
+
if (env.GITHUB_ACTION) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
55
64
|
try {
|
|
56
65
|
const {
|
|
57
66
|
data: {
|
package/package.json
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
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": "5.4.
|
|
4
|
+
"version": "5.4.3",
|
|
5
5
|
"author": "Pierre Vanduynslager (https://twitter.com/@pvdlg_)",
|
|
6
|
+
"ava": {
|
|
7
|
+
"helpers": [
|
|
8
|
+
"test/helpers/**/*"
|
|
9
|
+
]
|
|
10
|
+
},
|
|
6
11
|
"bugs": {
|
|
7
12
|
"url": "https://github.com/semantic-release/github/issues"
|
|
8
13
|
},
|
|
@@ -16,35 +21,35 @@
|
|
|
16
21
|
"Gregor Martynus (https://twitter.com/gr2m)"
|
|
17
22
|
],
|
|
18
23
|
"dependencies": {
|
|
19
|
-
"@octokit/rest": "^16.
|
|
24
|
+
"@octokit/rest": "^16.27.0",
|
|
20
25
|
"@semantic-release/error": "^2.2.0",
|
|
21
26
|
"aggregate-error": "^3.0.0",
|
|
22
|
-
"bottleneck": "^2.
|
|
27
|
+
"bottleneck": "^2.18.1",
|
|
23
28
|
"debug": "^4.0.0",
|
|
24
|
-
"dir-glob": "^
|
|
25
|
-
"fs-extra": "^
|
|
26
|
-
"globby": "^
|
|
29
|
+
"dir-glob": "^3.0.0",
|
|
30
|
+
"fs-extra": "^8.0.0",
|
|
31
|
+
"globby": "^10.0.0",
|
|
27
32
|
"http-proxy-agent": "^2.1.0",
|
|
28
33
|
"https-proxy-agent": "^2.2.1",
|
|
29
|
-
"issue-parser": "^
|
|
34
|
+
"issue-parser": "^4.0.0",
|
|
30
35
|
"lodash": "^4.17.4",
|
|
31
|
-
"mime": "^2.
|
|
36
|
+
"mime": "^2.4.3",
|
|
32
37
|
"p-filter": "^2.0.0",
|
|
33
38
|
"p-retry": "^4.0.0",
|
|
34
39
|
"parse-github-url": "^1.0.1",
|
|
35
40
|
"url-join": "^4.0.0"
|
|
36
41
|
},
|
|
37
42
|
"devDependencies": {
|
|
38
|
-
"ava": "^
|
|
39
|
-
"clear-module": "^
|
|
40
|
-
"codecov": "^3.
|
|
43
|
+
"ava": "^2.0.0",
|
|
44
|
+
"clear-module": "^4.0.0",
|
|
45
|
+
"codecov": "^3.5.0",
|
|
41
46
|
"commitizen": "^3.0.0",
|
|
42
47
|
"cz-conventional-changelog": "^2.0.0",
|
|
43
48
|
"nock": "^10.0.0",
|
|
44
|
-
"nyc": "^14.
|
|
49
|
+
"nyc": "^14.1.1",
|
|
45
50
|
"proxy": "^0.2.4",
|
|
46
51
|
"proxyquire": "^2.0.0",
|
|
47
|
-
"semantic-release": "^
|
|
52
|
+
"semantic-release": "^15.13.12",
|
|
48
53
|
"server-destroy": "^1.0.1",
|
|
49
54
|
"sinon": "^7.1.1",
|
|
50
55
|
"tempy": "^0.3.0",
|
|
@@ -84,14 +89,15 @@
|
|
|
84
89
|
"all": true
|
|
85
90
|
},
|
|
86
91
|
"peerDependencies": {
|
|
87
|
-
"semantic-release": ">=
|
|
92
|
+
"semantic-release": ">=15.8.0 <16.0.0"
|
|
88
93
|
},
|
|
89
94
|
"prettier": {
|
|
90
95
|
"printWidth": 120,
|
|
91
96
|
"trailingComma": "es5"
|
|
92
97
|
},
|
|
93
98
|
"publishConfig": {
|
|
94
|
-
"access": "public"
|
|
99
|
+
"access": "public",
|
|
100
|
+
"tag": "next"
|
|
95
101
|
},
|
|
96
102
|
"repository": {
|
|
97
103
|
"type": "git",
|
|
@@ -114,9 +120,7 @@
|
|
|
114
120
|
{
|
|
115
121
|
"allow": [
|
|
116
122
|
"issue_number",
|
|
117
|
-
"pull_number"
|
|
118
|
-
"tag_name",
|
|
119
|
-
"release_id"
|
|
123
|
+
"pull_number"
|
|
120
124
|
]
|
|
121
125
|
}
|
|
122
126
|
]
|
package/lib/add-channel.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
const parseGithubUrl = require('parse-github-url');
|
|
2
|
-
const debug = require('debug')('semantic-release:github');
|
|
3
|
-
const {RELEASE_NAME} = require('./definitions/constants');
|
|
4
|
-
const resolveConfig = require('./resolve-config');
|
|
5
|
-
const getClient = require('./get-client');
|
|
6
|
-
const isPrerelease = require('./is-prerelease');
|
|
7
|
-
|
|
8
|
-
module.exports = async (pluginConfig, context) => {
|
|
9
|
-
const {
|
|
10
|
-
options: {repositoryUrl},
|
|
11
|
-
branch,
|
|
12
|
-
currentRelease: {gitTag: currentGitTag, channel: currentChannel},
|
|
13
|
-
nextRelease: {name, gitTag, notes},
|
|
14
|
-
logger,
|
|
15
|
-
} = context;
|
|
16
|
-
const {githubToken, githubUrl, githubApiPathPrefix, proxy} = resolveConfig(pluginConfig, context);
|
|
17
|
-
const {name: repo, owner} = parseGithubUrl(repositoryUrl);
|
|
18
|
-
const github = getClient({githubToken, githubUrl, githubApiPathPrefix, proxy});
|
|
19
|
-
let release_id;
|
|
20
|
-
|
|
21
|
-
const release = {owner, repo, name, prerelease: isPrerelease(branch)};
|
|
22
|
-
|
|
23
|
-
debug('release owner: %o', release.owner);
|
|
24
|
-
debug('release repo: %o', release.repo);
|
|
25
|
-
debug('release tag_name: %o', release.tag_name);
|
|
26
|
-
debug('release name: %o', release.name);
|
|
27
|
-
debug('release prerelease: %o', release.prerelease);
|
|
28
|
-
|
|
29
|
-
try {
|
|
30
|
-
({
|
|
31
|
-
data: {id: release_id},
|
|
32
|
-
} = await github.repos.getReleaseByTag({owner, repo, tag: currentGitTag}));
|
|
33
|
-
} catch (error) {
|
|
34
|
-
if (error.status === 404) {
|
|
35
|
-
logger.log('There is no release for tag %s, creating a new one', currentGitTag);
|
|
36
|
-
|
|
37
|
-
debug('release tag_name: %o', gitTag);
|
|
38
|
-
|
|
39
|
-
const {
|
|
40
|
-
data: {html_url: url},
|
|
41
|
-
} = await github.repos.createRelease({...release, body: notes, tag_name: gitTag});
|
|
42
|
-
|
|
43
|
-
logger.log('Published GitHub release: %s', url);
|
|
44
|
-
return {url, name: RELEASE_NAME};
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
throw error;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const tag_name = currentChannel ? gitTag : undefined;
|
|
51
|
-
|
|
52
|
-
debug('release release_id: %o', release_id);
|
|
53
|
-
debug('release tag_name: %o', tag_name);
|
|
54
|
-
|
|
55
|
-
const {
|
|
56
|
-
data: {html_url: url},
|
|
57
|
-
} = await github.repos.updateRelease({...release, release_id, tag_name});
|
|
58
|
-
|
|
59
|
-
logger.log('Updated GitHub release: %s', url);
|
|
60
|
-
|
|
61
|
-
return {url, name: RELEASE_NAME};
|
|
62
|
-
};
|
package/lib/is-prerelease.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = ({type, channel}) => type === 'prerelease' || (type === 'release' && Boolean(channel));
|