Skip to content

Commit a7a47e8

Browse files
Copilothotlong
andcommitted
Add changesets and automated release workflow
- Install @changesets/cli package - Configure changesets for monorepo (ignore examples/apps, public access) - Add changeset scripts to package.json - Create GitHub Actions workflow for automated releases - Update CONTRIBUTING.md with changeset usage guide - Update .github/WORKFLOWS.md with changeset documentation - Enhance .changeset/README.md with Object UI specific guidance Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent e2482a6 commit a7a47e8

File tree

7 files changed

+847
-13
lines changed

7 files changed

+847
-13
lines changed

.changeset/README.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Changesets
2+
3+
This directory contains changeset files that track changes to packages in the Object UI monorepo.
4+
5+
## What are Changesets?
6+
7+
Changesets are a way to declare your intent to release packages. They help us:
8+
- Track which packages have changed
9+
- Determine appropriate version bumps (major, minor, patch)
10+
- Generate comprehensive changelogs
11+
- Automate the release process
12+
13+
## Quick Start
14+
15+
### Creating a Changeset
16+
17+
When you make changes to packages, run:
18+
19+
```bash
20+
pnpm changeset
21+
```
22+
23+
This will guide you through:
24+
1. Selecting which packages changed
25+
2. Choosing the type of version bump
26+
3. Writing a description of the changes
27+
28+
### Example
29+
30+
```bash
31+
$ pnpm changeset
32+
33+
🦋 Which packages would you like to include?
34+
◉ @object-ui/react
35+
◯ @object-ui/core
36+
◯ @object-ui/components
37+
38+
🦋 What kind of change is this for @object-ui/react?
39+
◯ major (breaking change)
40+
◉ minor (new feature)
41+
◯ patch (bug fix)
42+
43+
🦋 Please enter a summary for this change:
44+
Add support for custom validators in form components
45+
```
46+
47+
### When to Create a Changeset
48+
49+
**DO** create a changeset for:
50+
- New features
51+
- Bug fixes
52+
- Breaking changes
53+
- Performance improvements
54+
- API changes
55+
56+
**DON'T** create a changeset for:
57+
- Documentation updates
58+
- Changes to examples or apps
59+
- Internal refactoring with no API changes
60+
- Test-only updates
61+
62+
## Automated Release Process
63+
64+
1. **Merge PR with changeset** → Triggers automation
65+
2. **Bot creates "Version Packages" PR** → Updates versions and changelogs
66+
3. **Merge Version PR** → Automatically publishes to npm
67+
68+
## Learn More
69+
70+
- [Full Changesets Documentation](https://github.com/changesets/changesets)
71+
- [Object UI Contributing Guide](../CONTRIBUTING.md#versioning-and-releases)
72+
- [Common Questions](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
73+

.changeset/config.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/config@3.1.2/schema.json",
3+
"changelog": "@changesets/cli/changelog",
4+
"commit": false,
5+
"fixed": [],
6+
"linked": [],
7+
"access": "public",
8+
"baseBranch": "main",
9+
"updateInternalDependencies": "patch",
10+
"ignore": [
11+
"@apps/*",
12+
"@examples/*"
13+
]
14+
}

.github/WORKFLOWS.md

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,58 @@ Creates GitHub releases and publishes packages.
121121

122122
**Note**: npm publishing is currently disabled. Uncomment the publish step when ready.
123123

124-
### 8. Stale Issues & PRs
124+
### 8. Changeset Release (Automated)
125+
126+
**File**: `changeset-release.yml`
127+
**Triggers**: Push to `main` branch
128+
129+
Automated version management and package publishing using Changesets.
130+
131+
**What It Does**:
132+
1. Detects changesets in merged PRs
133+
2. Creates/updates a "Version Packages" PR that:
134+
- Bumps package versions based on changesets
135+
- Updates CHANGELOG.md files
136+
- Removes consumed changeset files
137+
3. When the Version PR is merged:
138+
- Publishes updated packages to npm
139+
- Creates GitHub releases with tags
140+
141+
**How It Works**:
142+
143+
```mermaid
144+
graph LR
145+
A[PR with changeset merged] --> B[Workflow runs]
146+
B --> C{Changesets exist?}
147+
C -->|Yes| D[Create/Update Version PR]
148+
C -->|No| E[Skip]
149+
D --> F[Version PR merged]
150+
F --> G[Publish to npm]
151+
G --> H[Create GitHub Release]
152+
```
153+
154+
**Developer Workflow**:
155+
1. Create PR with code changes
156+
2. Run `pnpm changeset` to create a changeset file
157+
3. Commit changeset file with your PR
158+
4. When PR is merged, automation takes over
159+
5. Review and merge the automated "Version Packages" PR
160+
6. Packages are published automatically
161+
162+
**Benefits**:
163+
- No manual version number editing
164+
- Automatic changelog generation
165+
- Coordinated releases across packages
166+
- Clear versioning based on semantic versioning
167+
- Prevents accidental version conflicts
168+
169+
**Required Setup**:
170+
- `NPM_TOKEN` secret must be configured in repository settings
171+
- Changesets should be included in all PRs with package changes
172+
173+
**Note**: See [CONTRIBUTING.md](../CONTRIBUTING.md#versioning-and-releases) for details on creating changesets.
174+
175+
### 9. Stale Issues & PRs
125176

126177
**File**: `stale.yml`
127178
**Triggers**: Daily schedule, Manual workflow dispatch
@@ -134,7 +185,7 @@ Manages stale issues and pull requests.
134185
- Exempt labels: `pinned`, `security`, `critical`, `bug`, `enhancement`
135186
- Can be reopened if activity resumes
136187

137-
### 9. Dependabot Auto-merge
188+
### 10. Dependabot Auto-merge
138189

139190
**File**: `dependabot-auto-merge.yml`
140191
**Configuration**: `dependabot.yml`
@@ -153,7 +204,7 @@ Automatically manages dependency updates.
153204
- Groups related dependencies
154205
- Limits to 10 open PRs
155206

156-
### 10. Auto Changelog
207+
### 11. Auto Changelog
157208

158209
**File**: `changelog.yml`
159210
**Triggers**: Release published, Manual workflow dispatch
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Changeset Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
concurrency: ${{ github.workflow }}-${{ github.ref }}
9+
10+
permissions:
11+
contents: write
12+
pull-requests: write
13+
id-token: write
14+
15+
jobs:
16+
release:
17+
name: Changeset Release
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout Repo
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Setup pnpm
26+
uses: pnpm/action-setup@v4
27+
with:
28+
version: 9
29+
30+
- name: Setup Node.js
31+
uses: actions/setup-node@v4
32+
with:
33+
node-version: '20.x'
34+
cache: 'pnpm'
35+
registry-url: 'https://registry.npmjs.org'
36+
37+
- name: Install dependencies
38+
run: pnpm install --frozen-lockfile
39+
40+
- name: Run tests
41+
run: pnpm test
42+
43+
- name: Build packages
44+
run: pnpm build
45+
46+
- name: Create Release Pull Request or Publish to npm
47+
id: changesets
48+
uses: changesets/action@v1
49+
with:
50+
version: pnpm changeset:version
51+
publish: pnpm changeset:publish
52+
title: 'chore: release packages'
53+
commit: 'chore: release packages'
54+
env:
55+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
57+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

CONTRIBUTING.md

Lines changed: 131 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,19 +303,31 @@ refactor: simplify expression evaluator
303303
git rebase upstream/main
304304
```
305305

306-
2. **Ensure tests pass**:
306+
2. **Create a changeset** (for package changes):
307+
```bash
308+
pnpm changeset
309+
```
310+
311+
This will prompt you to:
312+
- Select which packages have changed
313+
- Choose the version bump type (major, minor, patch)
314+
- Write a summary of the changes
315+
316+
Learn more about changesets in the [Versioning and Releases](#versioning-and-releases) section.
317+
318+
3. **Ensure tests pass**:
307319
```bash
308320
pnpm test
309321
```
310322

311-
3. **Ensure build succeeds**:
323+
4. **Ensure build succeeds**:
312324
```bash
313325
pnpm build
314326
```
315327

316-
4. **Update documentation** if needed
328+
5. **Update documentation** if needed
317329

318-
5. **Add tests** for new features
330+
6. **Add tests** for new features
319331

320332
### Creating the PR
321333

@@ -398,6 +410,121 @@ pnpm docs:build
398410

399411
See [Documentation Guide](./docs/README.md) for details.
400412

413+
## Versioning and Releases
414+
415+
We use [Changesets](https://github.com/changesets/changesets) for version management and automated releases.
416+
417+
### Understanding Changesets
418+
419+
Changesets is a tool that helps us:
420+
- **Track changes**: Each PR includes a changeset file describing what changed
421+
- **Automate versioning**: Automatically determine version bumps based on changesets
422+
- **Generate changelogs**: Create comprehensive changelogs from changeset descriptions
423+
- **Coordinate releases**: Release multiple packages together in our monorepo
424+
425+
### When to Create a Changeset
426+
427+
Create a changeset when your PR makes changes to any package in `packages/`:
428+
429+
-**DO create a changeset for**:
430+
- New features
431+
- Bug fixes
432+
- Breaking changes
433+
- Performance improvements
434+
- API changes
435+
436+
-**DON'T create a changeset for**:
437+
- Documentation updates only
438+
- Changes to examples or apps
439+
- Internal refactoring with no user-facing changes
440+
- Test updates without code changes
441+
442+
### How to Create a Changeset
443+
444+
1. **Run the changeset command**:
445+
```bash
446+
pnpm changeset
447+
```
448+
449+
2. **Select packages**: Use arrow keys and spacebar to select which packages changed
450+
```
451+
🦋 Which packages would you like to include?
452+
◯ @object-ui/core
453+
◉ @object-ui/react
454+
◯ @object-ui/components
455+
```
456+
457+
3. **Choose version bump type**:
458+
- **Major** (x.0.0): Breaking changes
459+
- **Minor** (0.x.0): New features (backwards compatible)
460+
- **Patch** (0.0.x): Bug fixes and minor updates
461+
462+
4. **Write a summary**: Describe what changed
463+
```
464+
Summary: Add support for custom validation rules in forms
465+
```
466+
467+
5. **Commit the changeset file**:
468+
```bash
469+
git add .changeset/*.md
470+
git commit -m "chore: add changeset"
471+
```
472+
473+
### Changeset Message Guidelines
474+
475+
Write clear, user-facing descriptions:
476+
477+
```markdown
478+
✅ Good:
479+
- Add support for custom date formats in DatePicker
480+
- Fix validation error in nested form fields
481+
- Improve performance of large data grids by 50%
482+
483+
❌ Bad:
484+
- Updated code
485+
- Fixed bug
486+
- Changes to validation
487+
```
488+
489+
### Release Process
490+
491+
The release process is automated:
492+
493+
1. **Create PR with changes** → Include a changeset file
494+
2. **PR is merged** → Changeset bot creates/updates a "Version Packages" PR
495+
3. **Version PR is merged** → Packages are automatically published to npm
496+
497+
You don't need to manually:
498+
- Update version numbers
499+
- Update CHANGELOGs
500+
- Create Git tags
501+
- Publish to npm
502+
503+
Everything is handled by the changeset automation!
504+
505+
### Example Workflow
506+
507+
```bash
508+
# 1. Create a feature branch
509+
git checkout -b feat/add-date-picker
510+
511+
# 2. Make your changes
512+
# ... edit files ...
513+
514+
# 3. Create a changeset
515+
pnpm changeset
516+
# Select @object-ui/components
517+
# Choose "minor" (new feature)
518+
# Summary: "Add DatePicker component with calendar popup"
519+
520+
# 4. Commit everything
521+
git add .
522+
git commit -m "feat: add DatePicker component"
523+
524+
# 5. Push and create PR
525+
git push origin feat/add-date-picker
526+
```
527+
401528
## Adding Components
402529

403530
### Creating a New Component

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,13 @@
3030
"test:coverage": "vitest run --coverage",
3131
"lint": "pnpm -r lint",
3232
"cli": "node packages/cli/dist/cli.js",
33-
"objectui": "node packages/cli/dist/cli.js"
33+
"objectui": "node packages/cli/dist/cli.js",
34+
"changeset": "changeset",
35+
"changeset:version": "changeset version",
36+
"changeset:publish": "changeset publish"
3437
},
3538
"devDependencies": {
39+
"@changesets/cli": "^2.29.8",
3640
"@eslint/js": "^9.39.1",
3741
"@testing-library/dom": "^10.4.1",
3842
"@testing-library/jest-dom": "^6.9.1",

0 commit comments

Comments
 (0)