Skip to content

Commit b29f486

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

File tree

8 files changed

+2580
-25
lines changed

8 files changed

+2580
-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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = {
2+
extends: ['@commitlint/config-conventional'],
3+
rules: {
4+
'subject-case': [
5+
2,
6+
'always',
7+
['sentence-case', 'start-case', 'pascal-case', 'upper-case'],
8+
],
9+
},
10+
};

package.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,40 @@
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+
"commitlint": "commitlint --from=HEAD~1 --to=HEAD",
15+
"release": "semantic-release",
1416
"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",
1517
"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",
1618
"lint": "eslint .",
1719
"preview": "vite preview",
1820
"test": "vitest run",
1921
"test:watch": "vitest"
2022
},
23+
"release": {
24+
"branches": ["stage"],
25+
"tagFormat": "v${version}",
26+
"plugins": [
27+
["@semantic-release/commit-analyzer", {
28+
"preset": "conventionalcommits",
29+
"releaseRules": [
30+
{"type": "feat", "release": "minor"},
31+
{"type": "fix", "release": "patch"},
32+
{"type": "perf", "release": "patch"},
33+
{"type": "refactor", "release": "patch"},
34+
{"type": "chore", "release": "patch"},
35+
{"type": "docs", "release": "patch"},
36+
{"type": "style", "release": "patch"},
37+
{"type": "test", "release": "patch"},
38+
{"type": "build", "release": "patch"},
39+
{"type": "ci", "release": "patch"},
40+
{"type": "revert", "release": "patch"},
41+
{"type": "*", "release": "patch"}
42+
]
43+
}],
44+
"@semantic-release/release-notes-generator",
45+
"@semantic-release/github"
46+
]
47+
},
2148
"dependencies": {
2249
"@datadog/browser-rum": "^6.18.0",
2350
"@datadog/browser-rum-react": "^6.18.0",
@@ -60,7 +87,12 @@
6087
"zod": "^3.25.0"
6188
},
6289
"devDependencies": {
90+
"@commitlint/cli": "^19.5.0",
91+
"@commitlint/config-conventional": "^19.5.0",
6392
"@eslint/js": "^9.19.0",
93+
"@semantic-release/commit-analyzer": "^13.0.0",
94+
"@semantic-release/release-notes-generator": "^14.0.0",
95+
"@semantic-release/github": "^10.0.7",
6496
"@tanstack/router-devtools": "^1.111.11",
6597
"@types/react": "^19.0.8",
6698
"@types/react-dom": "^19.0.3",
@@ -70,6 +102,7 @@
70102
"eslint-plugin-react-refresh": "^0.4.18",
71103
"globals": "^15.14.0",
72104
"oxlint": "^0.15.12",
105+
"semantic-release": "^24.1.0",
73106
"typescript": "~5.7.2",
74107
"typescript-eslint": "^8.22.0",
75108
"vite": "^6.1.0",

0 commit comments

Comments
 (0)