Skip to content

Commit 4fc145f

Browse files
authored
Merge pull request #5 from NandhakumarE/develop
Add CI/CD workflows for Storybook and npm releases
2 parents 7db3cfa + 1abb2f6 commit 4fc145f

6 files changed

Lines changed: 269 additions & 6 deletions

File tree

.changeset/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"commit": false,
55
"fixed": [],
66
"linked": [],
7-
"access": "restricted",
7+
"access": "public",
88
"baseBranch": "main",
99
"updateInternalDependencies": "patch",
1010
"ignore": []

.changeset/initial-features.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
"react-querybuilder-lite": minor
3+
---
4+
5+
### Features
6+
7+
- Add `QueryBuilder` component for building queries without drag-and-drop
8+
- Add `QueryBuilderDnD` component with built-in drag-and-drop support
9+
- Add `addRule` and `addRuleGroup` utilities for inserting new items
10+
- Add `removeRule` and `removeRuleGroup` utilities for deletion
11+
- Add `updateRuleInQuery` and `updateRuleGroupInQuery` for modifications
12+
- Add `cloneRule` and `cloneRuleGroup` for duplicating with new IDs
13+
- Add `lockRule` and `lockRuleGroup` to prevent editing
14+
- Add `moveHandler` for drag-and-drop reordering
15+
- Add `DefaultDragOverlay` component for drag preview
16+
- Add `Draggable` and `Droppable` components for custom DnD implementations
17+
- Add Storybook with interactive component examples
18+
19+
### Bug Fixes
20+
21+
- Fix depth calculation in nested group render props
22+
- Fix drag-and-drop edge cases when moving between groups
23+
- Fix styles to inject at runtime (no separate CSS import required)
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Deploy Storybook to GitHub Pages
2+
# Triggers: Push to main branch only
3+
name: Deploy Storybook
4+
5+
on:
6+
push:
7+
branches:
8+
- main
9+
workflow_dispatch: # Allow manual trigger
10+
11+
permissions:
12+
contents: read
13+
pages: write
14+
id-token: write
15+
16+
concurrency:
17+
group: "pages"
18+
cancel-in-progress: true
19+
20+
jobs:
21+
build:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
27+
- name: Setup Node.js
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: "20"
31+
cache: "npm"
32+
33+
- name: Install dependencies
34+
run: npm ci
35+
36+
- name: Build Storybook
37+
run: npm run build-storybook
38+
39+
- name: Setup Pages
40+
uses: actions/configure-pages@v4
41+
42+
- name: Upload artifact
43+
uses: actions/upload-pages-artifact@v3
44+
with:
45+
path: "./storybook-static"
46+
47+
deploy:
48+
needs: build
49+
runs-on: ubuntu-latest
50+
environment:
51+
name: github-pages
52+
url: ${{ steps.deployment.outputs.page_url }}
53+
steps:
54+
- name: Deploy to GitHub Pages
55+
id: deployment
56+
uses: actions/deploy-pages@v4

