semantic-release 25.0.4 → 25.0.6

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.
Files changed (63) hide show
  1. package/README.md +36 -37
  2. package/bin/semantic-release.js +1 -1
  3. package/index.js +265 -37
  4. package/lib/branches/expand.js +18 -0
  5. package/lib/branches/get-tags.js +39 -0
  6. package/lib/branches/index.js +71 -0
  7. package/lib/branches/normalize.js +104 -0
  8. package/lib/definitions/branches.js +22 -0
  9. package/lib/definitions/constants.js +8 -9
  10. package/lib/definitions/errors.js +303 -0
  11. package/lib/definitions/plugins.js +108 -0
  12. package/lib/get-commits.js +31 -0
  13. package/lib/get-config.js +98 -0
  14. package/lib/get-error.js +7 -0
  15. package/lib/get-git-auth-url.js +126 -0
  16. package/lib/get-last-release.js +48 -0
  17. package/lib/get-logger.js +19 -0
  18. package/lib/get-next-version.js +35 -0
  19. package/lib/get-release-to-add.js +59 -0
  20. package/lib/git.js +381 -0
  21. package/lib/hide-sensitive.js +14 -1
  22. package/lib/plugins/index.js +103 -0
  23. package/lib/plugins/normalize.js +69 -0
  24. package/lib/plugins/pipeline.js +59 -0
  25. package/lib/plugins/utils.js +81 -0
  26. package/lib/utils.js +101 -0
  27. package/lib/verify.js +43 -0
  28. package/package.json +20 -15
  29. package/docs/README.md +0 -7
  30. package/docs/developer-guide/README.md +0 -5
  31. package/docs/developer-guide/js-api.md +0 -294
  32. package/docs/developer-guide/plugin.md +0 -284
  33. package/docs/developer-guide/shareable-configuration.md +0 -1
  34. package/docs/extending/README.md +0 -4
  35. package/docs/extending/plugins-list.md +0 -233
  36. package/docs/extending/shareable-configurations-list.md +0 -22
  37. package/docs/recipes/ci-configurations/README.md +0 -7
  38. package/docs/recipes/ci-configurations/circleci-workflows.md +0 -49
  39. package/docs/recipes/ci-configurations/github-actions.md +0 -136
  40. package/docs/recipes/ci-configurations/gitlab-ci.md +0 -98
  41. package/docs/recipes/ci-configurations/jenkins-ci.md +0 -61
  42. package/docs/recipes/ci-configurations/travis.md +0 -97
  43. package/docs/recipes/git-hosted-services/README.md +0 -3
  44. package/docs/recipes/git-hosted-services/git-auth-ssh-keys.md +0 -166
  45. package/docs/recipes/release-workflow/README.md +0 -5
  46. package/docs/recipes/release-workflow/distribution-channels.md +0 -117
  47. package/docs/recipes/release-workflow/maintenance-releases.md +0 -157
  48. package/docs/recipes/release-workflow/pre-releases.md +0 -197
  49. package/docs/support/FAQ.md +0 -253
  50. package/docs/support/README.md +0 -7
  51. package/docs/support/git-version.md +0 -4
  52. package/docs/support/node-support-policy.md +0 -21
  53. package/docs/support/node-version.md +0 -38
  54. package/docs/support/resources.md +0 -22
  55. package/docs/support/troubleshooting.md +0 -70
  56. package/docs/usage/README.md +0 -9
  57. package/docs/usage/ci-configuration.md +0 -50
  58. package/docs/usage/configuration.md +0 -206
  59. package/docs/usage/getting-started.md +0 -8
  60. package/docs/usage/installation.md +0 -51
  61. package/docs/usage/plugins.md +0 -105
  62. package/docs/usage/shareable-configurations.md +0 -7
  63. package/docs/usage/workflow-configuration.md +0 -199
