Skip to content

Commit 249ba59

Browse files
committed
chore: automate releases with changesets
Replace custom changelog.js script with @changesets/cli for professional versioning, changelog generation, and npm publishing. Add GitHub Actions release workflow that opens a "Version Packages" PR on merge to master.
1 parent f25950c commit 249ba59

7 files changed

Lines changed: 707 additions & 200 deletions

File tree

.changeset/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changesets
2+
3+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
4+
with multi-package repos, or single-package repos to help you version and publish your code. You can
5+
find the full documentation for it [in the repository](https://github.com/changesets/changesets)
6+
7+
We have a quick list of common questions to get you started engaging with this project in
8+
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)

.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.1/schema.json",
3+
"changelog": [
4+
"@changesets/changelog-github",
5+
{ "repo": "wangdicoder/tiny-ui" }
6+
],
7+
"commit": false,
8+
"fixed": [],
9+
"linked": [],
10+
"access": "public",
11+
"baseBranch": "master",
12+
"updateInternalDependencies": "patch",
13+
"ignore": ["@tiny-ui/docs"]
14+
}

.github/workflows/release.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches: [master]
6+
7+
concurrency: ${{ github.workflow }}-${{ github.ref }}
8+
9+
jobs:
10+
release:
11+
name: Release
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: write
15+
pull-requests: write
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Install pnpm
21+
uses: pnpm/action-setup@v4
22+
23+
- name: Use Node.js 22
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: 22
27+
cache: 'pnpm'
28+
29+
- name: Install dependencies
30+
run: pnpm install --frozen-lockfile
31+
32+
- name: Build
33+
run: pnpm build
34+
35+
- name: Create Release Pull Request or Publish
36+
id: changesets
37+
uses: changesets/action@v1
38+
with:
39+
version: pnpm changeset version
40+
publish: pnpm release
41+
title: 'chore: version packages'
42+
commit: 'chore: version packages'
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

CONTRIBUTING.md

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# Contributing to Tiny UI
2+
3+
Thanks for your interest in contributing to Tiny UI! This guide will help you get started.
4+
5+
## Development Setup
6+
7+
### Prerequisites
8+
9+
- Node.js >= 22
10+
- pnpm (see `packageManager` in `package.json` for the exact version)
11+
12+
### Getting Started
13+
14+
```bash
15+
# Clone the repo
16+
git clone https://github.com/wangdicoder/tiny-ui.git
17+
cd tiny-ui
18+
19+
# Install dependencies
20+
pnpm install
21+
22+
# Start the docs site (dev server)
23+
pnpm dev
24+
25+
# Run tests
26+
pnpm test
27+
28+
# Build the component library
29+
pnpm build
30+
```
31+
32+
## Project Structure
33+
34+
```
35+
tiny-ui/
36+
├── packages/react/ # @tiny-ui/react — component library
37+
│ ├── src/ # Component source code
38+
│ ├── scripts/ # Build scripts
39+
│ └── package.json
40+
├── apps/docs/ # Documentation site
41+
│ ├── src/ # Site source
42+
│ ├── guides/ # Guide markdown files
43+
│ └── package.json
44+
├── turbo.json # Turborepo config
45+
└── package.json # Workspace root
46+
```
47+
48+
## Adding a New Component
49+
50+
1. Create a new directory under `packages/react/src/your-component/`
51+
2. Follow the existing component structure:
52+
53+
```
54+
your-component/
55+
├── your-component.tsx # Component implementation
56+
├── types.ts # TypeScript interfaces
57+
├── index.tsx # Barrel export
58+
├── index.md # English documentation
59+
├── index.zh_CN.md # Chinese documentation
60+
├── style/
61+
│ ├── _index.scss # Component styles
62+
│ └── index.tsx # Style entry (imports)
63+
├── demo/
64+
│ └── basic.md # Usage demos
65+
└── __tests__/
66+
└── your-component.test.tsx
67+
```
68+
69+
3. Export the component from `packages/react/src/index.ts`
70+
4. Add the route in `apps/docs/src/routers.tsx`
71+
72+
## Code Style
73+
74+
- TypeScript strict mode is enabled
75+
- Components use `React.forwardRef` for ref forwarding
76+
- CSS class names follow the `ty-component-name` convention
77+
- SCSS variables are in `packages/react/src/style/_variables.scss`
78+
79+
## Running Tests
80+
81+
```bash
82+
# Run all tests
83+
pnpm test
84+
85+
# Run tests for a specific component
86+
pnpm --filter @tiny-ui/react test -- --testPathPattern=button
87+
88+
# Update snapshots
89+
pnpm --filter @tiny-ui/react test:update
90+
91+
# Run with coverage
92+
pnpm --filter @tiny-ui/react test:coverage
93+
```
94+
95+
## Commit Convention
96+
97+
We use [Conventional Commits](https://www.conventionalcommits.org/). Each commit message should be structured as:
98+
99+
```
100+
<type>(<scope>): <description>
101+
```
102+
103+
Types: `feat`, `fix`, `docs`, `style`, `refactor`, `perf`, `test`, `chore`, `revert`
104+
105+
Examples:
106+
- `feat(button): add loading state`
107+
- `fix(modal): prevent scroll when open`
108+
- `docs(input): update API documentation`
109+
110+
## Adding a Changeset
111+
112+
We use [Changesets](https://github.com/changesets/changesets) to manage versioning and changelogs. If your PR includes user-facing changes to `@tiny-ui/react`, add a changeset:
113+
114+
```bash
115+
pnpm changeset
116+
```
117+
118+
You'll be prompted to:
119+
1. Select the package(s) affected (`@tiny-ui/react`)
120+
2. Choose the semver bump type (patch / minor / major)
121+
3. Write a short summary of your change
122+
123+
This creates a markdown file in `.changeset/` — commit it with your PR. When the PR merges, a "Version Packages" PR is automatically opened. Merging that PR publishes to npm and updates the changelog.
124+
125+
## Pull Requests
126+
127+
1. Fork the repo and create a branch from `master`
128+
2. If you've added code, add tests
129+
3. Ensure the test suite passes (`pnpm test`)
130+
4. Ensure your code lints (`pnpm lint`)
131+
5. Add a changeset if your change affects published packages (`pnpm changeset`)
132+
6. Create a pull request with a clear description
133+
134+
## Reporting Bugs
135+
136+
Use [GitHub Issues](https://github.com/wangdicoder/tiny-ui/issues) with the bug report template. Include:
137+
- Steps to reproduce
138+
- Expected vs actual behavior
139+
- Browser and OS information
140+
- A minimal reproduction if possible
141+
142+
## License
143+
144+
By contributing, you agree that your contributions will be licensed under the [MIT License](./LICENSE).

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,13 @@
2020
"lint": "turbo run lint",
2121
"lint:style": "turbo run lint:style",
2222
"prepare": "husky",
23-
"changelog": "node packages/react/scripts/changelog.js"
23+
"changeset": "changeset",
24+
"version-packages": "changeset version",
25+
"release": "turbo run build && changeset publish"
2426
},
2527
"devDependencies": {
28+
"@changesets/changelog-github": "^0.6.0",
29+
"@changesets/cli": "^2.30.0",
2630
"@commitlint/cli": "^19.0.0",
2731
"@eslint/js": "^9.0.0",
2832
"commitlint-config-cz": "^0.13.3",

0 commit comments

Comments
 (0)