Skip to content

Commit e24c131

Browse files
authored
Merge pull request #75 from objectstack-ai/copilot/add-changeset-and-automation
2 parents ba0ca3d + 993fc58 commit e24c131

File tree

9 files changed

+1129
-8
lines changed

9 files changed

+1129
-8
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: 81 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,85 @@ 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. Changeset Check
176+
177+
**File**: `changeset-check.yml`
178+
**Triggers**: Pull Requests (opened, synchronized, labeled)
179+
180+
Ensures PRs that modify packages include a changeset.
181+
182+
**What It Does**:
183+
- Checks if PR modifies any files in `packages/`
184+
- Verifies a changeset file exists (`.changeset/*.md`)
185+
- Fails the check if changeset is missing
186+
- Can be skipped with `skip-changeset` or `dependencies` label
187+
188+
**When to Skip**:
189+
- Documentation-only changes
190+
- Changes to examples or apps
191+
- Test-only updates
192+
- Automated dependency updates (Dependabot)
193+
194+
**How to Pass**:
195+
1. Run `pnpm changeset` locally
196+
2. Follow the prompts to create a changeset
197+
3. Commit the generated `.changeset/*.md` file
198+
4. OR add `skip-changeset` label if not needed
199+
200+
This workflow helps maintain consistent versioning and comprehensive changelogs.
201+
202+
### 10. Stale Issues & PRs
125203

126204
**File**: `stale.yml`
127205
**Triggers**: Daily schedule, Manual workflow dispatch
@@ -134,7 +212,7 @@ Manages stale issues and pull requests.
134212
- Exempt labels: `pinned`, `security`, `critical`, `bug`, `enhancement`
135213
- Can be reopened if activity resumes
136214

137-
### 9. Dependabot Auto-merge
215+
### 11. Dependabot Auto-merge
138216

139217
**File**: `dependabot-auto-merge.yml`
140218
**Configuration**: `dependabot.yml`
@@ -153,7 +231,7 @@ Automatically manages dependency updates.
153231
- Groups related dependencies
154232
- Limits to 10 open PRs
155233

156-
### 10. Auto Changelog
234+
### 12. Auto Changelog
157235

158236
**File**: `changelog.yml`
159237
**Triggers**: Release published, Manual workflow dispatch
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Changeset Check
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened, labeled, unlabeled]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
check:
12+
name: Check for Changeset
13+
runs-on: ubuntu-latest
14+
# Skip this check if PR has 'skip-changeset' label or only changes non-package files
15+
if: |
16+
!contains(github.event.pull_request.labels.*.name, 'skip-changeset') &&
17+
!contains(github.event.pull_request.labels.*.name, 'dependencies')
18+
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+
36+
- name: Install dependencies
37+
run: pnpm install --frozen-lockfile
38+
39+
- name: Check for changesets
40+
run: |
41+
# Check if there are any changesets
42+
if [ ! "$(ls -A .changeset/*.md 2>/dev/null | grep -v 'README.md')" ]; then
43+
# Check if any package files were changed
44+
if git diff --name-only origin/${{ github.base_ref }}...HEAD | grep -q '^packages/'; then
45+
echo "❌ This PR modifies packages but doesn't include a changeset"
46+
echo ""
47+
echo "To add a changeset, run: pnpm changeset"
48+
echo ""
49+
echo "If this PR doesn't need a changeset (docs only, etc.),"
50+
echo "add the 'skip-changeset' label to the PR"
51+
echo ""
52+
echo "📚 Learn more: https://github.com/objectstack-ai/objectui/blob/main/CONTRIBUTING.md#versioning-and-releases"
53+
exit 1
54+
else
55+
echo "✅ No package changes detected, skipping changeset check"
56+
fi
57+
else
58+
echo "✅ Changeset found"
59+
fi
60+
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 }}

0 commit comments

Comments
 (0)