@semantic-release/github 9.0.2 → 9.0.4
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 +1 -1
- package/index.js +10 -10
- package/lib/add-channel.js +3 -3
- package/lib/definitions/errors.js +21 -21
- package/lib/fail.js +3 -3
- package/lib/get-release-links.js +1 -1
- package/lib/glob-assets.js +3 -3
- package/lib/octokit.js +2 -2
- package/lib/parse-github-url.js +3 -3
- package/lib/publish.js +7 -7
- package/lib/resolve-config.js +1 -1
- package/lib/success.js +24 -24
- package/lib/verify.js +5 -5
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -209,7 +209,7 @@ Each label name is generated with [Lodash template](https://lodash.com/docs#temp
|
|
|
209
209
|
|
|
210
210
|
##### releasedLabels example
|
|
211
211
|
|
|
212
|
-
The `releasedLabels` ``
|
|
212
|
+
The `releasedLabels` ``['released<%= nextRelease.channel ? ` on @\${nextRelease.channel}` : "" %> from <%= branch.name %>']`` will generate the label:
|
|
213
213
|
|
|
214
214
|
> released on @next from branch next
|
|
215
215
|
|
package/index.js
CHANGED
|
@@ -14,33 +14,33 @@ let verified;
|
|
|
14
14
|
export async function verifyConditions(
|
|
15
15
|
pluginConfig,
|
|
16
16
|
context,
|
|
17
|
-
{ Octokit = SemanticReleaseOctokit } = {}
|
|
17
|
+
{ Octokit = SemanticReleaseOctokit } = {},
|
|
18
18
|
) {
|
|
19
19
|
const { options } = context;
|
|
20
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
|
|
21
21
|
if (options.publish) {
|
|
22
22
|
const publishPlugin =
|
|
23
23
|
castArray(options.publish).find(
|
|
24
|
-
(config) => config.path && config.path === "@semantic-release/github"
|
|
24
|
+
(config) => config.path && config.path === "@semantic-release/github",
|
|
25
25
|
) || {};
|
|
26
26
|
|
|
27
27
|
pluginConfig.assets = defaultTo(pluginConfig.assets, publishPlugin.assets);
|
|
28
28
|
pluginConfig.successComment = defaultTo(
|
|
29
29
|
pluginConfig.successComment,
|
|
30
|
-
publishPlugin.successComment
|
|
30
|
+
publishPlugin.successComment,
|
|
31
31
|
);
|
|
32
32
|
pluginConfig.failComment = defaultTo(
|
|
33
33
|
pluginConfig.failComment,
|
|
34
|
-
publishPlugin.failComment
|
|
34
|
+
publishPlugin.failComment,
|
|
35
35
|
);
|
|
36
36
|
pluginConfig.failTitle = defaultTo(
|
|
37
37
|
pluginConfig.failTitle,
|
|
38
|
-
publishPlugin.failTitle
|
|
38
|
+
publishPlugin.failTitle,
|
|
39
39
|
);
|
|
40
40
|
pluginConfig.labels = defaultTo(pluginConfig.labels, publishPlugin.labels);
|
|
41
41
|
pluginConfig.assignees = defaultTo(
|
|
42
42
|
pluginConfig.assignees,
|
|
43
|
-
publishPlugin.assignees
|
|
43
|
+
publishPlugin.assignees,
|
|
44
44
|
);
|
|
45
45
|
}
|
|
46
46
|
|
|
@@ -51,7 +51,7 @@ export async function verifyConditions(
|
|
|
51
51
|
export async function publish(
|
|
52
52
|
pluginConfig,
|
|
53
53
|
context,
|
|
54
|
-
{ Octokit = SemanticReleaseOctokit } = {}
|
|
54
|
+
{ Octokit = SemanticReleaseOctokit } = {},
|
|
55
55
|
) {
|
|
56
56
|
if (!verified) {
|
|
57
57
|
await verifyGitHub(pluginConfig, context, { Octokit });
|
|
@@ -64,7 +64,7 @@ export async function publish(
|
|
|
64
64
|
export async function addChannel(
|
|
65
65
|
pluginConfig,
|
|
66
66
|
context,
|
|
67
|
-
{ Octokit = SemanticReleaseOctokit } = {}
|
|
67
|
+
{ Octokit = SemanticReleaseOctokit } = {},
|
|
68
68
|
) {
|
|
69
69
|
if (!verified) {
|
|
70
70
|
await verifyGitHub(pluginConfig, context, { Octokit });
|
|
@@ -77,7 +77,7 @@ export async function addChannel(
|
|
|
77
77
|
export async function success(
|
|
78
78
|
pluginConfig,
|
|
79
79
|
context,
|
|
80
|
-
{ Octokit = SemanticReleaseOctokit } = {}
|
|
80
|
+
{ Octokit = SemanticReleaseOctokit } = {},
|
|
81
81
|
) {
|
|
82
82
|
if (!verified) {
|
|
83
83
|
await verifyGitHub(pluginConfig, context, { Octokit });
|
|
@@ -90,7 +90,7 @@ export async function success(
|
|
|
90
90
|
export async function fail(
|
|
91
91
|
pluginConfig,
|
|
92
92
|
context,
|
|
93
|
-
{ Octokit = SemanticReleaseOctokit } = {}
|
|
93
|
+
{ Octokit = SemanticReleaseOctokit } = {},
|
|
94
94
|
) {
|
|
95
95
|
if (!verified) {
|
|
96
96
|
await verifyGitHub(pluginConfig, context, { Octokit });
|
package/lib/add-channel.js
CHANGED
|
@@ -17,7 +17,7 @@ export default async function addChannel(pluginConfig, context, { Octokit }) {
|
|
|
17
17
|
} = context;
|
|
18
18
|
const { githubToken, githubUrl, githubApiPathPrefix, proxy } = resolveConfig(
|
|
19
19
|
pluginConfig,
|
|
20
|
-
context
|
|
20
|
+
context,
|
|
21
21
|
);
|
|
22
22
|
const { owner, repo } = parseGithubUrl(repositoryUrl);
|
|
23
23
|
const octokit = new Octokit(
|
|
@@ -26,7 +26,7 @@ export default async function addChannel(pluginConfig, context, { Octokit }) {
|
|
|
26
26
|
githubUrl,
|
|
27
27
|
githubApiPathPrefix,
|
|
28
28
|
proxy,
|
|
29
|
-
})
|
|
29
|
+
}),
|
|
30
30
|
);
|
|
31
31
|
let releaseId;
|
|
32
32
|
|
|
@@ -72,7 +72,7 @@ export default async function addChannel(pluginConfig, context, { Octokit }) {
|
|
|
72
72
|
data: { html_url: url },
|
|
73
73
|
} = await octokit.request(
|
|
74
74
|
"PATCH /repos/{owner}/{repo}/releases/{release_id}",
|
|
75
|
-
{ ...release, release_id: releaseId }
|
|
75
|
+
{ ...release, release_id: releaseId },
|
|
76
76
|
);
|
|
77
77
|
|
|
78
78
|
logger.log("Updated GitHub release: %s", url);
|
|
@@ -21,7 +21,7 @@ export function EINVALIDASSETS({ assets }) {
|
|
|
21
21
|
return {
|
|
22
22
|
message: "Invalid `assets` option.",
|
|
23
23
|
details: `The [assets option](${linkify(
|
|
24
|
-
"README.md#assets"
|
|
24
|
+
"README.md#assets",
|
|
25
25
|
)}) must be an \`Array\` of \`Strings\` or \`Objects\` with a \`path\` property.
|
|
26
26
|
|
|
27
27
|
Your configuration for the \`assets\` option is \`${stringify(assets)}\`.`,
|
|
@@ -32,11 +32,11 @@ export function EINVALIDSUCCESSCOMMENT({ successComment }) {
|
|
|
32
32
|
return {
|
|
33
33
|
message: "Invalid `successComment` option.",
|
|
34
34
|
details: `The [successComment option](${linkify(
|
|
35
|
-
"README.md#successcomment"
|
|
35
|
+
"README.md#successcomment",
|
|
36
36
|
)}) if defined, must be a non empty \`String\`.
|
|
37
37
|
|
|
38
38
|
Your configuration for the \`successComment\` option is \`${stringify(
|
|
39
|
-
successComment
|
|
39
|
+
successComment,
|
|
40
40
|
)}\`.`,
|
|
41
41
|
};
|
|
42
42
|
}
|
|
@@ -45,11 +45,11 @@ export function EINVALIDFAILTITLE({ failTitle }) {
|
|
|
45
45
|
return {
|
|
46
46
|
message: "Invalid `failTitle` option.",
|
|
47
47
|
details: `The [failTitle option](${linkify(
|
|
48
|
-
"README.md#failtitle"
|
|
48
|
+
"README.md#failtitle",
|
|
49
49
|
)}) if defined, must be a non empty \`String\`.
|
|
50
50
|
|
|
51
51
|
Your configuration for the \`failTitle\` option is \`${stringify(
|
|
52
|
-
failTitle
|
|
52
|
+
failTitle,
|
|
53
53
|
)}\`.`,
|
|
54
54
|
};
|
|
55
55
|
}
|
|
@@ -58,11 +58,11 @@ export function EINVALIDFAILCOMMENT({ failComment }) {
|
|
|
58
58
|
return {
|
|
59
59
|
message: "Invalid `failComment` option.",
|
|
60
60
|
details: `The [failComment option](${linkify(
|
|
61
|
-
"README.md#failcomment"
|
|
61
|
+
"README.md#failcomment",
|
|
62
62
|
)}) if defined, must be a non empty \`String\`.
|
|
63
63
|
|
|
64
64
|
Your configuration for the \`failComment\` option is \`${stringify(
|
|
65
|
-
failComment
|
|
65
|
+
failComment,
|
|
66
66
|
)}\`.`,
|
|
67
67
|
};
|
|
68
68
|
}
|
|
@@ -71,7 +71,7 @@ export function EINVALIDLABELS({ labels }) {
|
|
|
71
71
|
return {
|
|
72
72
|
message: "Invalid `labels` option.",
|
|
73
73
|
details: `The [labels option](${linkify(
|
|
74
|
-
"README.md#options"
|
|
74
|
+
"README.md#options",
|
|
75
75
|
)}) if defined, must be an \`Array\` of non empty \`String\`.
|
|
76
76
|
|
|
77
77
|
Your configuration for the \`labels\` option is \`${stringify(labels)}\`.`,
|
|
@@ -82,11 +82,11 @@ export function EINVALIDASSIGNEES({ assignees }) {
|
|
|
82
82
|
return {
|
|
83
83
|
message: "Invalid `assignees` option.",
|
|
84
84
|
details: `The [assignees option](${linkify(
|
|
85
|
-
"README.md#options"
|
|
85
|
+
"README.md#options",
|
|
86
86
|
)}) must be an \`Array\` of non empty \`Strings\`.
|
|
87
87
|
|
|
88
88
|
Your configuration for the \`assignees\` option is \`${stringify(
|
|
89
|
-
assignees
|
|
89
|
+
assignees,
|
|
90
90
|
)}\`.`,
|
|
91
91
|
};
|
|
92
92
|
}
|
|
@@ -95,11 +95,11 @@ export function EINVALIDRELEASEDLABELS({ releasedLabels }) {
|
|
|
95
95
|
return {
|
|
96
96
|
message: "Invalid `releasedLabels` option.",
|
|
97
97
|
details: `The [releasedLabels option](${linkify(
|
|
98
|
-
"README.md#options"
|
|
98
|
+
"README.md#options",
|
|
99
99
|
)}) if defined, must be an \`Array\` of non empty \`String\`.
|
|
100
100
|
|
|
101
101
|
Your configuration for the \`releasedLabels\` option is \`${stringify(
|
|
102
|
-
releasedLabels
|
|
102
|
+
releasedLabels,
|
|
103
103
|
)}\`.`,
|
|
104
104
|
};
|
|
105
105
|
}
|
|
@@ -108,11 +108,11 @@ export function EINVALIDADDRELEASES({ addReleases }) {
|
|
|
108
108
|
return {
|
|
109
109
|
message: "Invalid `addReleases` option.",
|
|
110
110
|
details: `The [addReleases option](${linkify(
|
|
111
|
-
"README.md#options"
|
|
111
|
+
"README.md#options",
|
|
112
112
|
)}) if defined, must be one of \`false|top|bottom\`.
|
|
113
113
|
|
|
114
114
|
Your configuration for the \`addReleases\` option is \`${stringify(
|
|
115
|
-
addReleases
|
|
115
|
+
addReleases,
|
|
116
116
|
)}\`.`,
|
|
117
117
|
};
|
|
118
118
|
}
|
|
@@ -121,11 +121,11 @@ export function EINVALIDDRAFTRELEASE({ draftRelease }) {
|
|
|
121
121
|
return {
|
|
122
122
|
message: "Invalid `draftRelease` option.",
|
|
123
123
|
details: `The [draftRelease option](${linkify(
|
|
124
|
-
"README.md#options"
|
|
124
|
+
"README.md#options",
|
|
125
125
|
)}) if defined, must be a \`Boolean\`.
|
|
126
126
|
|
|
127
127
|
Your configuration for the \`draftRelease\` option is \`${stringify(
|
|
128
|
-
draftRelease
|
|
128
|
+
draftRelease,
|
|
129
129
|
)}\`.`,
|
|
130
130
|
};
|
|
131
131
|
}
|
|
@@ -143,7 +143,7 @@ export function EINVALIDPROXY({ proxy }) {
|
|
|
143
143
|
return {
|
|
144
144
|
message: "Invalid `proxy` option.",
|
|
145
145
|
details: `The [proxy option](${linkify(
|
|
146
|
-
"README.md#proxy"
|
|
146
|
+
"README.md#proxy",
|
|
147
147
|
)}) must be a \`String\` or an \`Objects\` with a \`host\` and a \`port\` property.
|
|
148
148
|
|
|
149
149
|
Your configuration for the \`proxy\` option is \`${stringify(proxy)}\`.`,
|
|
@@ -158,7 +158,7 @@ export function EMISSINGREPO({ owner, repo }) {
|
|
|
158
158
|
By default the \`repositoryUrl\` option is retrieved from the \`repository\` property of your \`package.json\` or the [git origin url](https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes) of the repository cloned by your CI environment.
|
|
159
159
|
|
|
160
160
|
If you are using [GitHub Enterprise](https://enterprise.github.com) please make sure to configure the \`githubUrl\` and \`githubApiPathPrefix\` [options](${linkify(
|
|
161
|
-
"README.md#options"
|
|
161
|
+
"README.md#options",
|
|
162
162
|
)}).`,
|
|
163
163
|
};
|
|
164
164
|
}
|
|
@@ -167,7 +167,7 @@ export function EGHNOPERMISSION({ owner, repo }) {
|
|
|
167
167
|
return {
|
|
168
168
|
message: `The GitHub token doesn't allow to push on the repository ${owner}/${repo}.`,
|
|
169
169
|
details: `The user associated with the [GitHub token](${linkify(
|
|
170
|
-
"README.md#github-authentication"
|
|
170
|
+
"README.md#github-authentication",
|
|
171
171
|
)}) configured in the \`GH_TOKEN\` or \`GITHUB_TOKEN\` environment variable must allows to push to the repository ${owner}/${repo}.
|
|
172
172
|
|
|
173
173
|
Please make sure the GitHub user associated with the token is an [owner](https://help.github.com/articles/permission-levels-for-a-user-account-repository/#owner-access-on-a-repository-owned-by-a-user-account) or a [collaborator](https://help.github.com/articles/permission-levels-for-a-user-account-repository/#collaborator-access-on-a-repository-owned-by-a-user-account) if the reposotory belong to a user account or has [write permissions](https://help.github.com/articles/managing-team-access-to-an-organization-repository) if the repository [belongs to an organization](https://help.github.com/articles/repository-permission-levels-for-an-organization).`,
|
|
@@ -178,7 +178,7 @@ export function EINVALIDGHTOKEN({ owner, repo }) {
|
|
|
178
178
|
return {
|
|
179
179
|
message: "Invalid GitHub token.",
|
|
180
180
|
details: `The [GitHub token](${linkify(
|
|
181
|
-
"README.md#github-authentication"
|
|
181
|
+
"README.md#github-authentication",
|
|
182
182
|
)}) configured in the \`GH_TOKEN\` or \`GITHUB_TOKEN\` environment variable must be a valid [personal token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line) allowing to push to the repository ${owner}/${repo}.
|
|
183
183
|
|
|
184
184
|
Please make sure to set the \`GH_TOKEN\` or \`GITHUB_TOKEN\` environment variable in your CI with the exact value of the GitHub personal token.`,
|
|
@@ -189,7 +189,7 @@ export function ENOGHTOKEN({ owner, repo }) {
|
|
|
189
189
|
return {
|
|
190
190
|
message: "No GitHub token specified.",
|
|
191
191
|
details: `A [GitHub personal token](${linkify(
|
|
192
|
-
"README.md#github-authentication"
|
|
192
|
+
"README.md#github-authentication",
|
|
193
193
|
)}) must be created and set in the \`GH_TOKEN\` or \`GITHUB_TOKEN\` environment variable on your CI environment.
|
|
194
194
|
|
|
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}.`,
|
package/lib/fail.js
CHANGED
|
@@ -32,12 +32,12 @@ export default async function fail(pluginConfig, context, { Octokit }) {
|
|
|
32
32
|
logger.log("Skip issue creation.");
|
|
33
33
|
} else {
|
|
34
34
|
const octokit = new Octokit(
|
|
35
|
-
toOctokitOptions({ githubToken, githubUrl, githubApiPathPrefix, proxy })
|
|
35
|
+
toOctokitOptions({ githubToken, githubUrl, githubApiPathPrefix, proxy }),
|
|
36
36
|
);
|
|
37
37
|
// In case the repo changed name, get the new `repo`/`owner` as the search API will not follow redirects
|
|
38
38
|
const { data: repoData } = await octokit.request(
|
|
39
39
|
"GET /repos/{owner}/{repo}",
|
|
40
|
-
parseGithubUrl(repositoryUrl)
|
|
40
|
+
parseGithubUrl(repositoryUrl),
|
|
41
41
|
);
|
|
42
42
|
const [owner, repo] = repoData.full_name.split("/");
|
|
43
43
|
const body = failComment
|
|
@@ -53,7 +53,7 @@ export default async function fail(pluginConfig, context, { Octokit }) {
|
|
|
53
53
|
data: { html_url: url },
|
|
54
54
|
} = await octokit.request(
|
|
55
55
|
"POST /repos/{owner}/{repo}/issues/{issue_number}/comments",
|
|
56
|
-
comment
|
|
56
|
+
comment,
|
|
57
57
|
);
|
|
58
58
|
logger.log("Added comment to issue #%d: %s.", srIssue.number, url);
|
|
59
59
|
} else {
|
package/lib/get-release-links.js
CHANGED
|
@@ -11,7 +11,7 @@ const linkify = (releaseInfo) =>
|
|
|
11
11
|
|
|
12
12
|
const filterReleases = (releaseInfos) =>
|
|
13
13
|
releaseInfos.filter(
|
|
14
|
-
(releaseInfo) => releaseInfo.name && releaseInfo.name !== RELEASE_NAME
|
|
14
|
+
(releaseInfo) => releaseInfo.name && releaseInfo.name !== RELEASE_NAME,
|
|
15
15
|
);
|
|
16
16
|
|
|
17
17
|
export default function getReleaseLinks(releaseInfos) {
|
package/lib/glob-assets.js
CHANGED
|
@@ -22,7 +22,7 @@ export default async function globAssets({ cwd }, assets) {
|
|
|
22
22
|
if (glob.length <= 1 && glob[0].startsWith("!")) {
|
|
23
23
|
debug(
|
|
24
24
|
"skipping the negated glob %o as its alone in its group and would retrieve a large amount of files",
|
|
25
|
-
glob[0]
|
|
25
|
+
glob[0],
|
|
26
26
|
);
|
|
27
27
|
return [];
|
|
28
28
|
}
|
|
@@ -62,7 +62,7 @@ export default async function globAssets({ cwd }, assets) {
|
|
|
62
62
|
|
|
63
63
|
// If asset is a String definition but no match is found, output the elements of the original glob (each one will be considered as a missing file)
|
|
64
64
|
return glob;
|
|
65
|
-
})
|
|
65
|
+
}),
|
|
66
66
|
// Sort with Object first, to prioritize Object definition over Strings in dedup
|
|
67
67
|
)
|
|
68
68
|
)
|
|
@@ -71,6 +71,6 @@ export default async function globAssets({ cwd }, assets) {
|
|
|
71
71
|
// Compare `path` property if Object definition, value itself if String
|
|
72
72
|
(a, b) =>
|
|
73
73
|
resolve(cwd, isPlainObject(a) ? a.path : a) ===
|
|
74
|
-
resolve(cwd, isPlainObject(b) ? b.path : b)
|
|
74
|
+
resolve(cwd, isPlainObject(b) ? b.path : b),
|
|
75
75
|
);
|
|
76
76
|
}
|
package/lib/octokit.js
CHANGED
|
@@ -24,7 +24,7 @@ const pkg = require("../package.json");
|
|
|
24
24
|
|
|
25
25
|
const onRetry = (retryAfter, options, octokit, retryCount) => {
|
|
26
26
|
octokit.log.warn(
|
|
27
|
-
`Request quota exhausted for request ${options.method} ${options.url}
|
|
27
|
+
`Request quota exhausted for request ${options.method} ${options.url}`,
|
|
28
28
|
);
|
|
29
29
|
|
|
30
30
|
if (retryCount <= RETRY_CONF.retries) {
|
|
@@ -36,7 +36,7 @@ const onRetry = (retryAfter, options, octokit, retryCount) => {
|
|
|
36
36
|
export const SemanticReleaseOctokit = Octokit.plugin(
|
|
37
37
|
paginateRest,
|
|
38
38
|
retry,
|
|
39
|
-
throttling
|
|
39
|
+
throttling,
|
|
40
40
|
).defaults({
|
|
41
41
|
userAgent: `@semantic-release/github v${pkg.version}`,
|
|
42
42
|
retry: RETRY_CONF,
|
package/lib/parse-github-url.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export default function parseGitHubUrl(repositoryUrl) {
|
|
2
2
|
const [match, auth, host, path] =
|
|
3
3
|
/^(?!.+:\/\/)(?:(?<auth>.*)@)?(?<host>.*?):(?<path>.*)$/.exec(
|
|
4
|
-
repositoryUrl
|
|
4
|
+
repositoryUrl,
|
|
5
5
|
) || [];
|
|
6
6
|
try {
|
|
7
7
|
const [, owner, repo] =
|
|
@@ -9,8 +9,8 @@ export default function parseGitHubUrl(repositoryUrl) {
|
|
|
9
9
|
new URL(
|
|
10
10
|
match
|
|
11
11
|
? `ssh://${auth ? `${auth}@` : ""}${host}/${path}`
|
|
12
|
-
: repositoryUrl
|
|
13
|
-
).pathname
|
|
12
|
+
: repositoryUrl,
|
|
13
|
+
).pathname,
|
|
14
14
|
);
|
|
15
15
|
return { owner, repo };
|
|
16
16
|
} catch {
|
package/lib/publish.js
CHANGED
|
@@ -37,7 +37,7 @@ export default async function publish(pluginConfig, context, { Octokit }) {
|
|
|
37
37
|
githubUrl,
|
|
38
38
|
githubApiPathPrefix,
|
|
39
39
|
proxy,
|
|
40
|
-
})
|
|
40
|
+
}),
|
|
41
41
|
);
|
|
42
42
|
const release = {
|
|
43
43
|
owner,
|
|
@@ -61,7 +61,7 @@ export default async function publish(pluginConfig, context, { Octokit }) {
|
|
|
61
61
|
data: { html_url: url, id: releaseId },
|
|
62
62
|
} = await octokit.request(
|
|
63
63
|
"POST /repos/{owner}/{repo}/releases",
|
|
64
|
-
draftReleaseOptions
|
|
64
|
+
draftReleaseOptions,
|
|
65
65
|
);
|
|
66
66
|
|
|
67
67
|
logger.log("Created GitHub draft release: %s", url);
|
|
@@ -82,7 +82,7 @@ export default async function publish(pluginConfig, context, { Octokit }) {
|
|
|
82
82
|
data: { upload_url: uploadUrl, html_url: draftUrl, id: releaseId },
|
|
83
83
|
} = await octokit.request(
|
|
84
84
|
"POST /repos/{owner}/{repo}/releases",
|
|
85
|
-
draftReleaseOptions
|
|
85
|
+
draftReleaseOptions,
|
|
86
86
|
);
|
|
87
87
|
|
|
88
88
|
// Append assets to the release
|
|
@@ -99,7 +99,7 @@ export default async function publish(pluginConfig, context, { Octokit }) {
|
|
|
99
99
|
} catch {
|
|
100
100
|
logger.error(
|
|
101
101
|
"The asset %s cannot be read, and will be ignored.",
|
|
102
|
-
filePath
|
|
102
|
+
filePath,
|
|
103
103
|
);
|
|
104
104
|
return;
|
|
105
105
|
}
|
|
@@ -107,7 +107,7 @@ export default async function publish(pluginConfig, context, { Octokit }) {
|
|
|
107
107
|
if (!file || !file.isFile()) {
|
|
108
108
|
logger.error(
|
|
109
109
|
"The asset %s is not a file, and will be ignored.",
|
|
110
|
-
filePath
|
|
110
|
+
filePath,
|
|
111
111
|
);
|
|
112
112
|
return;
|
|
113
113
|
}
|
|
@@ -135,7 +135,7 @@ export default async function publish(pluginConfig, context, { Octokit }) {
|
|
|
135
135
|
data: { browser_download_url: downloadUrl },
|
|
136
136
|
} = await octokit.request(upload);
|
|
137
137
|
logger.log("Published file %s", downloadUrl);
|
|
138
|
-
})
|
|
138
|
+
}),
|
|
139
139
|
);
|
|
140
140
|
|
|
141
141
|
// If we want to create a draft we don't need to update the release again
|
|
@@ -153,7 +153,7 @@ export default async function publish(pluginConfig, context, { Octokit }) {
|
|
|
153
153
|
repo,
|
|
154
154
|
release_id: releaseId,
|
|
155
155
|
draft: false,
|
|
156
|
-
}
|
|
156
|
+
},
|
|
157
157
|
);
|
|
158
158
|
|
|
159
159
|
logger.log("Published GitHub release: %s", url);
|
package/lib/resolve-config.js
CHANGED
package/lib/success.js
CHANGED
|
@@ -36,13 +36,13 @@ export default async function success(pluginConfig, context, { Octokit }) {
|
|
|
36
36
|
} = resolveConfig(pluginConfig, context);
|
|
37
37
|
|
|
38
38
|
const octokit = new Octokit(
|
|
39
|
-
toOctokitOptions({ githubToken, githubUrl, githubApiPathPrefix, proxy })
|
|
39
|
+
toOctokitOptions({ githubToken, githubUrl, githubApiPathPrefix, proxy }),
|
|
40
40
|
);
|
|
41
41
|
|
|
42
42
|
// In case the repo changed name, get the new `repo`/`owner` as the search API will not follow redirects
|
|
43
43
|
const { data: repoData } = await octokit.request(
|
|
44
44
|
"GET /repos/{owner}/{repo}",
|
|
45
|
-
parseGithubUrl(repositoryUrl)
|
|
45
|
+
parseGithubUrl(repositoryUrl),
|
|
46
46
|
);
|
|
47
47
|
const [owner, repo] = repoData.full_name.split("/");
|
|
48
48
|
|
|
@@ -53,23 +53,23 @@ export default async function success(pluginConfig, context, { Octokit }) {
|
|
|
53
53
|
} else {
|
|
54
54
|
const parser = issueParser(
|
|
55
55
|
"github",
|
|
56
|
-
githubUrl ? { hosts: [githubUrl] } : {}
|
|
56
|
+
githubUrl ? { hosts: [githubUrl] } : {},
|
|
57
57
|
);
|
|
58
58
|
const releaseInfos = releases.filter((release) => Boolean(release.name));
|
|
59
59
|
const shas = commits.map(({ hash }) => hash);
|
|
60
60
|
|
|
61
61
|
const searchQueries = getSearchQueries(
|
|
62
62
|
`repo:${owner}/${repo}+type:pr+is:merged`,
|
|
63
|
-
shas
|
|
63
|
+
shas,
|
|
64
64
|
).map(
|
|
65
65
|
async (q) =>
|
|
66
|
-
(await octokit.request("GET /search/issues", { q })).data.items
|
|
66
|
+
(await octokit.request("GET /search/issues", { q })).data.items,
|
|
67
67
|
);
|
|
68
68
|
|
|
69
69
|
const searchQueriesResults = await Promise.all(searchQueries);
|
|
70
70
|
const uniqueSearchQueriesResults = uniqBy(
|
|
71
71
|
flatten(searchQueriesResults),
|
|
72
|
-
"number"
|
|
72
|
+
"number",
|
|
73
73
|
);
|
|
74
74
|
const prs = await pFilter(
|
|
75
75
|
uniqueSearchQueriesResults,
|
|
@@ -80,7 +80,7 @@ export default async function success(pluginConfig, context, { Octokit }) {
|
|
|
80
80
|
owner,
|
|
81
81
|
repo,
|
|
82
82
|
pull_number: number,
|
|
83
|
-
}
|
|
83
|
+
},
|
|
84
84
|
);
|
|
85
85
|
const matchingCommit = commits.find(({ sha }) => shas.includes(sha));
|
|
86
86
|
if (matchingCommit) return matchingCommit;
|
|
@@ -91,15 +91,15 @@ export default async function success(pluginConfig, context, { Octokit }) {
|
|
|
91
91
|
owner,
|
|
92
92
|
repo,
|
|
93
93
|
pull_number: number,
|
|
94
|
-
}
|
|
94
|
+
},
|
|
95
95
|
);
|
|
96
96
|
return shas.includes(pullRequest.merge_commit_sha);
|
|
97
|
-
}
|
|
97
|
+
},
|
|
98
98
|
);
|
|
99
99
|
|
|
100
100
|
debug(
|
|
101
101
|
"found pull requests: %O",
|
|
102
|
-
prs.map((pr) => pr.number)
|
|
102
|
+
prs.map((pr) => pr.number),
|
|
103
103
|
);
|
|
104
104
|
|
|
105
105
|
// Parse the release commits message and PRs body to find resolved issues/PRs via comment keyworkds
|
|
@@ -113,14 +113,14 @@ export default async function success(pluginConfig, context, { Octokit }) {
|
|
|
113
113
|
parser(message)
|
|
114
114
|
.actions.close.filter(
|
|
115
115
|
(action) =>
|
|
116
|
-
isNil(action.slug) || action.slug === `${owner}/${repo}
|
|
116
|
+
isNil(action.slug) || action.slug === `${owner}/${repo}`,
|
|
117
117
|
)
|
|
118
118
|
.map((action) => ({
|
|
119
119
|
number: Number.parseInt(action.issue, 10),
|
|
120
|
-
}))
|
|
120
|
+
})),
|
|
121
121
|
)
|
|
122
122
|
: issues,
|
|
123
|
-
[]
|
|
123
|
+
[],
|
|
124
124
|
);
|
|
125
125
|
|
|
126
126
|
debug("found issues via comments: %O", issues);
|
|
@@ -137,13 +137,13 @@ export default async function success(pluginConfig, context, { Octokit }) {
|
|
|
137
137
|
data: { html_url: url },
|
|
138
138
|
} = await octokit.request(
|
|
139
139
|
"POST /repos/{owner}/{repo}/issues/{issue_number}/comments",
|
|
140
|
-
comment
|
|
140
|
+
comment,
|
|
141
141
|
);
|
|
142
142
|
logger.log("Added comment to issue #%d: %s", issue.number, url);
|
|
143
143
|
|
|
144
144
|
if (releasedLabels) {
|
|
145
145
|
const labels = releasedLabels.map((label) =>
|
|
146
|
-
template(label)(context)
|
|
146
|
+
template(label)(context),
|
|
147
147
|
);
|
|
148
148
|
await octokit.request(
|
|
149
149
|
"POST /repos/{owner}/{repo}/issues/{issue_number}/labels",
|
|
@@ -152,7 +152,7 @@ export default async function success(pluginConfig, context, { Octokit }) {
|
|
|
152
152
|
repo,
|
|
153
153
|
issue_number: issue.number,
|
|
154
154
|
data: labels,
|
|
155
|
-
}
|
|
155
|
+
},
|
|
156
156
|
);
|
|
157
157
|
logger.log("Added labels %O to issue #%d", labels, issue.number);
|
|
158
158
|
}
|
|
@@ -160,23 +160,23 @@ export default async function success(pluginConfig, context, { Octokit }) {
|
|
|
160
160
|
if (error.status === 403) {
|
|
161
161
|
logger.error(
|
|
162
162
|
"Not allowed to add a comment to the issue #%d.",
|
|
163
|
-
issue.number
|
|
163
|
+
issue.number,
|
|
164
164
|
);
|
|
165
165
|
} else if (error.status === 404) {
|
|
166
166
|
logger.error(
|
|
167
167
|
"Failed to add a comment to the issue #%d as it doesn't exist.",
|
|
168
|
-
issue.number
|
|
168
|
+
issue.number,
|
|
169
169
|
);
|
|
170
170
|
} else {
|
|
171
171
|
errors.push(error);
|
|
172
172
|
logger.error(
|
|
173
173
|
"Failed to add a comment to the issue #%d.",
|
|
174
|
-
issue.number
|
|
174
|
+
issue.number,
|
|
175
175
|
);
|
|
176
176
|
// Don't throw right away and continue to update other issues
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
|
-
})
|
|
179
|
+
}),
|
|
180
180
|
);
|
|
181
181
|
}
|
|
182
182
|
|
|
@@ -202,7 +202,7 @@ export default async function success(pluginConfig, context, { Octokit }) {
|
|
|
202
202
|
data: { html_url: url },
|
|
203
203
|
} = await octokit.request(
|
|
204
204
|
"PATCH /repos/{owner}/{repo}/issues/{issue_number}",
|
|
205
|
-
updateIssue
|
|
205
|
+
updateIssue,
|
|
206
206
|
);
|
|
207
207
|
logger.log("Closed issue #%d: %s.", issue.number, url);
|
|
208
208
|
} catch (error) {
|
|
@@ -210,13 +210,13 @@ export default async function success(pluginConfig, context, { Octokit }) {
|
|
|
210
210
|
logger.error("Failed to close the issue #%d.", issue.number);
|
|
211
211
|
// Don't throw right away and continue to close other issues
|
|
212
212
|
}
|
|
213
|
-
})
|
|
213
|
+
}),
|
|
214
214
|
);
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
if (addReleases !== false && errors.length === 0) {
|
|
218
218
|
const ghRelease = releases.find(
|
|
219
|
-
(release) => release.name && release.name === RELEASE_NAME
|
|
219
|
+
(release) => release.name && release.name === RELEASE_NAME,
|
|
220
220
|
);
|
|
221
221
|
if (!isNil(ghRelease)) {
|
|
222
222
|
const ghRelaseId = ghRelease.id;
|
|
@@ -233,7 +233,7 @@ export default async function success(pluginConfig, context, { Octokit }) {
|
|
|
233
233
|
repo,
|
|
234
234
|
release_id: ghRelaseId,
|
|
235
235
|
body: newBody,
|
|
236
|
-
}
|
|
236
|
+
},
|
|
237
237
|
);
|
|
238
238
|
}
|
|
239
239
|
}
|
package/lib/verify.js
CHANGED
|
@@ -30,12 +30,12 @@ const VALIDATORS = {
|
|
|
30
30
|
isNonEmptyString(proxy) ||
|
|
31
31
|
(isPlainObject(proxy) &&
|
|
32
32
|
isNonEmptyString(proxy.host) &&
|
|
33
|
-
isNumber(proxy.port))
|
|
33
|
+
isNumber(proxy.port)),
|
|
34
34
|
),
|
|
35
35
|
assets: isArrayOf(
|
|
36
36
|
(asset) =>
|
|
37
37
|
isStringOrStringArray(asset) ||
|
|
38
|
-
(isPlainObject(asset) && isStringOrStringArray(asset.path))
|
|
38
|
+
(isPlainObject(asset) && isStringOrStringArray(asset.path)),
|
|
39
39
|
),
|
|
40
40
|
successComment: canBeDisabled(isNonEmptyString),
|
|
41
41
|
failTitle: canBeDisabled(isNonEmptyString),
|
|
@@ -64,13 +64,13 @@ export default async function verify(pluginConfig, context, { Octokit }) {
|
|
|
64
64
|
getError(`EINVALID${option.toUpperCase()}`, { [option]: value }),
|
|
65
65
|
]
|
|
66
66
|
: errors,
|
|
67
|
-
[]
|
|
67
|
+
[],
|
|
68
68
|
);
|
|
69
69
|
|
|
70
70
|
if (githubUrl) {
|
|
71
71
|
logger.log(
|
|
72
72
|
"Verify GitHub authentication (%s)",
|
|
73
|
-
urlJoin(githubUrl, githubApiPathPrefix)
|
|
73
|
+
urlJoin(githubUrl, githubApiPathPrefix),
|
|
74
74
|
);
|
|
75
75
|
} else {
|
|
76
76
|
logger.log("Verify GitHub authentication");
|
|
@@ -84,7 +84,7 @@ export default async function verify(pluginConfig, context, { Octokit }) {
|
|
|
84
84
|
!errors.find(({ code }) => code === "EINVALIDPROXY")
|
|
85
85
|
) {
|
|
86
86
|
const octokit = new Octokit(
|
|
87
|
-
toOctokitOptions({ githubToken, githubUrl, githubApiPathPrefix, proxy })
|
|
87
|
+
toOctokitOptions({ githubToken, githubUrl, githubApiPathPrefix, proxy }),
|
|
88
88
|
);
|
|
89
89
|
|
|
90
90
|
// https://github.com/semantic-release/github/issues/182
|
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.0.4",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Pierre Vanduynslager (https://twitter.com/@pvdlg_)",
|
|
7
7
|
"ava": {
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
"Gregor Martynus (https://twitter.com/gr2m)"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@octokit/core": "^
|
|
24
|
-
"@octokit/plugin-paginate-rest": "^
|
|
25
|
-
"@octokit/plugin-retry": "^
|
|
26
|
-
"@octokit/plugin-throttling": "^
|
|
27
|
-
"@semantic-release/error": "^
|
|
23
|
+
"@octokit/core": "^5.0.0",
|
|
24
|
+
"@octokit/plugin-paginate-rest": "^8.0.0",
|
|
25
|
+
"@octokit/plugin-retry": "^6.0.0",
|
|
26
|
+
"@octokit/plugin-throttling": "^7.0.0",
|
|
27
|
+
"@semantic-release/error": "^4.0.0",
|
|
28
28
|
"aggregate-error": "^4.0.1",
|
|
29
29
|
"debug": "^4.3.4",
|
|
30
30
|
"dir-glob": "^3.0.1",
|
|
@@ -38,14 +38,14 @@
|
|
|
38
38
|
"url-join": "^5.0.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"ava": "5.3.
|
|
42
|
-
"c8": "
|
|
41
|
+
"ava": "5.3.1",
|
|
42
|
+
"c8": "8.0.0",
|
|
43
43
|
"cpy": "10.1.0",
|
|
44
44
|
"fetch-mock": "npm:@gr2m/fetch-mock@9.11.0-pull-request-644.1",
|
|
45
|
-
"prettier": "
|
|
46
|
-
"semantic-release": "21.0.
|
|
47
|
-
"sinon": "15.
|
|
48
|
-
"tempy": "3.
|
|
45
|
+
"prettier": "3.0.0",
|
|
46
|
+
"semantic-release": "21.0.7",
|
|
47
|
+
"sinon": "15.2.0",
|
|
48
|
+
"tempy": "3.1.0"
|
|
49
49
|
},
|
|
50
50
|
"engines": {
|
|
51
51
|
"node": ">=18"
|