Skip to content

Commit 26244c0

Browse files
committed
fix: try output build log
1 parent c6a8d45 commit 26244c0

File tree

3 files changed

+55
-33
lines changed

3 files changed

+55
-33
lines changed

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

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,6 @@ In `package.json` add:
8484
"branches": [main", "next"],
8585
//diff-add
8686
"plugins": [
87-
//diff-add
88-
[
89-
//diff-add
90-
"@semantic-release/exec",
91-
//diff-add
92-
{
93-
//diff-add
94-
"prepareCmd": "npm run build"
95-
//diff-add
96-
}
97-
//diff-add
98-
],
9987
//diff-add
10088
"@semantic-release/commit-analyzer",
10189
//diff-add
@@ -114,13 +102,12 @@ In `package.json` add:
114102
Make sure name in package.json has your organisation name like mine `@devforth/` and you have access to publish packages to npmjs.com.
115103

116104

117-
Also install `semantic-release` and `@semantic-release/exec`:
105+
Also install `semantic-release`:
118106

119107
```
120-
npm i -D semantic-release @semantic-release/exec
108+
npm i -D semantic-release
121109
```
122110

123-
We use `@semantic-release/exec` to run `npm run build` as prepare step for release. Of course you can run build before calling `semantic-release` in CI pipleine, but this approach will allow to nativeley integrate it with `semantic-release` and e.g. show build errors in semantic-release notification plugins.
124111

125112
## Connecting to CI
126113

@@ -145,6 +132,7 @@ steps:
145132
- /var/run/docker.sock:/var/run/docker.sock
146133
commands:
147134
- npm clean-install
135+
- npm run build
148136
- npm audit signatures
149137
- npx semantic-release
150138
secrets:
@@ -278,15 +266,37 @@ For our internal team we use Slack and we want to get notifications about releas
278266
npm i -D semantic-release-slack-bot
279267
```
280268

281-
Into "release" section of `package.json` add:
269+
Into "release" section of `package.json` add slack plugin:
282270

283271
```
272+
"plugins": [
273+
"@semantic-release/commit-analyzer",
274+
"@semantic-release/release-notes-generator",
275+
"@semantic-release/npm",
276+
"@semantic-release/github",
277+
//diff-add
284278
[
285-
"@semantic-release/slack",
279+
//diff-add
280+
"semantic-release-slack-bot",
281+
//diff-add
286282
{
287-
...
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
288297
}
289-
],
298+
]
299+
],
290300
```
291301

292302

@@ -302,4 +312,12 @@ Also add this secterd to `.woodpecker.yml`:
302312
- NPM_TOKEN
303313
//diff-add
304314
- 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+
305323
```

adminforth/package.json

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,8 @@
2828
"plugins": [
2929
"@semantic-release/commit-analyzer",
3030
"@semantic-release/release-notes-generator",
31-
32-
[
33-
"@semantic-release/exec",
34-
{
35-
"prepareCmd": "npm run build"
36-
}
37-
],
31+
"@semantic-release/npm",
32+
"@semantic-release/github",
3833
[
3934
"semantic-release-slack-bot",
4035
{
@@ -44,15 +39,9 @@
4439
"onSuccessTemplate": {
4540
"text": "$npm_package_version has been released!"
4641
},
47-
"onFailTemplate": {
48-
"text": "Release failed for $npm_package_version. Please check the logs!"
49-
},
5042
"markdownReleaseNotes": true
5143
}
52-
],
53-
54-
"@semantic-release/npm",
55-
"@semantic-release/github"
44+
]
5645
],
5746
"branches": [
5847
"main",

live-demo/deploy/.woodpecker.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,28 @@ steps:
1717
commands:
1818
- cd adminforth
1919
- npm clean-install
20+
- npm run build > build.log 2>&1 || echo "Build failed. See build.log for details."
2021
- npm audit signatures
2122
- npx semantic-release
2223
secrets:
2324
- GITHUB_TOKEN
2425
- NPM_TOKEN
2526
- SLACK_WEBHOOK
2627

28+
slack-after-build:
29+
image: plugins/slack
30+
secrets:
31+
- DEVELOPERS_SLACK_WEBHOOK
32+
webhook: $DEVELOPERS_SLACK_WEBHOOK
33+
username: Woodpecker CI
34+
icon_url: ${CI_COMMIT_AUTHOR_AVATAR}
35+
template: >
36+
{{repo.name}}/{{build.branch}} - #{{build.number}} {{uppercasefirst build.status}} after {{since build.started}} (<{{build.link}}|Open>)
37+
```{{ cat build.log | tail -n 50 }}```
38+
when:
39+
status:
40+
- failure
41+
2742
build-live-demo:
2843
when:
2944
- event: push

0 commit comments

Comments
 (0)