Skip to content

Commit 0fa1abb

Browse files
committed
fix: add @semantic-release/exec
1 parent be5ffcc commit 0fa1abb

File tree

6 files changed

+358
-13
lines changed

6 files changed

+358
-13
lines changed

adminforth/documentation/blog/2025-01-09-how-adminforth-manages-version/index.md

Lines changed: 85 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,34 @@ In `package.json` add:
8181
//diff-add
8282
"release": {
8383
//diff-add
84-
"branches": [main", "next"]
84+
"branches": [main", "next"],
85+
//diff-add
86+
"plugins": [
87+
//diff-add
88+
"@semantic-release/commit-analyzer",
89+
//diff-add
90+
"@semantic-release/release-notes-generator",
91+
//diff-add
92+
"@semantic-release/npm",
93+
//diff-add
94+
"@semantic-release/github"
95+
//diff-add
96+
],
8597
//diff-add
8698
}
8799
}
88100
```
89101

90102
Make sure name in package.json has your organisation name like mine `@devforth/` and you have access to publish packages to npmjs.com.
91103

104+
105+
Also install `semantic-release`:
106+
92107
```
93-
npm install --save-dev semantic-release
108+
npm i -D semantic-release
94109
```
95110

111+
96112
## Connecting to CI
97113

98114
We will use Woodpecker CI for this example. Woodpecker is a free and open-source CI/CD tool that you can install to your own server / VPS and will not need to pay only for server. No limits on pipelines, users, repositories, etc. If you want to try it, we have [Woodpecker installation guide](https://devforth.io/blog/step-by-step-guide-to-modern-secure-ci-setup/)
@@ -238,4 +254,70 @@ git merge next
238254
git push
239255
```
240256

241-
This will trigger release `v1.2.0` because we merged `next` to `main` and it was a feature release.
257+
This will trigger release `v1.2.0` because we merged `next` to `main` and it was a feature release.
258+
259+
260+
## Slack notifications
261+
262+
So now we have automatic releases with release notes on GitHub.
263+
For our internal team we use Slack and we want to get notifications about releases there.
264+
265+
```
266+
npm i -D semantic-release-slack-bot
267+
```
268+
269+
Into "release" section of `package.json` add slack plugin:
270+
271+
```
272+
"plugins": [
273+
"@semantic-release/commit-analyzer",
274+
"@semantic-release/release-notes-generator",
275+
"@semantic-release/npm",
276+
"@semantic-release/github",
277+
//diff-add
278+
[
279+
//diff-add
280+
"semantic-release-slack-bot",
281+
//diff-add
282+
{
283+
//diff-add
284+
"notifyOnSuccess": true,
285+
//diff-add
286+
"notifyOnFail": true,
287+
//diff-add
288+
"slackIcon": ":package:",
289+
//diff-add
290+
"onSuccessTemplate": {
291+
//diff-add
292+
"text": "$npm_package_version has been released!"
293+
//diff-add
294+
},
295+
//diff-add
296+
"markdownReleaseNotes": true
297+
}
298+
]
299+
],
300+
```
301+
302+
303+
Also create channel in Slack, click on channel name, "Integrations" -> "Add an App" -> "Incoming Webhooks" -> "Add to Slack" -> "Add Incoming Webhook to Workspace" -> "Add to Slack" -> "Copy Webhook URL"
304+
305+
Add it to Woodpecker as secret `SLACK_WEBHOOK` environment variable.
306+
307+
Also add this secterd to `.woodpecker.yml`:
308+
309+
```
310+
secrets:
311+
- GITHUB_TOKEN
312+
- NPM_TOKEN
313+
//diff-add
314+
- SLACK_WEBHOOK
315+
```
316+
317+
318+
This will send notifications to Slack channel about succesfull releases when `npm run build` is done without errors.
319+
However if you have errors in build, or have unit tests in the flow, you will not get notifications about failed releases, because `npx semantic-release` will not be executed.
320+
321+
To fix it we will add another slack notification plugin, moreover we will use dedicated `adminforth-developers` channel for it.
322+
323+
```

adminforth/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import ExpressServer from './servers/express.js';
88
// import FastifyServer from './servers/fastify.js';
99
import { ADMINFORTH_VERSION, listify, suggestIfTypo, RateLimiter, getClientIp } from './modules/utils.js';
1010

11+
a.b =1
12+
1113
import {
1214
type AdminForthConfig,
1315
type IAdminForth,

adminforth/package-lock.json

Lines changed: 207 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

adminforth/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,6 @@
2626
},
2727
"release": {
2828
"plugins": [
29-
[
30-
"@semantic-release/exec",
31-
{
32-
"prepareCmd": "npm run build"
33-
}
34-
],
3529
"@semantic-release/commit-analyzer",
3630
"@semantic-release/release-notes-generator",
3731
"@semantic-release/npm",
@@ -40,7 +34,12 @@
4034
"semantic-release-slack-bot",
4135
{
4236
"notifyOnSuccess": true,
43-
"notifyOnFail": true
37+
"notifyOnFail": true,
38+
"slackIcon": ":package:",
39+
"onSuccessTemplate": {
40+
"text": "$npm_package_version has been released!"
41+
},
42+
"markdownReleaseNotes": true
4443
}
4544
]
4645
],
@@ -87,6 +86,7 @@
8786
"ws": "^8.18.0"
8887
},
8988
"devDependencies": {
89+
"@semantic-release/exec": "^6.0.3",
9090
"@types/node": "^20.14.2",
9191
"semantic-release": "^24.2.1",
9292
"semantic-release-slack-bot": "^4.0.2",

0 commit comments

Comments
 (0)