semantic-release 25.0.5 → 25.0.7

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 (43) hide show
  1. package/README.md +36 -30
  2. package/bin/semantic-release.js +1 -1
  3. package/index.d.ts +3 -0
  4. package/lib/definitions/errors.js +53 -33
  5. package/lib/git.js +13 -11
  6. package/lib/hide-sensitive.js +14 -1
  7. package/lib/verify.js +4 -0
  8. package/package.json +20 -15
  9. package/docs/README.md +0 -7
  10. package/docs/developer-guide/README.md +0 -5
  11. package/docs/developer-guide/js-api.md +0 -294
  12. package/docs/developer-guide/plugin.md +0 -284
  13. package/docs/developer-guide/shareable-configuration.md +0 -1
  14. package/docs/extending/README.md +0 -4
  15. package/docs/extending/plugins-list.md +0 -233
  16. package/docs/extending/shareable-configurations-list.md +0 -22
  17. package/docs/recipes/ci-configurations/README.md +0 -7
  18. package/docs/recipes/ci-configurations/circleci-workflows.md +0 -49
  19. package/docs/recipes/ci-configurations/github-actions.md +0 -136
  20. package/docs/recipes/ci-configurations/gitlab-ci.md +0 -98
  21. package/docs/recipes/ci-configurations/jenkins-ci.md +0 -61
  22. package/docs/recipes/ci-configurations/travis.md +0 -97
  23. package/docs/recipes/git-hosted-services/README.md +0 -3
  24. package/docs/recipes/git-hosted-services/git-auth-ssh-keys.md +0 -166
  25. package/docs/recipes/release-workflow/README.md +0 -5
  26. package/docs/recipes/release-workflow/distribution-channels.md +0 -117
  27. package/docs/recipes/release-workflow/maintenance-releases.md +0 -157
  28. package/docs/recipes/release-workflow/pre-releases.md +0 -197
  29. package/docs/support/FAQ.md +0 -253
  30. package/docs/support/README.md +0 -7
  31. package/docs/support/git-version.md +0 -4
  32. package/docs/support/node-support-policy.md +0 -21
  33. package/docs/support/node-version.md +0 -38
  34. package/docs/support/resources.md +0 -22
  35. package/docs/support/troubleshooting.md +0 -70
  36. package/docs/usage/README.md +0 -9
  37. package/docs/usage/ci-configuration.md +0 -50
  38. package/docs/usage/configuration.md +0 -206
  39. package/docs/usage/getting-started.md +0 -8
  40. package/docs/usage/installation.md +0 -51
  41. package/docs/usage/plugins.md +0 -105
  42. package/docs/usage/shareable-configurations.md +0 -7
  43. package/docs/usage/workflow-configuration.md +0 -199
