Skip to content

Commit 8cbef07

Browse files
committed
feat: add woodpecker release script
1 parent 7a26e12 commit 8cbef07

5 files changed

Lines changed: 2744 additions & 4 deletions

File tree

.woodpecker/buildRelease.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
npm run build 2>&1 | tee build.log
4+
build_status=${PIPESTATUS[0]}
5+
6+
if [ $build_status -ne 0 ]; then
7+
echo "Build failed. Exiting with status code $build_status"
8+
exit $build_status
9+
fi

.woodpecker/buildSlackNotify.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/sh
2+
3+
set -x
4+
5+
COMMIT_SHORT_SHA=$(echo $CI_COMMIT_SHA | cut -c1-8)
6+
7+
STATUS=${1}
8+
9+
if [ "$STATUS" = "success" ]; then
10+
MESSAGE="Did a build without issues on \`$CI_REPO_NAME/$CI_COMMIT_BRANCH\`. Commit: _${CI_COMMIT_MESSAGE}_ (<$CI_COMMIT_URL|$COMMIT_SHORT_SHA>)"
11+
12+
curl -s -X POST -H "Content-Type: application/json" -d '{
13+
"username": "'"$CI_COMMIT_AUTHOR"'",
14+
"icon_url": "'"$CI_COMMIT_AUTHOR_AVATAR"'",
15+
"attachments": [
16+
{
17+
"mrkdwn_in": ["text", "pretext"],
18+
"color": "#36a64f",
19+
"text": "'"$MESSAGE"'"
20+
}
21+
]
22+
}' "$DEVELOPERS_SLACK_WEBHOOK"
23+
exit 0
24+
fi
25+
export BUILD_LOG=$(cat ./build.log)
26+
27+
BUILD_LOG=$(echo $BUILD_LOG | sed 's/"/\\"/g')
28+
29+
MESSAGE="Broke \`$CI_REPO_NAME/$CI_COMMIT_BRANCH\` with commit _${CI_COMMIT_MESSAGE}_ (<$CI_COMMIT_URL|$COMMIT_SHORT_SHA>)"
30+
CODE_BLOCK="\`\`\`$BUILD_LOG\n\`\`\`"
31+
32+
echo "Sending slack message to developers $MESSAGE"
33+
curl -sS -X POST -H "Content-Type: application/json" -d '{
34+
"username": "'"$CI_COMMIT_AUTHOR"'",
35+
"icon_url": "'"$CI_COMMIT_AUTHOR_AVATAR"'",
36+
"attachments": [
37+
{
38+
"mrkdwn_in": ["text", "pretext"],
39+
"color": "#8A1C12",
40+
"text": "'"$CODE_BLOCK"'",
41+
"pretext": "'"$MESSAGE"'"
42+
}
43+
]
44+
}' "$DEVELOPERS_SLACK_WEBHOOK" 2>&1

.woodpecker/release.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
clone:
2+
git:
3+
image: woodpeckerci/plugin-git
4+
settings:
5+
partial: false
6+
depth: 5
7+
8+
steps:
9+
init-secrets:
10+
when:
11+
- event: push
12+
image: infisical/cli
13+
environment:
14+
INFISICAL_TOKEN:
15+
from_secret: VAULT_TOKEN
16+
commands:
17+
- infisical export --domain https://vault.devforth.io/api --format=dotenv-export --env="prod" > /woodpecker/deploy.vault.env
18+
19+
build:
20+
image: devforth/node20-pnpm:latest
21+
when:
22+
- event: push
23+
commands:
24+
- . /woodpecker/deploy.vault.env
25+
- pnpm install
26+
- /bin/bash ./.woodpecker/buildRelease.sh
27+
- npm audit signatures
28+
29+
release:
30+
image: devforth/node20-pnpm:latest
31+
when:
32+
- event:
33+
- push
34+
branch:
35+
- main
36+
commands:
37+
- . /woodpecker/deploy.vault.env
38+
- pnpm exec semantic-release
39+
40+
slack-on-failure:
41+
image: curlimages/curl
42+
when:
43+
- event: push
44+
status: [failure]
45+
commands:
46+
- . /woodpecker/deploy.vault.env
47+
- /bin/sh ./.woodpecker/buildSlackNotify.sh failure
48+
49+
slack-on-success:
50+
image: curlimages/curl
51+
when:
52+
- event: push
53+
status: [success]
54+
commands:
55+
- . /woodpecker/deploy.vault.env
56+
- /bin/sh ./.woodpecker/buildSlackNotify.sh success

package.json

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,53 @@
11
{
22
"name": "@adminforth/github-oauth-adapter",
3-
"version": "1.0.10",
3+
"version": "1.0.0",
44
"main": "dist/index.js",
55
"types": "dist/index.d.ts",
66
"type": "module",
77
"scripts": {
8-
"build": "tsc && npm version patch",
9-
"rollout": "npm run build && npm publish --access public"
8+
"build": "tsc"
109
},
1110
"keywords": [],
1211
"author": "DevForth (https://devforth.io)",
1312
"license": "MIT",
1413
"description": "",
14+
"devDependencies": {
15+
"semantic-release": "^24.2.1",
16+
"semantic-release-slack-bot": "^4.0.2"
17+
},
1518
"repository": {
1619
"type": "git",
1720
"url": "https://github.com/devforth/adminforth-github-oauth-adapter.git"
1821
},
22+
"publishConfig": {
23+
"access": "public"
24+
},
1925
"dependencies": {
2026
"typescript": "^5.7.3"
27+
},
28+
"release": {
29+
"plugins": [
30+
"@semantic-release/commit-analyzer",
31+
"@semantic-release/release-notes-generator",
32+
"@semantic-release/npm",
33+
"@semantic-release/github",
34+
[
35+
"semantic-release-slack-bot",
36+
{
37+
"packageName": "@adminforth/github-oauth-adapter",
38+
"notifyOnSuccess": true,
39+
"notifyOnFail": true,
40+
"slackIcon": ":package:",
41+
"markdownReleaseNotes": true
42+
}
43+
]
44+
],
45+
"branches": [
46+
"main",
47+
{
48+
"name": "next",
49+
"prerelease": true
50+
}
51+
]
2152
}
2253
}

0 commit comments

Comments
 (0)