.github/workflows/release.yml

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
# Release Workflow
2+
#
3+
# Your flow:
4+
# develop → release (PR) → merge → publishes beta
5+
# release → main (PR) → merge → publishes stable (changeset required)
6+
#
7+
# Beta version: Reads changeset for bump type (patch/minor/major), defaults to patch
8+
#
9+
name: Release
10+
11+
on:
12+
push:
13+
branches:
14+
- main
15+
- release
16+
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.ref }}
19+
cancel-in-progress: true
20+
21+
jobs:
22+
release:
23+
runs-on: ubuntu-latest
24+
25+
permissions:
26+
contents: write
27+
id-token: write
28+
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v4
32+
33+
- name: Setup Node.js
34+
uses: actions/setup-node@v4
35+
with:
36+
node-version: "20"
37+
cache: "npm"
38+
registry-url: "https://registry.npmjs.org"
39+
40+
- name: Install dependencies
41+
run: npm ci
42+
43+
- name: Build package
44+
run: npm run build
45+
46+
# ─────────────────────────────────────────────────────────
47+
# Check for changesets and determine bump type
48+
# ─────────────────────────────────────────────────────────
49+
- name: Check changesets and bump type
50+
id: changesets
51+
run: |
52+
CHANGESET_FILE=$(find .changeset -name "*.md" ! -name "README.md" 2>/dev/null | head -1)
53+
54+
if [ -z "$CHANGESET_FILE" ]; then
55+
echo "has_changesets=false" >> $GITHUB_OUTPUT
56+
echo "bump_type=patch" >> $GITHUB_OUTPUT
57+
echo "⚠️ No changesets found - defaulting to patch"
58+
else
59+
echo "has_changesets=true" >> $GITHUB_OUTPUT
60+
61+
# Read changeset to determine bump type (major > minor > patch)
62+
if grep -q "major" "$CHANGESET_FILE"; then
63+
echo "bump_type=major" >> $GITHUB_OUTPUT
64+
echo "📦 Changeset indicates: major"
65+
elif grep -q "minor" "$CHANGESET_FILE"; then
66+
echo "bump_type=minor" >> $GITHUB_OUTPUT
67+
echo "📦 Changeset indicates: minor"
68+
else
69+
echo "bump_type=patch" >> $GITHUB_OUTPUT
70+
echo "📦 Changeset indicates: patch"
71+
fi
72+
fi
73+
74+
# ─────────────────────────────────────────────────────────
75+
# RELEASE BRANCH → Publish Beta
76+
# ─────────────────────────────────────────────────────────
77+
- name: Get current version
78+
if: github.ref == 'refs/heads/release'
79+
id: current_version
80+
run: |
81+
VERSION=$(node -p "require('./package.json').version")
82+
echo "version=$VERSION" >> $GITHUB_OUTPUT
83+
echo "Current version: $VERSION"
84+
85+
- name: Determine beta version
86+
if: github.ref == 'refs/heads/release'
87+
id: beta_version
88+
run: |
89+
CURRENT="${{ steps.current_version.outputs.version }}"
90+
BUMP_TYPE="${{ steps.changesets.outputs.bump_type }}"
91+
92+
# Remove any existing prerelease suffix
93+
BASE=$(echo $CURRENT | sed 's/-beta.*//' | sed 's/-alpha.*//' | sed 's/-rc.*//')
94+
IFS='.' read -ra PARTS <<< "$BASE"
95+
96+
MAJOR=${PARTS[0]}
97+
MINOR=${PARTS[1]}
98+
PATCH=${PARTS[2]}
99+
100+
# Apply bump based on changeset type
101+
case $BUMP_TYPE in
102+
major)
103+
NEW_MAJOR=$((MAJOR + 1))
104+
NEW_VERSION="${NEW_MAJOR}.0.0-beta.1"
105+
;;
106+
minor)
107+
NEW_MINOR=$((MINOR + 1))
108+
NEW_VERSION="${MAJOR}.${NEW_MINOR}.0-beta.1"
109+
;;
110+
patch)
111+
# Check if already a beta of same base version
112+
if [[ "$CURRENT" == "${MAJOR}.${MINOR}.$((PATCH))-beta"* ]]; then
113+
# Increment beta number
114+
BETA_NUM=$(echo $CURRENT | sed 's/.*-beta\.//')
115+
NEW_BETA=$((BETA_NUM + 1))
116+
NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}-beta.${NEW_BETA}"
117+
else
118+
NEW_PATCH=$((PATCH + 1))
119+
NEW_VERSION="${MAJOR}.${MINOR}.${NEW_PATCH}-beta.1"
120+
fi
121+
;;
122+
esac
123+
124+
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
125+
echo "📦 Beta version: $NEW_VERSION (bump type: $BUMP_TYPE)"
126+
127+
- name: Update version for beta
128+
if: github.ref == 'refs/heads/release'
129+
run: npm version ${{ steps.beta_version.outputs.new_version }} --no-git-tag-version
130+
131+
- name: Publish beta to npm
132+
if: github.ref == 'refs/heads/release'
133+
run: npm publish --tag beta --provenance --access public
134+
env:
135+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
136+
137+
- name: Commit beta version
138+
if: github.ref == 'refs/heads/release'
139+
run: |
140+
git config user.name "github-actions[bot]"
141+
git config user.email "github-actions[bot]@users.noreply.github.com"
142+
git add package.json package-lock.json
143+
git commit -m "chore: release ${{ steps.beta_version.outputs.new_version }}"
144+
git push
145+
env:
146+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
147+
148+
# ─────────────────────────────────────────────────────────
149+
# MAIN BRANCH → Publish Stable (changeset REQUIRED)
150+
# ─────────────────────────────────────────────────────────
151+
- name: Version packages (stable)
152+
if: github.ref == 'refs/heads/main' && steps.changesets.outputs.has_changesets == 'true'
153+
run: npx changeset version
154+
155+
- name: Publish stable to npm
156+
if: github.ref == 'refs/heads/main' && steps.changesets.outputs.has_changesets == 'true'
157+
run: npm publish --provenance --access public
158+
env:
159+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
160+
161+
- name: Commit version + changelog
162+
if: github.ref == 'refs/heads/main' && steps.changesets.outputs.has_changesets == 'true'
163+
run: |
164+
git config user.name "github-actions[bot]"
165+
git config user.email "github-actions[bot]@users.noreply.github.com"
166+
git add -A
167+
git commit -m "chore: release stable"
168+
git push
169+
env:
170+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
171+
172+
# ─────────────────────────────────────────────────────────
173+
# MAIN BRANCH + NO CHANGESETS → Skip
174+
# ─────────────────────────────────────────────────────────
175+
- name: Skip stable publish (no changesets)
176+
if: github.ref == 'refs/heads/main' && steps.changesets.outputs.has_changesets == 'false'
177+
run: |
178+
echo "────────────────────────────────────────────────"
179+
echo "ℹ️ No changesets found - skipping stable release"
180+
echo ""
181+
echo "To publish a stable version:"
182+
echo " 1. Run: npx changeset"
183+
echo " 2. Commit the .md file"
184+
echo " 3. Merge to main"
185+
echo "────────────────────────────────────────────────"

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ dist-ssr
1616
.env.*.local
1717
*.local
1818

19-
.changeset/*.md
20-
!.changeset/README.md
21-
2219
# Editor directories and files
2320
.vscode/*
2421
!.vscode/extensions.json

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
![TypeScript](https://img.shields.io/badge/TypeScript-strict-blue)
66
![React](https://img.shields.io/badge/React-18%20%7C%2019-61dafb)
77
[![License](https://img.shields.io/npm/l/react-querybuilder-lite)](https://github.com/NandhakumarE/react-visual-querybuilder/blob/main/LICENSE)
8+
[![Storybook](https://img.shields.io/badge/Storybook-Live%20Demo-ff4785)](https://nandhakumare.github.io/react-querybuilder-lite/)
89

910
A lightweight, headless React query builder with drag-and-drop support. Build complex filter UIs with any design system — zero styling opinions.
1011

@@ -290,8 +291,9 @@ Operators are automatically filtered by field type:
290291

291292
## Live Demos
292293

293-
<!-- TODO: Add Storybook link after deployment -->
294-
Coming soon — Storybook examples with various design systems.
294+
**[📚 View Storybook →](https://nandhakumare.github.io/react-querybuilder-lite/)**
295+
296+
Interactive examples showcasing all components with different configurations.
295297

296298
## Design Decisions
297299

0 commit comments

Comments
 (0)