Skip to content

Commit d8753bf

Browse files
committed
Add semantic release and conventional commit
https://harperdb.atlassian.net/browse/STUDIO-188
1 parent 11ab0ef commit d8753bf

File tree

8 files changed

+2572
-25
lines changed

8 files changed

+2572
-25
lines changed

.env

Lines changed: 0 additions & 6 deletions
This file was deleted.

.github/workflows/deploy-dev.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ jobs:
1010
steps:
1111
- name: Checkout code
1212
uses: actions/checkout@v4
13+
with:
14+
fetch-depth: 0
15+
fetch-tags: true
1316
- name: Set up Node.js
1417
uses: actions/setup-node@v4
1518
- name: Set up pnpm
@@ -20,6 +23,11 @@ jobs:
2023
run: pnpm test
2124
- name: Run lint
2225
run: pnpm lint
26+
- name: Determine version tag for build
27+
run: |
28+
VERSION_TAG="v${GITHUB_SHA:0:7}"
29+
echo "$VERSION_TAG"
30+
echo "VITE_STUDIO_VERSION=$VERSION_TAG" >> $GITHUB_ENV
2331
- name: Build dev
2432
run: pnpm build:dev
2533
- name: Install HarperDB

.github/workflows/deploy-prod.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ jobs:
99
steps:
1010
- name: Checkout code
1111
uses: actions/checkout@v4
12+
with:
13+
fetch-depth: 0
14+
fetch-tags: true
1215
- name: Set up Node.js
1316
uses: actions/setup-node@v4
1417
- name: Set up pnpm
@@ -19,6 +22,13 @@ jobs:
1922
run: pnpm test
2023
- name: Run lint
2124
run: pnpm lint
25+
- name: Determine version tag for build
26+
run: |
27+
VERSION_TAG=$(git tag --points-at HEAD | grep -E '^v?[0-9]+\.[0-9]+\.[0-9]+' | sort -V | tail -n1)
28+
if [ -z "$VERSION_TAG" ]; then
29+
VERSION_TAG="v0.0.0+${GITHUB_SHA:0:7}"
30+
fi
31+
echo "VITE_STUDIO_VERSION=$VERSION_TAG" >> $GITHUB_ENV
2232
- name: Build prod
2333
run: pnpm build:prod
2434
- name: Install HarperDB

.github/workflows/deploy-stage.yaml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@ on:
77
jobs:
88
deployToStage:
99
runs-on: ubuntu-latest
10+
permissions:
11+
contents: write
1012
steps:
1113
- name: Checkout code
1214
uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
fetch-tags: true
1318
- name: Set up Node.js
1419
uses: actions/setup-node@v4
1520
- name: Set up pnpm
@@ -20,7 +25,20 @@ jobs:
2025
run: pnpm test
2126
- name: Run lint
2227
run: pnpm lint
23-
- name: Build stage
28+
- name: Verify stage can build
29+
run: pnpm build:stage
30+
- name: Semantic release
31+
run: pnpm release
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
- name: Determine version tag for build
35+
run: |
36+
VERSION_TAG=$(git tag --points-at HEAD | grep -E '^v?[0-9]+\.[0-9]+\.[0-9]+' | sort -V | tail -n1)
37+
if [ -z "$VERSION_TAG" ]; then
38+
VERSION_TAG="v0.0.0+${GITHUB_SHA:0:7}"
39+
fi
40+
echo "VITE_STUDIO_VERSION=$VERSION_TAG" >> $GITHUB_ENV
41+
- name: Build stage for release
2442
run: pnpm build:stage
2543
- name: Install HarperDB
2644
run: npm install -g [email protected]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Verify Commits
2+
on:
3+
pull_request:
4+
types: [opened, synchronize, edited, reopened, ready_for_review]
5+
push:
6+
branches: [dev, stage, prod]
7+
jobs:
8+
commitlint:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v4
13+
with:
14+
fetch-depth: 0
15+
- name: Commitlint
16+
uses: wagoid/commitlint-github-action@v6
17+
with:
18+
configFile: commitlint.config.cjs

commitlint.config.cjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
extends: ['@commitlint/config-conventional'],
3+
};

package.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,39 @@
1111
"build:dev": "tsc -b && vite build --mode dev",
1212
"build:stage": "tsc -b && vite build --mode stage",
1313
"build:prod": "tsc -b && vite build --mode prod",
14+
"release": "semantic-release",
1415
"update-sdk": "npx -y dotenv-cli -e .env.local -- npm run update-sdk:fetch && npx -y openapi-typescript --root-types --alphabetize --enum ./dist/central-manager.json -o ./src/lib/api.gen.d.ts",
1516
"update-sdk:fetch": "mkdir -p dist && curl --location \"$VITE_CENTRAL_MANAGER_API_URL/openapi\" -u \"$HDB_ADMIN_USERNAME_FOR_OPENAPI:$HDB_ADMIN_PASSWORD_FOR_OPENAPI\" -o ./dist/central-manager.json",
1617
"lint": "eslint .",
1718
"preview": "vite preview",
1819
"test": "vitest run",
1920
"test:watch": "vitest"
2021
},
22+
"release": {
23+
"branches": ["stage"],
24+
"tagFormat": "v${version}",
25+
"plugins": [
26+
["@semantic-release/commit-analyzer", {
27+
"preset": "conventionalcommits",
28+
"releaseRules": [
29+
{"type": "feat", "release": "minor"},
30+
{"type": "fix", "release": "patch"},
31+
{"type": "perf", "release": "patch"},
32+
{"type": "refactor", "release": "patch"},
33+
{"type": "chore", "release": "patch"},
34+
{"type": "docs", "release": "patch"},
35+
{"type": "style", "release": "patch"},
36+
{"type": "test", "release": "patch"},
37+
{"type": "build", "release": "patch"},
38+
{"type": "ci", "release": "patch"},
39+
{"type": "revert", "release": "patch"},
40+
{"type": "*", "release": "patch"}
41+
]
42+
}],
43+
"@semantic-release/release-notes-generator",
44+
"@semantic-release/github"
45+
]
46+
},
2147
"dependencies": {
2248
"@datadog/browser-rum": "^6.18.0",
2349
"@datadog/browser-rum-react": "^6.18.0",
@@ -60,7 +86,12 @@
6086
"zod": "^3.25.0"
6187
},
6288
"devDependencies": {
89+
"@commitlint/cli": "^19.5.0",
90+
"@commitlint/config-conventional": "^19.5.0",
6391
"@eslint/js": "^9.19.0",
92+
"@semantic-release/commit-analyzer": "^13.0.0",
93+
"@semantic-release/release-notes-generator": "^14.0.0",
94+
"@semantic-release/github": "^10.0.7",
6495
"@tanstack/router-devtools": "^1.111.11",
6596
"@types/react": "^19.0.8",
6697
"@types/react-dom": "^19.0.3",
@@ -70,6 +101,7 @@
70101
"eslint-plugin-react-refresh": "^0.4.18",
71102
"globals": "^15.14.0",
72103
"oxlint": "^0.15.12",
104+
"semantic-release": "^24.1.0",
73105
"typescript": "~5.7.2",
74106
"typescript-eslint": "^8.22.0",
75107
"vite": "^6.1.0",

0 commit comments

Comments
 (0)