@@ -0,0 +1,104 @@
1
+ import { isNil, sortBy } from "lodash-es";
2
+ import { FIRST_RELEASE, RELEASE_TYPE } from "../definitions/constants.js";
3
+ import {
4
+ getFirstVersion,
5
+ getLatestVersion,
6
+ getLowerBound,
7
+ getRange,
8
+ getUpperBound,
9
+ getVersionDiff,
10
+ highest,
11
+ isMajorRange,
12
+ lowest,
13
+ tagsToVersions,
14
+ } from "../utils.js";
15
+
16
+ export function maintenance({ maintenance, release }) {
17
+ return sortBy(
18
+ maintenance.map(({ name, range, channel, ...rest }) => ({
19
+ ...rest,
20
+ name,
21
+ range: range || name,
22
+ channel: isNil(channel) ? name : channel,
23
+ })),
24
+ "range"
25
+ ).map(({ name, range, tags, ...rest }, idx, branches) => {
26
+ const versions = tagsToVersions(tags);
27
+ // Find the lower bound based on Maintenance branches
28
+ const maintenanceMin =
29
+ // If the current branch has a major range (1.x or 1.x.x) and the previous doesn't
30
+ isMajorRange(range) && branches[idx - 1] && !isMajorRange(branches[idx - 1].range)
31
+ ? // Then the lowest bound is the upper bound of the previous branch range
32
+ getUpperBound(branches[idx - 1].range)
33
+ : // Otherwise the lowest bound is the lowest bound of the current branch range
34
+ getLowerBound(range);
35
+ // The actual lower bound is the highest version between the current branch last release and `maintenanceMin`
36
+ const min = highest(getLatestVersion(versions) || FIRST_RELEASE, maintenanceMin);
37
+ // Determine the first release of the default branch not present in any maintenance branch
38
+ const base =
39
+ (release[0] &&
40
+ (getFirstVersion(tagsToVersions(release[0].tags), branches) ||
41
+ getLatestVersion(tagsToVersions(release[0].tags)))) ||
42
+ FIRST_RELEASE;
43
+ // The upper bound is the lowest version between the `base` version and the upper bound of the current branch range
44
+ const max = lowest(base, getUpperBound(range));
45
+ const diff = getVersionDiff(min, max);
46
+ return {
47
+ ...rest,
48
+ type: "maintenance",
49
+ name,
50
+ tags,
51
+ range: getRange(min, max),
52
+ accept: diff ? RELEASE_TYPE.slice(0, RELEASE_TYPE.indexOf(diff)) : [],
53
+ mergeRange: getRange(maintenanceMin, getUpperBound(range)),
54
+ };
55
+ });
56
+ }
57
+
58
+ export function release({ release }) {
59
+ if (release.length === 0) {
60
+ return release;
61
+ }
62
+
63
+ // The initial lastVersion is the last release from the base branch of `FIRST_RELEASE` (1.0.0)
64
+ let lastVersion = getLatestVersion(tagsToVersions(release[0].tags)) || FIRST_RELEASE;
65
+
66
+ return release.map(({ name, tags, channel, ...rest }, idx) => {
67
+ const versions = tagsToVersions(tags);
68
+ // The new lastVersion is the highest version between the current branch last release and the previous branch lastVersion
69
+ lastVersion = highest(getLatestVersion(versions), lastVersion);
70
+ // The upper bound is:
71
+ // - None if the current branch is the last one of the release branches
72
+ // - Otherwise, The upper bound is the lowest version that is present on the current branch but none of the previous ones
73
+ const bound =
74
+ release.length - 1 === idx
75
+ ? undefined
76
+ : getFirstVersion(tagsToVersions(release[idx + 1].tags), release.slice(0, idx + 1));
77
+
78
+ const diff = bound ? getVersionDiff(lastVersion, bound) : null;
79
+ return {
80
+ ...rest,
81
+ channel: idx === 0 ? channel : isNil(channel) ? name : channel,
82
+ tags,
83
+ type: "release",
84
+ name,
85
+ range: getRange(lastVersion, bound),
86
+ accept: bound ? RELEASE_TYPE.slice(0, RELEASE_TYPE.indexOf(diff)) : RELEASE_TYPE,
87
+ main: idx === 0,
88
+ };
89
+ });
90
+ }
91
+
92
+ export function prerelease({ prerelease }) {
93
+ return prerelease.map(({ name, prerelease, channel, tags, ...rest }) => {
94
+ const preid = prerelease === true ? name : prerelease;
95
+ return {
96
+ ...rest,
97
+ channel: isNil(channel) ? name : channel,
98
+ type: "prerelease",
99
+ name,
100
+ prerelease: preid,
101
+ tags,
102
+ };
103
+ });
104
+ }
@@ -0,0 +1,22 @@
1
+ import { isNil, uniqBy } from "lodash-es";
2
+ import semver from "semver";
3
+ import { isMaintenanceRange } from "../utils.js";
4
+
5
+ export const maintenance = {
6
+ filter: ({ name, range }) => (!isNil(range) && range !== false) || isMaintenanceRange(name),
7
+ branchValidator: ({ range }) => (isNil(range) ? true : isMaintenanceRange(range)),
8
+ branchesValidator: (branches) => uniqBy(branches, ({ range }) => semver.validRange(range)).length === branches.length,
9
+ };
10
+
11
+ export const prerelease = {
12
+ filter: ({ prerelease }) => !isNil(prerelease) && prerelease !== false,
13
+ branchValidator: ({ name, prerelease }) =>
14
+ Boolean(prerelease) && Boolean(semver.valid(`1.0.0-${prerelease === true ? name : prerelease}.1`)),
15
+ branchesValidator: (branches) => uniqBy(branches, "prerelease").length === branches.length,
16
+ };
17
+
18
+ export const release = {
19
+ // eslint-disable-next-line unicorn/no-fn-reference-in-iterator
20
+ filter: (branch) => !maintenance.filter(branch) && !prerelease.filter(branch),
21
+ branchesValidator: (branches) => branches.length <= 3 && branches.length > 0,
22
+ };
@@ -1,18 +1,17 @@
1
+ export const RELEASE_TYPE = ["patch", "minor", "major"];
2
+
3
+ export const FIRST_RELEASE = "1.0.0";
4
+
5
+ export const FIRSTPRERELEASE = "1";
6
+
1
7
  export const COMMIT_NAME = "semantic-release-bot";
