semantic-release 17.4.2 → 17.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.
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
# Plugin Developer Guide
|
|
2
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 `
|
|
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
4
|
|
|
5
|
-
- `
|
|
5
|
+
- `verifyConditions`
|
|
6
|
+
- `analyzeCommits`
|
|
7
|
+
- `verifyRelease`
|
|
8
|
+
- `generateNotes`
|
|
9
|
+
- `addChannel`
|
|
6
10
|
- `prepare`
|
|
7
11
|
- `publish`
|
|
8
12
|
- `success`
|
|
9
13
|
- `fail`
|
|
10
14
|
|
|
11
|
-
`semantic-release` will require the plugin via `node` and look through the required object for methods named like the lifecyles stated above. For example, if your plugin only had a `
|
|
15
|
+
`semantic-release` will require the plugin via `node` and look through the required object for methods named like the lifecyles 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.
|
|
12
16
|
|
|
13
17
|
In addition to the lifecycle methods, each lifecyle is passed two objects:
|
|
14
18
|
|
|
@@ -93,7 +97,131 @@ if (message.length) {
|
|
|
93
97
|
}
|
|
94
98
|
```
|
|
95
99
|
|
|
96
|
-
##
|
|
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
|
+
* `cwd`
|
|
114
|
+
* Current working directory
|
|
115
|
+
* `env`
|
|
116
|
+
* Environment variables
|
|
117
|
+
* `envCi`
|
|
118
|
+
* Information about CI environment
|
|
119
|
+
* Contains (at least) the following keys:
|
|
120
|
+
* `isCi`
|
|
121
|
+
* Boolean, true if the environment is a CI environment
|
|
122
|
+
* `commit`
|
|
123
|
+
* Commit hash
|
|
124
|
+
* `branch`
|
|
125
|
+
* Current branch
|
|
126
|
+
* `options`
|
|
127
|
+
* Options passed to `semantic-release` via CLI, configuration files etc.
|
|
128
|
+
* `branch`
|
|
129
|
+
* Information on the current branch
|
|
130
|
+
* Object keys:
|
|
131
|
+
* `channel`
|
|
132
|
+
* `tags`
|
|
133
|
+
* `type`
|
|
134
|
+
* `name`
|
|
135
|
+
* `range`
|
|
136
|
+
* `accept`
|
|
137
|
+
* `main`
|
|
138
|
+
* `branches`
|
|
139
|
+
* Information on branches
|
|
140
|
+
* List of branch objects (see above)
|
|
141
|
+
|
|
142
|
+
#### analyzeCommits
|
|
143
|
+
|
|
144
|
+
Compared to the verifyConditions, `analyzeCommits` lifecycle context has keys
|
|
145
|
+
|
|
146
|
+
* `commits` (List)
|
|
147
|
+
* List of commits taken into account when determining the new version.
|
|
148
|
+
* Keys:
|
|
149
|
+
* `commit` (Object)
|
|
150
|
+
* Keys:
|
|
151
|
+
* `long` (String, Commit hash)
|
|
152
|
+
* `short` (String, Commit hash)
|
|
153
|
+
* `tree` (Object)
|
|
154
|
+
* Keys:
|
|
155
|
+
* `long` (String, Commit hash)
|
|
156
|
+
* `short` (String, Commit hash)
|
|
157
|
+
* `author` (Object)
|
|
158
|
+
* Keys:
|
|
159
|
+
* `name` (String)
|
|
160
|
+
* `email` (String)
|
|
161
|
+
* `date` (String, ISO 8601 timestamp)
|
|
162
|
+
* `committer` (Object)
|
|
163
|
+
* Keys:
|
|
164
|
+
* `name` (String)
|
|
165
|
+
* `email` (String)
|
|
166
|
+
* `date` (String, ISO 8601 timestamp)
|
|
167
|
+
* `subject` (String, Commit message subject)
|
|
168
|
+
* `body` (String, Commit message body)
|
|
169
|
+
* `hash` (String, Commit hash)
|
|
170
|
+
* `committerDate` (String, ISO 8601 timestamp)
|
|
171
|
+
* `message` (String)
|
|
172
|
+
* `gitTags` (String, List of git tags)
|
|
173
|
+
* `releases` (List)
|
|
174
|
+
* `lastRelease` (Object)
|
|
175
|
+
* Keys
|
|
176
|
+
* `version` (String)
|
|
177
|
+
* `gitTag` (String)
|
|
178
|
+
* `channels` (List)
|
|
179
|
+
* `gitHead` (String, Commit hash)
|
|
180
|
+
* `name` (String)
|
|
181
|
+
|
|
182
|
+
#### verifyRelease
|
|
183
|
+
|
|
184
|
+
Additional keys:
|
|
185
|
+
|
|
186
|
+
* `nextRelease`
|
|
187
|
+
* Similar object as `lastRelease` (see above)
|
|
188
|
+
|
|
189
|
+
#### generateNotes
|
|
190
|
+
|
|
191
|
+
No new content in the context.
|
|
192
|
+
|
|
193
|
+
#### addChannel
|
|
194
|
+
|
|
195
|
+
*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.*
|
|
196
|
+
|
|
197
|
+
Context content is similar to lifecycle `verifyRelease`.
|
|
198
|
+
|
|
199
|
+
#### prepare
|
|
200
|
+
|
|
201
|
+
Only change is that `generateNotes` has populated `nextRelease.notes`.
|
|
202
|
+
|
|
203
|
+
#### publish
|
|
204
|
+
|
|
205
|
+
No new content in the context.
|
|
206
|
+
|
|
207
|
+
#### success
|
|
208
|
+
|
|
209
|
+
Lifecycles `success` and `fail` are mutually exclusive, only one of them will be run.
|
|
210
|
+
|
|
211
|
+
Additional keys:
|
|
212
|
+
|
|
213
|
+
* `releases`
|
|
214
|
+
* Populated by `publish` lifecycle
|
|
215
|
+
|
|
216
|
+
#### fail
|
|
217
|
+
|
|
218
|
+
Lifecycles `success` and `fail` are mutually exclusive, only one of them will be run.
|
|
219
|
+
|
|
220
|
+
Additional keys:
|
|
221
|
+
|
|
222
|
+
* `errors`
|
|
223
|
+
|
|
224
|
+
### Supporting Environment Variables
|
|
97
225
|
|
|
98
226
|
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:
|
|
99
227
|
|
|
@@ -101,6 +229,6 @@ Similar to `options`, environment variables exist to allow users to pass tokens
|
|
|
101
229
|
const { env } = context;
|
|
102
230
|
|
|
103
231
|
if (env.GITHUB_TOKEN) {
|
|
104
|
-
|
|
232
|
+
//...
|
|
105
233
|
}
|
|
106
|
-
```
|
|
234
|
+
```
|
|
@@ -97,7 +97,7 @@ The Git history of the repository is now:
|
|
|
97
97
|
|
|
98
98
|
After a period of feedback from our users using the `@next` dist-tag we feel confident to make our big feature available to all users. To do so we merge the `next` branch into `master`. There should be no conflict as `next` is strictly ahead of `master`.
|
|
99
99
|
|
|
100
|
-
Once the merge commit is pushed to `
|
|
100
|
+
Once the merge commit is pushed to `master`, **semantic-release** will add the version `2.1.0` to the dist-tag `@latest` so all users will receive it when installing out module with `npm install example-module`.
|
|
101
101
|
|
|
102
102
|
The Git history of the repository is now:
|
|
103
103
|
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
- ["Introduction to SemVer" - Irina Gebauer](https://blog.greenkeeper.io/introduction-to-semver-d272990c44f2)
|
|
16
16
|
- ["Introduction to Semantic Release" - liv](https://blog.greenkeeper.io/introduction-to-semantic-release-33f73b117c8)
|
|
17
17
|
- ["Series - Semantic Release Automation" - Abdelrahman Wahdan](https://dev.to/abdelrahmanahmed/semantic-release-and-how-to-automate-it-part-1-4pa2)
|
|
18
|
+
- ["Explain semantic release and how to use it on GitLab pipeline"](https://regoo707.medium.com/auto-bump-apps-versions-and-releases-using-gitlab-pipeline-e32f1d7fa3ee)
|
|
18
19
|
|
|
19
20
|
## Tutorials
|
|
20
21
|
|
|
@@ -65,5 +65,5 @@ To recover from that situation, do the following:
|
|
|
65
65
|
|
|
66
66
|
1. Delete the tag(s) for the release(s) that have been lost from the git history. You can delete each tag from remote using `git push origin :[TAG NAME]`, e.g. `git push origin :v2.0.0-beta.1`. You can delete tags locally using `git tag -d [TAG NAME]`, e.g. `git tag -d v2.0.0-beta.1`.
|
|
67
67
|
2. Re-create the tags locally: `git tag [TAG NAME] [COMMIT HASH]`, where `[COMMIT HASH]` is the new commit that created the release for the lost tag. E.g. `git tag v2.0.0-beta.1 abcdef0`
|
|
68
|
-
3. Re-create the git notes for each release tag, e.g. `git notes --ref semantic-release add -f -m '{"channels":["beta"]}'
|
|
68
|
+
3. Re-create the git notes for each release tag, e.g. `git notes --ref semantic-release add -f -m '{"channels":["beta"]}' v2.0.0-beta.1`. If the release was also published in the default channel (usually `master`), then set the first channel to `null`, e.g. `git notes --ref semantic-release add -f -m '{"channels":[null, "beta"]}'
|
|
69
69
|
4. Push the local notes: `git push --force origin refs/notes/semantic-release`. The `--force` is needed after the rebase. Be careful.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "semantic-release",
|
|
3
3
|
"description": "Automated semver compliant package publishing",
|
|
4
|
-
"version": "17.4.
|
|
4
|
+
"version": "17.4.3",
|
|
5
5
|
"author": "Stephan Bönnemann <stephan@boennemann.me> (http://boennemann.me)",
|
|
6
6
|
"ava": {
|
|
7
7
|
"files": [
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"git-log-parser": "^1.2.0",
|
|
37
37
|
"hook-std": "^2.0.0",
|
|
38
38
|
"hosted-git-info": "^4.0.0",
|
|
39
|
-
"lodash": "^4.17.
|
|
39
|
+
"lodash": "^4.17.21",
|
|
40
40
|
"marked": "^2.0.0",
|
|
41
41
|
"marked-terminal": "^4.1.1",
|
|
42
42
|
"micromatch": "^4.0.2",
|
|
@@ -57,12 +57,12 @@
|
|
|
57
57
|
"dockerode": "3.2.1",
|
|
58
58
|
"file-url": "3.0.0",
|
|
59
59
|
"fs-extra": "9.1.0",
|
|
60
|
-
"got": "11.8.
|
|
60
|
+
"got": "11.8.2",
|
|
61
61
|
"js-yaml": "3.14.1",
|
|
62
62
|
"mockserver-client": "5.11.2",
|
|
63
|
-
"nock": "13.0.
|
|
63
|
+
"nock": "13.0.11",
|
|
64
64
|
"nyc": "15.1.0",
|
|
65
|
-
"p-retry": "4.
|
|
65
|
+
"p-retry": "4.5.0",
|
|
66
66
|
"proxyquire": "2.1.3",
|
|
67
67
|
"sinon": "9.2.4",
|
|
68
68
|
"stream-buffers": "3.0.2",
|