@@ -1,294 +0,0 @@
1
- # JavaScript API
2
-
3
- ## Usage
4
-
5
- ```js
6
- const semanticRelease = require("semantic-release");
7
- const { WritableStreamBuffer } = require("stream-buffers");
8
-
9
- const stdoutBuffer = new WritableStreamBuffer();
10
- const stderrBuffer = new WritableStreamBuffer();
11
-
12
- try {
13
- const result = await semanticRelease(
14
- {
15
- // Core options
16
- branches: [
17
- "+([0-9])?(.{+([0-9]),x}).x",
18
- "master",
19
- "main",
20
- "next",
21
- "next-major",
22
- { name: "beta", prerelease: true },
23
- { name: "alpha", prerelease: true },
24
- ],
25
- repositoryUrl: "https://github.com/me/my-package.git",
26
- // Shareable config
27
- extends: "my-shareable-config",
28
- // Plugin options
29
- githubUrl: "https://my-ghe.com",
30
- githubApiPathPrefix: "/api-prefix",
31
- },
32
- {
33
- // Run semantic-release from `/path/to/git/repo/root` without having to change local process `cwd` with `process.chdir()`
34
- cwd: "/path/to/git/repo/root",
35
- // Pass the variable `MY_ENV_VAR` to semantic-release without having to modify the local `process.env`
36
- env: { ...process.env, MY_ENV_VAR: "MY_ENV_VAR_VALUE" },
37
- // Store stdout and stderr to use later instead of writing to `process.stdout` and `process.stderr`
38
- stdout: stdoutBuffer,
39
- stderr: stderrBuffer,
40
- }
41
- );
42
-
43
- if (result) {
44
- const { lastRelease, commits, nextRelease, releases } = result;
45
-
46
- console.log(
47
- `Published ${nextRelease.type} release version ${nextRelease.version} containing ${commits.length} commits.`
48
- );
49
-
50
- if (lastRelease.version) {
51
- console.log(`The last release was "${lastRelease.version}".`);
52
- }
53
-
54
- for (const release of releases) {
55
- console.log(`The release was published with plugin "${release.pluginName}".`);
56
- }
57
- } else {
58
- console.log("No release published.");
59
- }
60
-
61
- // Get stdout and stderr content
62
- const logs = stdoutBuffer.getContentsAsString("utf8");
63
- const errors = stderrBuffer.getContentsAsString("utf8");
64
- } catch (err) {
65
- console.error("The automated release failed with %O", err);
66
- }
67
- ```
68
-
69
- ## API
70
-
71
- ### semanticRelease([options], [config]) => Promise<Result>
72
-
73
- Run **semantic-release** and returns a `Promise` that resolves to a [Result](#result) object.
74
-
75
- #### options
76
-
77
- Type: `Object`
78
-
79
- **semantic-release** options.
80
-
81
- Can be used to set any [core option](../usage/configuration.md#configuration) or [plugin options](../usage/plugins.md#configuration).
82
-
83
- Each option, will take precedence over options configured in the [configuration file](../usage/configuration.md#configuration) and [shareable configurations](../usage/configuration.md#extends).
84
-
85
- #### config
86
-
87
- Type: `Object`
88
-
89
- **semantic-release** configuration specific for API usage.
90
-
91
- ##### cwd
92
-
93
- Type: `String`<br>
94
- Default: `process.cwd()`
95
-
96
- The current working directory to use. It should be configured to the root of the Git repository to release from.
97
-
98
- It allows to run **semantic-release** from a specific path without having to change the local process `cwd` with `process.chdir()`.
99
-
100
- ##### env
101
-
102
- Type: `Object`<br>
103
- Default: `process.env`
104
-
105
- The environment variables to use.
106
-
107
- It allows to run **semantic-release** with specific environment variables without having to modify the local `process.env`.
108
-
109
- ##### stdout
110
-
111
- Type: [`stream.Writable`](https://nodejs.org/api/stream.html#stream_writable_streams)<br>
112
- Default: `process.stdout`
113
-
114
- The [writable stream](https://nodejs.org/api/stream.html#stream_writable_streams) used to log information.
115
-
116
- It allows to configure **semantic-release** to write logs to a specific stream rather than the local `process.stdout`.
117
-
118
- ##### stderr
119
-
120
- Type: [`stream.Writable`](https://nodejs.org/api/stream.html#stream_writable_streams)<br>
121
- Default: `process.stderr`
122
-
123
- The [writable stream](https://nodejs.org/api/stream.html#stream_writable_streams) used to log errors.
124
-
125
- It allows to configure **semantic-release** to write errors to a specific stream rather than the local `process.stderr`.
126
-
127
- ### Result
128
-
129
- Type: `Object` `Boolean`<br>
130
-
131
- An object with [`lastRelease`](#lastrelease), [`nextRelease`](#nextrelease), [`commits`](#commits) and [`releases`](#releases) if a release is published or `false` if no release was published.
132
-
133
- #### lastRelease
134
-
135
- Type: `Object`
136
-
137
- Information related to the last release found:
138
-
139
- | Name | Type | Description |
140
- | ------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------- |
141
- | version | `String` | The version of the last release. |
142
- | gitHead | `String` | The sha of the last commit being part of the last release. |
143
- | gitTag | `String` | The [Git tag](https://git-scm.com/book/en/v2/Git-Basics-Tagging) associated with the last release. |
144
- | channel | `String` | The distribution channel on which the last release was initially made available (`undefined` for the default distribution channel). |
145
-
146
- **Note**: If no previous release is found, `lastRelease` will be an empty `Object`.
147
-
148
- Example:
149
-
150
- ```js
151
- {
152
- gitHead: 'da39a3ee5e6b4b0d3255bfef95601890afd80709',
153
- version: '1.0.0',
154
- gitTag: 'v1.0.0',
155
- channel: 'next'
156
- }
157
- ```
158
-
159
- #### commits
160
-
161
- Type: `Array<Object>`
162
-
163
- The list of commit(s) included in the new release.<br>
164
- Each commit object has the following properties:
165
-
166
- | Name | Type | Description |
167
- | --------------- | -------- | ----------------------------------------------- |
168
- | commit | `Object` | The commit abbreviated and full hash. |
169
- | commit.long | `String` | The commit hash. |
170
- | commit.short | `String` | The commit abbreviated hash. |
171
- | tree | `Object` | The commit abbreviated and full tree hash. |
172
- | tree.long | `String` | The commit tree hash. |
173
- | tree.short | `String` | The commit abbreviated tree hash. |
174
- | author | `Object` | The commit author information. |
175
- | author.name | `String` | The commit author name. |
176
- | author.email | `String` | The commit author email. |
177
- | author.short | `String` | The commit author date. |
178
- | committer | `Object` | The committer information. |
179
- | committer.name | `String` | The committer name. |
180
- | committer.email | `String` | The committer email. |
181
- | committer.short | `String` | The committer date. |
182
- | subject | `String` | The commit subject. |
183
- | body | `String` | The commit body. |
184
- | message | `String` | The commit full message (`subject` and `body`). |
185
- | hash | `String` | The commit hash. |
186
- | committerDate | `String` | The committer date. |
187
-
188
- Example:
189
-
190
- ```js
191
- [
192
- {
193
- commit: {
194
- long: '68eb2c4d778050b0701136ca129f837d7ed494d2',
195
- short: '68eb2c4'
196
- },
197
- tree: {
198
- long: '7ab515d12bd2cf431745511ac4ee13fed15ab578',
199
- short: '7ab515d'
200
- },
201
- author: {
202
- name: 'Me',
203
- email: 'me@email.com',
204
- date: 2018-07-22T20:52:44.000Z
205
- },
206
- committer: {
207
- name: 'Me',
208
- email: 'me@email.com',
209
- date: 2018-07-22T20:52:44.000Z
210
- },
211
- subject: 'feat: a new feature',
212
- body: 'Description of the new feature',
213
- hash: '68eb2c4d778050b0701136ca129f837d7ed494d2',
214
- message: 'feat: a new feature\n\nDescription of the new feature',
215
- committerDate: 2018-07-22T20:52:44.000Z
216
- }
217
- ]
218
- ```
219
-
220
- #### nextRelease
221
-
222
- Type: `Object`
223
-
224
- Information related to the newly published release:
225
-
226
- | Name | Type | Description |
227
- | ------- | -------- | ----------------------------------------------------------------------------------------------------------------------------- |
228
- | type | `String` | The [semver](https://semver.org) type of the release (`patch`, `minor` or `major`). |
229
- | version | `String` | The version of the new release. |
230
- | gitHead | `String` | The sha of the last commit being part of the new release. |
231
- | gitTag | `String` | The [Git tag](https://git-scm.com/book/en/v2/Git-Basics-Tagging) associated with the new release. |
232
- | notes | `String` | The release notes for the new release. |
233
- | channel | `String` | The distribution channel on which the next release will be made available (`undefined` for the default distribution channel). |
234
-
235
- Example:
236
-
237
- ```js
238
- {
239
- type: 'minor',
240
- gitHead: '68eb2c4d778050b0701136ca129f837d7ed494d2',
241
- version: '1.1.0',
242
- gitTag: 'v1.1.0',
243
- notes: 'Release notes for version 1.1.0...',
244
- channel : 'next'
245
- }
246
- ```
247
-
248
- #### releases
249
-
250
- Type: `Array<Object>`
251
-
252
- The list of releases published or made available to a distribution channel.<br>
253
- Each release object has the following properties:
254
-
255
- | Name | Type | Description |
256
- | ---------- | -------- | -------------------------------------------------------------------------------------------------------------- |
257
- | name | `String` | **Optional.** The release name, only if set by the corresponding `publish` plugin. |
258
- | url | `String` | **Optional.** The release URL, only if set by the corresponding `publish` plugin. |
259
- | type | `String` | The [semver](https://semver.org) type of the release (`patch`, `minor` or `major`). |
260
- | version | `String` | The version of the release. |
261
- | gitHead | `String` | The sha of the last commit being part of the release. |
262
- | gitTag | `String` | The [Git tag](https://git-scm.com/book/en/v2/Git-Basics-Tagging) associated with the release. |
263
- | notes | `String` | The release notes for the release. |
264
- | pluginName | `String` | The name of the plugin that published the release. |
265
- | channel | `String` | The distribution channel on which the release is available (`undefined` for the default distribution channel). |
266
-
267
- Example:
268
-
269
- ```js
270
- [
271
- {
272
- name: 'GitHub release',
273
- url: 'https://github.com/me/my-package/releases/tag/v1.1.0',
274
- type: 'minor',
275
- gitHead: '68eb2c4d778050b0701136ca129f837d7ed494d2',
276
- version: '1.1.0',
277
- gitTag: 'v1.1.0',
278
- notes: 'Release notes for version 1.1.0...',
279
- pluginName: '@semantic-release/github'
280
- channel: 'next'
281
- },
282
- {
283
- name: 'npm package (@latest dist-tag)',
284
- url: 'https://www.npmjs.com/package/my-package',
285
- type: 'minor',
286
- gitHead: '68eb2c4d778050b0701136ca129f837d7ed494d2',
287
- version: '1.1.0',
288
- gitTag: 'v1.1.0',
289
- notes: 'Release notes for version 1.1.0...',
290
- pluginName: '@semantic-release/npm'
291
- channel: 'next'
292
- }
293
- ]
294
- ```
@@ -1,284 +0,0 @@
1
- # Plugin Developer Guide
2
-
3
- To create a plugin for `semantic-release`, you need to decide which parts of the release lifecycle are important to that plugin. For example, it is best to always have a `verifyConditions` step because you may be receiving inputs from a user and want to make sure they exist. A plugin can abide by any of the following lifecycles:
4
-
5
- - `verifyConditions`
6
- - `analyzeCommits`
7
- - `verifyRelease`
8
- - `generateNotes`
9
- - `addChannel`
10
- - `prepare`
11
- - `publish`
12
- - `success`
13
- - `fail`
14
-
15
- `semantic-release` will require the plugin via `node` and look through the required object for methods named like the lifecycles stated above. For example, if your plugin only had a `verifyConditions` and `success` step, the `main` file for your object would need to `export` an object with `verifyConditions` and `success` functions.
16
-
17
- In addition to the lifecycle methods, each lifecycle is passed two objects:
18
-
19
- 1. `pluginConfig` - an object containing the options that a user may pass in via their `release.config.js` file (or similar)
20
- 2. `context` - provided by `semantic-release` for access to things like `env` variables set on the running process.
21
-
22
- For each lifecycle you create, you will want to ensure it can accept `pluginConfig` and `context` as parameters.
23
-
24
- ## Creating a Plugin Project
25
-
26
- It is recommended that you generate a new project with `yarn init`. This will provide you with a basic node project to get started with. From there, create an `index.js` file, and make sure it is specified as the `main` in the `package.json`. We will use this file to orchestrate the lifecycle methods later on.
27
-
28
- Next, create a `src` or `lib` folder in the root of the project. This is where we will store our logic and code for how our lifecycle methods work. Finally, create a `test` folder so you can write tests related to your logic.
29
-
30
- We recommend you setup a linting system to ensure good javascript practices are enforced. ESLint is usually the system of choice, and the configuration can be whatever you or your team fancies.
31
-
32
- ## Exposing Lifecycle Methods
33
-
34
- In your `index.js` file, you can start by writing the following code
35
-
36
- ```javascript
37
- const verify = require("./src/verify");
38
-
39
- let verified;
40
-
41
- /**
42
- * Called by semantic-release during the verification step
43
- * @param {*} pluginConfig The semantic-release plugin config
44
- * @param {*} context The context provided by semantic-release
45
- */
46
- async function verifyConditions(pluginConfig, context) {
47
- await verify(pluginConfig, context);
48
- verified = true;
49
- }
50
-
51
- module.exports = { verifyConditions };
52
- ```
53
-
54
- Then, in your `src` folder, create a file called `verify.js` and add the following
55
-
56
- ```javascript
57
- const AggregateError = require("aggregate-error");
58
-
59
- /**
60
- * A method to verify that the user has given us a slack webhook url to post to
61
- */
62
- module.exports = async (pluginConfig, context) => {
63
- const { logger } = context;
64
- const errors = [];
65
-
66
- // Throw any errors we accumulated during the validation
67
- if (errors.length > 0) {
68
- throw new AggregateError(errors);
69
- }
70
- };
71
- ```
72
-
73
- As of right now, this code won't do anything. However, if you were to run this plugin via `semantic-release`, it would run when the `verify` step occurred.
74
-
75
- Following this structure, you can create different steps and checks to run through out the release process.
76
-
77
- ## Supporting Options
78
-
79
- Let's say we want to verify that an `option` is passed. An `option` is a configuration object that is specific to your plugin. For example, the user may set an `option` in their release config like:
80
-
81
- ```js
82
- {
83
- prepare: {
84
- path: "@semantic-release/my-special-plugin";
85
- message: "My cool release message";
86
- }
87
- }
88
- ```
89
-
90
- This `message` option will be passed to the `pluginConfig` object mentioned earlier. We can use the validation method we created to verify this option exists so we can perform logic based on that knowledge. In our `verify` file, we can add the following:
91
-
92
- ```js
93
- const { message } = pluginConfig;
94
-
95
- if (message.length) {
96
- //...
97
- }
98
- ```
99
-
100
- ## Context
101
-
102
- ### Common context keys
103
-
104
- - `stdout`
105
- - `stderr`
106
- - `logger`
107
-
108
- ### Context object keys by lifecycle
109
-
110
- #### verifyConditions
111
-
112
- Initially the context object contains the following keys (`verifyConditions` lifecycle):
113
-
114
- - `cwd`
115
- - Current working directory
116
- - `env`
117
- - Environment variables
118
- - `envCi`
119
- - Information about CI environment
120
- - Contains (at least) the following keys:
121
- - `isCi`
122
- - Boolean, true if the environment is a CI environment
123
- - `commit`
124
- - Commit hash
125
- - `branch`
126
- - Current branch
127
- - `options`
128
- - Options passed to `semantic-release` via CLI, configuration files etc.
129
- - `branch`
130
- - Information on the current branch
131
- - Object keys:
132
- - `channel`
133
- - `tags`
134
- - `type`
135
- - `name`
136
- - `range`
137
- - `accept`
138
- - `main`
139
- - `branches`
140
- - Information on branches
141
- - List of branch objects (see above)
142
-
143
- #### analyzeCommits
144
-
145
- Compared to the verifyConditions, `analyzeCommits` lifecycle context has keys
146
-
147
- - `commits` (List)
148
- - List of commits taken into account when determining the new version.
149
- - Keys:
150
- - `commit` (Object)
151
- - Keys:
152
- - `long` (String, Commit hash)
153
- - `short` (String, Commit hash)
154
- - `tree` (Object)
155
- - Keys:
156
- - `long` (String, Commit hash)
157
- - `short` (String, Commit hash)
158
- - `author` (Object)
159
- - Keys:
160
- - `name` (String)
161
- - `email` (String)
162
- - `date` (String, ISO 8601 timestamp)
163
- - `committer` (Object)
164
- - Keys:
165
- - `name` (String)
166
- - `email` (String)
167
- - `date` (String, ISO 8601 timestamp)
168
- - `subject` (String, Commit message subject)
169
- - `body` (String, Commit message body)
170
- - `hash` (String, Commit hash)
171
- - `committerDate` (String, ISO 8601 timestamp)
172
- - `message` (String)
173
- - `gitTags` (String, List of git tags)
174
- - `releases` (List)
175
- - `lastRelease` (Object)
176
- - Keys
177
- - `version` (String)
178
- - `gitTag` (String)
179
- - `channels` (List)
180
- - `gitHead` (String, Commit hash)
181
- - `name` (String)
182
-
183
- #### verifyRelease
184
-
185
- Additional keys:
186
-
187
- - `nextRelease` (Object)
188
- - `type` (String)
189
- - `channel` (String)
190
- - `gitHead` (String, Git hash)
191
- - `version` (String, version without `v`)
192
- - `gitTag` (String, version with `v`)
193
- - `name` (String)
194
-
195
- #### generateNotes
196
-
197
- No new content in the context.
198
-
199
- #### addChannel
200
-
201
- _This is run only if there are releases that have been merged from a higher branch but not added on the channel of the current branch._
202
-
203
- Context content is similar to lifecycle `verifyRelease`.
204
-
205
- #### prepare
206
-
207
- Only change is that `generateNotes` has populated `nextRelease.notes`.
208
-
209
- #### publish
210
-
211
- No new content in the context.
212
-
213
- #### success
214
-
215
- Lifecycles `success` and `fail` are mutually exclusive, only one of them will be run.
216
-
217
- Additional keys:
218
-
219
- - `releases`
220
- - Populated by `publish` lifecycle
221
-
222
- #### fail
223
-
224
- Lifecycles `success` and `fail` are mutually exclusive, only one of them will be run.
225
-
226
- Additional keys:
227
-
228
- - `errors`
229
-
230
- ### Supporting Environment Variables
231
-
232
- Similar to `options`, environment variables exist to allow users to pass tokens and set special URLs. These are set on the `context` object instead of the `pluginConfig` object. Let's say we wanted to check for `GITHUB_TOKEN` in the environment because we want to post to GitHub on the user's behalf. To do this, we can add the following to our `verify` command:
233
-
234
- ```js
235
- const { env } = context;
236
-
237
- if (env.GITHUB_TOKEN) {
238
- //...
239
- }
240
- ```
241
-
242
- ## Logger
243
-
244
- Use `context.logger` to provide debug logging in the plugin. Available logging functions: `log`, `warn`, `success`, `error`.
245
-
246
- ```js
247
- const { logger } = context;
248
-
249
- logger.log('Some message from plugin.').
250
- ```
251
-
252
- The above usage yields the following where `PLUGIN_PACKAGE_NAME` is automatically inferred.
253
-
254
- ```
255
- [3:24:04 PM] [semantic-release] [PLUGIN_PACKAGE_NAME] › ℹ Some message from plugin.
256
- ```
257
-
258
- ## Execution order
259
-
260
- For the lifecycles, the list at the top of the readme contains the order. If there are multiple plugins for the same lifecycle, then the order of the plugins determines the order in which they are executed.
261
-
262
- ## Handling errors
263
-
264
- In order to be able to detect and handle errors properly, the errors thrown from the must be of type [SemanticReleaseError](https://github.com/semantic-release/error) or extend it as described in the package readme. This way the errors are handled properly and plugins using the `fail` lifecycle receive the errors correctly. For any other types of errors the internal error handling does nothing, lets them through up until the final catch and does not call any `fail` plugins.
265
-
266
- ## Advanced
267
-
268
- Knowledge that might be useful for plugin developers.
269
-
270
- ### Multiple analyzeCommits plugins
271
-
272
- While it may be trivial that multiple analyzeCommits (or any lifecycle plugins) can be defined, it is not that self-evident that the plugins executed AFTER the first one (for example, the default one: `commit-analyzer`) can change the result. This way it is possible to create more advanced rules or situations, e.g. if none of the commits would result in new release, then a default can be defined.
273
-
274
- The commit must be a known release type, for example the commit-analyzer has the following default types:
275
-
276
- - major
277
- - premajor
278
- - minor
279
- - preminor
280
- - patch
281
- - prepatch
282
- - prerelease
283
-
284
- If the analyzeCommits-lifecycle plugin does not return anything, then the earlier result is used, but if it returns a supported string value, then that overrides the previous result.
@@ -1 +0,0 @@
1
- # Shareable configuration developer guide
@@ -1,4 +0,0 @@
1
- # Extending semantic-release
2
-
3
- - [Plugins list](plugins-list.md)
4
- - [Shareable configuration list](shareable-configurations-list.md)