2
8
 
3
9
  export const COMMIT_EMAIL = "semantic-release-bot@martynus.net";
4
10
 
11
+ export const RELEASE_NOTES_SEPARATOR = "\n\n";
12
+
5
13
  export const SECRET_REPLACEMENT = "[secure]";
6
14
 
7
15
  export const SECRET_MIN_SIZE = 5;
8
16
 
9
17
  export const GIT_NOTE_REF = "semantic-release";
10
-
11
- export const SEMANTIC_RELEASE_DEFAULT_CONFIG = {
12
- plugins: [
13
- "@semantic-release/commit-analyzer",
14
- "@semantic-release/release-notes-generator",
15
- "@semantic-release/npm",
16
- "@semantic-release/github",
17
- ],
18
- };
@@ -0,0 +1,303 @@
1
+ import { inspect } from "node:util";
2
+ import { isString, toLower, trim } from "lodash-es";
3
+ import { RELEASE_TYPE } from "./constants.js";
4
+
5
+ import pkg from "../../package.json" with { type: "json" };
6
+
7
+ const DOCS_URL = "https://semantic-release.org";
8
+
9
+ const stringify = (object) =>
10
+ isString(object) ? object : inspect(object, { breakLength: Infinity, depth: 2, maxArrayLength: 5 });
11
+
12
+ const linkify = (file) => {
13
+ const [path, hash] = file.split("#");
14
+
15
+ return `${DOCS_URL}/${path.replace(/\.md$/u, "")}${hash ? `#${hash}` : ""}`;
16
+ };
17
+
18
+ const wordsList = (words) =>
19
+ `${words.slice(0, -1).join(", ")}${words.length > 1 ? ` or ${words[words.length - 1]}` : trim(words[0])}`;
20
+
21
+ export function ENOGITREPO({ cwd }) {
22
+ return {
23
+ message: "Not running from a git repository.",
24
+ details: `The \`semantic-release\` command must be executed from a Git repository.
25
+
26
+ The current working directory is \`${cwd}\`.
27
+
28
+ Please verify your CI configuration to make sure the \`semantic-release\` command is executed from the root of the cloned repository.`,
29
+ };
30
+ }
31
+
32
+ export function ENOREPOURL() {
33
+ return {
34
+ message: "The `repositoryUrl` option is required.",
35
+ details: `The [repositoryUrl option](${linkify(
36
+ "usage/configuration#repositoryurl"
37
+ )}) cannot be determined from the semantic-release configuration, the \`package.json\` nor the [git origin url](https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes).
38
+
39
+ Please make sure to add the \`repositoryUrl\` to the [semantic-release configuration](${linkify(
40
+ "usage/configuration#repositoryurl"
41
+ )}).`,
42
+ };
43
+ }
44
+
45
+ export function EGITNOPERMISSION({ options: { repositoryUrl }, branch: { name } }) {
46
+ return {
47
+ message: "Cannot push to the Git repository.",
48
+ details: `**semantic-release** cannot push the version tag to the branch \`${name}\` on the remote Git repository with URL \`${repositoryUrl}\`.
49
+
50
+ This can be caused by:
51
+ - a misconfiguration of the [repositoryUrl](${linkify("usage/configuration#repositoryurl")}) option
52
+ - the repository being unavailable
53
+ - or missing push permission for the user configured via the [Git credentials on your CI environment](${linkify(
54
+ "usage/ci-configuration#authentication"
55
+ )})`,
56
+ };
57
+ }
58
+
59
+ export function EINVALIDTAGFORMAT({ options: { tagFormat } }) {
60
+ return {
61
+ message: "Invalid `tagFormat` option.",
62
+ details: `The [tagFormat](${linkify(
63
+ "usage/configuration#tagformat"
64
+ )}) must compile to a [valid Git reference](https://git-scm.com/docs/git-check-ref-format#_description).
65
+
66
+ Your configuration for the \`tagFormat\` option is \`${stringify(tagFormat)}\`.`,
67
+ };
68
+ }
69
+
70
+ export function ETAGNOVERSION({ options: { tagFormat } }) {
71
+ return {
72
+ message: "Invalid `tagFormat` option.",
73
+ details: `The [tagFormat](${linkify(
74
+ "usage/configuration#tagformat"
75
+ )}) option must contain the variable \`version\` exactly once.
76
+
77
+ Your configuration for the \`tagFormat\` option is \`${stringify(tagFormat)}\`.`,
78
+ };
79
+ }
80
+
81
+ export function EPLUGINCONF({ type, required, pluginConf }) {
82
+ return {
83
+ message: `The \`${type}\` plugin configuration is invalid.`,
84
+ details: `The [${type} plugin configuration](${linkify(`foundation/plugins#${toLower(type)}-plugin`)}) ${
85
+ required ? "is required and " : ""
86
+ } must be a single or an array of plugins definition. A plugin definition is an npm module name, optionally wrapped in an array with an object.
87
+
88
+ Your configuration for the \`${type}\` plugin is \`${stringify(pluginConf)}\`.`,
89
+ };
90
+ }
91
+
92
+ export function EPLUGINSCONF({ plugin }) {
93
+ return {
94
+ message: "The `plugins` configuration is invalid.",
95
+ details: `The [plugins](${linkify(
96
+ "usage/configuration#plugins"
97
+ )}) option must be an array of plugin definitions. A plugin definition is an npm module name, optionally wrapped in an array with an object.
98
+
99
+ The invalid configuration is \`${stringify(plugin)}\`.`,
100
+ };
101
+ }
102
+
103
+ export function EPLUGIN({ pluginName, type }) {
104
+ return {
105
+ message: `A plugin configured in the step ${type} is not a valid semantic-release plugin.`,
106
+ details: `A valid \`${type}\` **semantic-release** plugin must be a function or an object with a function in the property \`${type}\`.
107
+
108
+ The plugin \`${pluginName}\` doesn't have the property \`${type}\` and cannot be used for the \`${type}\` step.
109
+
110
+ Please refer to the \`${pluginName}\` and [semantic-release plugins configuration](${linkify(
111
+ "foundation/plugins/#plugin-options-configuration"
112
+ )}) documentation for more details.`,
113
+ };
114
+ }
115
+
116
+ export function EANALYZECOMMITSOUTPUT({ result, pluginName }) {
117
+ return {
118
+ message: "The `analyzeCommits` plugin returned an invalid value. It must return a valid semver release type.",
119
+ details: `The \`analyzeCommits\` plugin must return a valid [semver](https://semver.org) release type. The valid values are: ${RELEASE_TYPE.map(
120
+ (type) => `\`${type}\``
121
+ ).join(", ")}.
122
+
123
+ The \`analyzeCommits\` function of the \`${pluginName}\` returned \`${stringify(result)}\` instead.
124
+
125
+ We recommend to report the issue to the \`${pluginName}\` authors, providing the following informations:
126
+ - The **semantic-release** version: \`${pkg.version}\`
127
+ - The **semantic-release** logs from your CI job
128
+ - The value returned by the plugin: \`${stringify(result)}\`
129
+ - A link to the **semantic-release** plugin developer guide: [${linkify("developer-guide/plugin")}](${linkify(
130
+ "developer-guide/plugin"
131
+ )})`,
132
+ };
133
+ }
134
+
135
+ export function EGENERATENOTESOUTPUT({ result, pluginName }) {
136
+ return {
137
+ message: "The `generateNotes` plugin returned an invalid value. It must return a `String`.",
138
+ details: `The \`generateNotes\` plugin must return a \`String\`.
139
+
140
+ The \`generateNotes\` function of the \`${pluginName}\` returned \`${stringify(result)}\` instead.
141
+
142
+ We recommend to report the issue to the \`${pluginName}\` authors, providing the following informations:
143
+ - The **semantic-release** version: \`${pkg.version}\`
144
+ - The **semantic-release** logs from your CI job
145
+ - The value returned by the plugin: \`${stringify(result)}\`
146
+ - A link to the **semantic-release** plugin developer guide: [${linkify("developer-guide/plugin")}](${linkify(
147
+ "developer-guide/plugin"
148
+ )})`,
149
+ };
150
+ }
151
+
152
+ export function EPUBLISHOUTPUT({ result, pluginName }) {
153
+ return {
154
+ message: "A `publish` plugin returned an invalid value. It must return an `Object`.",
155
+ details: `The \`publish\` plugins must return an \`Object\`.
156
+
157
+ The \`publish\` function of the \`${pluginName}\` returned \`${stringify(result)}\` instead.
158
+
159
+ We recommend to report the issue to the \`${pluginName}\` authors, providing the following informations:
160
+ - The **semantic-release** version: \`${pkg.version}\`
161
+ - The **semantic-release** logs from your CI job
162
+ - The value returned by the plugin: \`${stringify(result)}\`
163
+ - A link to the **semantic-release** plugin developer guide: [${linkify("developer-guide/plugin")}](${linkify(
164
+ "developer-guide/plugin"
165
+ )})`,
166
+ };
167
+ }
168
+
169
+ export function EADDCHANNELOUTPUT({ result, pluginName }) {
170
+ return {
171
+ message: "A `addChannel` plugin returned an invalid value. It must return an `Object`.",
172
+ details: `The \`addChannel\` plugins must return an \`Object\`.
173
+
174
+ The \`addChannel\` function of the \`${pluginName}\` returned \`${stringify(result)}\` instead.
175
+
176
+ We recommend to report the issue to the \`${pluginName}\` authors, providing the following informations:
177
+ - The **semantic-release** version: \`${pkg.version}\`
178
+ - The **semantic-release** logs from your CI job
179
+ - The value returned by the plugin: \`${stringify(result)}\`
180
+ - A link to the **semantic-release** plugin developer guide: [${linkify("developer-guide/plugin")}](${linkify(
181
+ "developer-guide/plugin"
182
+ )})`,
183
+ };
184
+ }
185
+
186
+ export function EINVALIDBRANCH({ branch }) {
187
+ return {
188
+ message: "A branch is invalid in the `branches` configuration.",
189
+ details: `Each branch in the [branches configuration](${linkify(
190
+ "usage/configuration#branches"
191
+ )}) must be either a string, a regexp or an object with a \`name\` property.
192
+
193
+ Your configuration for the problematic branch is \`${stringify(branch)}\`.`,
194
+ };
195
+ }
196
+
197
+ export function EINVALIDBRANCHNAME({ branch }) {
198
+ return {
199
+ message: "A branch name is invalid in the `branches` configuration.",
200
+ details: `Each branch in the [branches configuration](${linkify(
201
+ "usage/configuration#branches"
202
+ )}) must be a [valid Git reference](https://git-scm.com/docs/git-check-ref-format#_description).
203
+
204
+ Your configuration for the problematic branch is \`${stringify(branch)}\`.`,
205
+ };
206
+ }
207
+
208
+ export function EDUPLICATEBRANCHES({ duplicates }) {
209
+ return {
210
+ message: "The `branches` configuration has duplicate branches.",
211
+ details: `Each branch in the [branches configuration](${linkify(
212
+ "usage/configuration#branches"
213
+ )}) must havea unique name.
214
+
215
+ Your configuration contains duplicates for the following branch names: \`${stringify(duplicates)}\`.`,
216
+ };
217
+ }
218
+
219
+ export function EMAINTENANCEBRANCH({ branch }) {
220
+ return {
221
+ message: "A maintenance branch is invalid in the `branches` configuration.",
222
+ details: `Each maintenance branch in the [branches configuration](${linkify(
223
+ "usage/configuration#branches"
224
+ )}) must have a \`range\` property formatted like \`N.x\`, \`N.x.x\` or \`N.N.x\` (\`N\` is a number).
225
+
226
+ Your configuration for the problematic branch is \`${stringify(branch)}\`.`,
227
+ };
228
+ }
229
+
230
+ export function EMAINTENANCEBRANCHES({ branches }) {
231
+ return {
232
+ message: "The maintenance branches are invalid in the `branches` configuration.",
233
+ details: `Each maintenance branch in the [branches configuration](${linkify(
234
+ "usage/configuration#branches"
235
+ )}) must have a unique \`range\` property and must exist on the remote repository.
236
+
237
+ Your configuration for the problematic branches is \`${stringify(branches)}\`.`,
238
+ };
239
+ }
240
+
241
+ export function ERELEASEBRANCHES({ branches }) {
242
+ return {
243
+ message: "The release branches are invalid in the `branches` configuration.",
244
+ details: `A minimum of 1 and a maximum of 3 release branches are required in the [branches configuration](${linkify(
245
+ "usage/configuration#branches"
246
+ )}). These branches must exist on the remote repository.
247
+
248
+ This may occur if your repository does not have a release branch, such as \`master\` or \`main\`.
249
+
250
+ Your configuration for the problematic branches is \`${stringify(branches)}\`.`,
251
+ };
252
+ }
253
+
254
+ export function EPRERELEASEBRANCH({ branch }) {
255
+ return {
256
+ message: "A pre-release branch configuration is invalid in the `branches` configuration.",
257
+ details: `Each pre-release branch in the [branches configuration](${linkify(
258
+ "usage/configuration#branches"
259
+ )}) must have a \`prerelease\` property valid per the [Semantic Versioning Specification](https://semver.org/#spec-item-9). If the \`prerelease\` property is set to \`true\`, then the \`name\` property is used instead. Additionally, each pre-release branch must exist on the remote repository.
260
+
261
+ Your configuration for the problematic branch is \`${stringify(branch)}\`.`,
262
+ };
263
+ }
264
+
265
+ export function EPRERELEASEBRANCHES({ branches }) {
266
+ return {
267
+ message: "The pre-release branches are invalid in the `branches` configuration.",
268
+ details: `Each pre-release branch in the [branches configuration](${linkify(
269
+ "usage/configuration#branches"
270
+ )}) must have a unique \`prerelease\` property. If the \`prerelease\` property is set to \`true\`, then the \`name\` property is used instead.
271
+
272
+ Your configuration for the problematic branches is \`${stringify(branches)}\`.`,
273
+ };
274
+ }
275
+
276
+ export function EINVALIDNEXTVERSION({ nextRelease: { version }, branch: { name, range }, commits, validBranches }) {
277
+ return {
278
+ message: `The release \`${version}\` on branch \`${name}\` cannot be published as it is out of range.`,
279
+ details: `Based on the releases published on other branches, only versions within the range \`${range}\` can be published from branch \`${name}\`.
280
+
281
+ The following commit${commits.length > 1 ? "s are" : " is"} responsible for the invalid release:
282
+ ${commits.map(({ commit: { short }, subject }) => `- ${subject} (${short})`).join("\n")}
283
+
284
+ ${
285
+ commits.length > 1 ? "Those commits" : "This commit"
286
+ } should be moved to a valid branch with [git merge](https://git-scm.com/docs/git-merge) or [git cherry-pick](https://git-scm.com/docs/git-cherry-pick) and removed from branch \`${name}\` with [git revert](https://git-scm.com/docs/git-revert) or [git reset](https://git-scm.com/docs/git-reset).
287
+
288
+ A valid branch could be ${wordsList(validBranches.map(({ name }) => `\`${name}\``))}.
289
+
290
+ See the [workflow configuration documentation](${linkify("foundation/workflow-configuration")}) for more details.`,
291
+ };
292
+ }
293
+
294
+ export function EINVALIDMAINTENANCEMERGE({ nextRelease: { channel, gitTag, version }, branch: { mergeRange, name } }) {
295
+ return {
296
+ message: `The release \`${version}\` on branch \`${name}\` cannot be published as it is out of range.`,
297
+ details: `Only releases within the range \`${mergeRange}\` can be merged into the maintenance branch \`${name}\` and published to the \`${channel}\` distribution channel.
298
+
299
+ The branch \`${name}\` head should be [reset](https://git-scm.com/docs/git-reset) to a previous commit so the commit with tag \`${gitTag}\` is removed from the branch history.
300
+
301
+ See the [workflow configuration documentation](${linkify("foundation/workflow-configuration")}) for more details.`,
302
+ };
303
+ }
@@ -0,0 +1,108 @@
1
+ /* eslint require-atomic-updates: off */
2
+
3
+ import { isPlainObject, isString } from "lodash-es";
4
+ import { getGitHead } from "../git.js";
5
+ import hideSensitive from "../hide-sensitive.js";
6
+ import { hideSensitiveValues } from "../utils.js";
7
+ import { RELEASE_NOTES_SEPARATOR, RELEASE_TYPE } from "./constants.js";
8
+
9
+ export default {
10
+ verifyConditions: {
11
+ required: false,
12
+ dryRun: true,
13
+ pipelineConfig: () => ({ settleAll: true }),
14
+ },
15
+ analyzeCommits: {
16
+ default: ["@semantic-release/commit-analyzer"],
17
+ required: true,
18
+ dryRun: true,
19
+ outputValidator: (output) => !output || RELEASE_TYPE.includes(output),
20
+ preprocess: ({ commits, ...inputs }) => ({
21
+ ...inputs,
22
+ commits: commits.filter((commit) => !/\[skip\s+release]|\[release\s+skip]/i.test(commit.message)),
23
+ }),
24
+ postprocess: (results) =>
25
+ RELEASE_TYPE[
26
+ results.reduce((highest, result) => {
27
+ const typeIndex = RELEASE_TYPE.indexOf(result);
28
+ return typeIndex > highest ? typeIndex : highest;
29
+ }, -1)
30
+ ],
31
+ },
32
+ verifyRelease: {
33
+ required: false,
34
+ dryRun: true,
35
+ pipelineConfig: () => ({ settleAll: true }),
36
+ },
37
+ generateNotes: {
38
+ required: false,
39
+ dryRun: true,
40
+ outputValidator: (output) => !output || isString(output),
41
+ pipelineConfig: () => ({
42
+ getNextInput: ({ nextRelease, ...context }, notes) => ({
43
+ ...context,
44
+ nextRelease: {
45
+ ...nextRelease,
46
+ notes: `${nextRelease.notes ? `${nextRelease.notes}${RELEASE_NOTES_SEPARATOR}` : ""}${notes}`,
47
+ },
48
+ }),
49
+ }),
50
+ postprocess: (results, { env }) => hideSensitive(env)(results.filter(Boolean).join(RELEASE_NOTES_SEPARATOR)),
51
+ },
52
+ prepare: {
53
+ required: false,
54
+ dryRun: false,
55
+ pipelineConfig: ({ generateNotes }) => ({
56
+ getNextInput: async (context) => {
57
+ const newGitHead = await getGitHead({ cwd: context.cwd });
58
+ // If previous prepare plugin has created a commit (gitHead changed)
59
+ if (context.nextRelease.gitHead !== newGitHead) {
60
+ context.nextRelease.gitHead = newGitHead;
61
+ // Regenerate the release notes
62
+ context.nextRelease.notes = await generateNotes(context);
63
+ }
64
+
65
+ // Call the next prepare plugin with the updated `nextRelease`
66
+ return context;
67
+ },
68
+ }),
69
+ },
70
+ publish: {
71
+ required: false,
72
+ dryRun: false,
73
+ outputValidator: (output) => !output || isPlainObject(output),
74
+ pipelineConfig: () => ({
75
+ // Add `nextRelease` and plugin properties to published release
76
+ transform: (release, step, { nextRelease }) => ({
77
+ ...(release === false ? {} : nextRelease),
78
+ ...release,
79
+ ...step,
80
+ }),
81
+ }),
82
+ },
83
+ addChannel: {
84
+ required: false,
85
+ dryRun: false,
86
+ outputValidator: (output) => !output || isPlainObject(output),
87
+ pipelineConfig: () => ({
88
+ // Add `nextRelease` and plugin properties to published release
89
+ transform: (release, step, { nextRelease }) => ({
90
+ ...(release === false ? {} : nextRelease),
91
+ ...release,
92
+ ...step,
93
+ }),
94
+ }),
95
+ },
96
+ success: {
97
+ required: false,
98
+ dryRun: false,
99
+ pipelineConfig: () => ({ settleAll: true }),
100
+ preprocess: ({ releases, env, ...inputs }) => ({ ...inputs, env, releases: hideSensitiveValues(env, releases) }),
101
+ },
102
+ fail: {
103
+ required: false,
104
+ dryRun: false,
105
+ pipelineConfig: () => ({ settleAll: true }),
106
+ preprocess: ({ errors, env, ...inputs }) => ({ ...inputs, env, errors: hideSensitiveValues(env, errors) }),
107
+ },
108
+ };
@@ -0,0 +1,31 @@
1
+ import debugCommits from "debug";
2
+ import { getCommits } from "./git.js";
3
+
4
+ const debug = debugCommits("semantic-release:get-commits");
5
+
6
+ /**
7
+ * Retrieve the list of commits on the current branch since the commit sha associated with the last release, or all the commits of the current branch if there is no last released version.
8
+ *
9
+ * @param {Object} context semantic-release context.
10
+ *
11
+ * @return {Promise<Array<Object>>} The list of commits on the branch `branch` since the last release.
12
+ */
13
+ export default async ({
14
+ cwd,
15
+ env,
16
+ lastRelease: { gitHead: from },
17
+ nextRelease: { gitHead: to = "HEAD" } = {},
18
+ logger,
19
+ }) => {
20
+ if (from) {
21
+ debug("Use from: %s", from);
22
+ } else {
23
+ logger.log("No previous release found, retrieving all commits");
24
+ }
25
+
26
+ const commits = await getCommits(from, to, { cwd, env });
27
+
28
+ logger.log(`Found ${commits.length} commits since last release`);
29
+ debug("Parsed commits: %o", commits);
30
+ return commits;
31
+ };