Skip to content

Commit c7ec4e5

Browse files
committed
build: publishing
1 parent d0cb045 commit c7ec4e5

3 files changed

Lines changed: 113 additions & 11 deletions

File tree

.github/workflows/release.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Plugin Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
permissions:
8+
contents: write
9+
id-token: write
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Setup pnpm
21+
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
22+
with:
23+
version: 10.16.1
24+
25+
- name: Setup Node.js
26+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
27+
with:
28+
node-version: '20'
29+
registry-url: 'https://registry.npmjs.org'
30+
31+
- name: Update npm
32+
run: npm install -g npm@latest
33+
34+
- name: Install dependencies
35+
run: pnpm install --frozen-lockfile
36+
37+
- name: Build
38+
run: pnpm run build
39+
40+
- name: Verify tag matches package version
41+
run: |
42+
PKG_VERSION=$(node -p "require('./packages/plugin/package.json').version")
43+
if [ -n "${{ github.event.release.tag_name }}" ]; then
44+
RAW_TAG="${{ github.event.release.tag_name }}"
45+
else
46+
RAW_TAG="${GITHUB_REF#refs/tags/}"
47+
fi
48+
TAG_VERSION="${RAW_TAG#v}"
49+
if [ "$PKG_VERSION" != "$TAG_VERSION" ]; then
50+
echo "Tag version ($TAG_VERSION) does not match package.json version ($PKG_VERSION)"
51+
exit 1
52+
fi
53+
54+
- name: Publish to NPM
55+
working-directory: ./packages/plugin
56+
run: npm publish --access public

README.md

Lines changed: 56 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,8 @@ export const getStackClient = (queryClient: QueryClient) => {
490490

491491
### Step 10: Build and Publish
492492

493+
Before publishing, make sure everything is working:
494+
493495
```bash
494496
# Build your plugin
495497
pnpm --filter @your-username/your-plugin-name build
@@ -500,11 +502,44 @@ pnpm --filter @your-username/your-plugin-name typecheck
500502
# Run linting
501503
pnpm --filter @your-username/your-plugin-name lint
502504

505+
# Run unit tests
506+
pnpm --filter @your-username/your-plugin-name test
507+
508+
# Run e2e tests
509+
pnpm e2e:smoke
510+
```
511+
512+
**Manual Publishing:**
513+
514+
```bash
503515
# Publish to npm (make sure you're logged in: npm login)
504516
cd packages/plugin
505517
npm publish --access public
506518
```
507519

520+
**Automated Publishing with GitHub Actions:**
521+
522+
This repository includes a GitHub Actions workflow that automatically publishes your plugin to npm when you create a GitHub release.
523+
524+
1. **Update the version** in `packages/plugin/package.json`:
525+
```json
526+
{
527+
"version": "1.0.0"
528+
}
529+
```
530+
531+
2. **Create a GitHub release** with a tag matching the version (e.g., `v1.0.0`):
532+
- Go to your repository on GitHub
533+
- Click "Releases" → "Create a new release"
534+
- Create a new tag (e.g., `v1.0.0`)
535+
- The tag version must match the `package.json` version exactly
536+
537+
3. **The workflow will automatically**:
538+
- Build the project
539+
- Verify the tag matches the package version
540+
- Publish to npm
541+
542+
508543
## Commands
509544

510545
### Root Level Commands
@@ -513,6 +548,7 @@ npm publish --access public
513548
- `pnpm dev` - Start development servers in watch mode
514549
- `pnpm lint` - Lint all packages
515550
- `pnpm typecheck` - Type check all packages
551+
- `pnpm test` - Run unit tests for all packages
516552
- `pnpm e2e:smoke` - Run end-to-end smoke tests
517553
- `pnpm format` - Format code with Prettier
518554

@@ -572,20 +608,38 @@ The project uses Tailwind CSS v4. Plugin styles are automatically included when
572608

573609
### Unit Tests
574610

575-
Your plugin includes unit tests using Vitest:
611+
Your plugin includes unit tests using Vitest. Run tests for all packages:
612+
613+
```bash
614+
pnpm test
615+
```
616+
617+
Or run tests for a specific package:
576618

577619
```bash
578620
pnpm --filter @your-username/your-plugin-name test
579621
```
580622

581623
### E2E Tests
582624

583-
End-to-end tests are located in the `e2e/` directory and use Playwright:
625+
End-to-end tests are located in the `e2e/` directory and use Playwright. Run the smoke tests:
584626

585627
```bash
586628
pnpm e2e:smoke
587629
```
588630

631+
This command will:
632+
- Build all packages
633+
- Start the example Next.js application
634+
- Run Playwright tests against the running application
635+
636+
For interactive debugging, you can run the Playwright UI:
637+
638+
```bash
639+
cd e2e
640+
pnpm e2e:ui
641+
```
642+
589643
## Project Structure Best Practices
590644

591645
1. **Separate API and Client**: Keep backend (`api/`) and frontend (`client/`) code separate
@@ -607,11 +661,3 @@ The `plugin` package is your starting point and serves as a complete reference i
607661
- SSR and meta generation
608662

609663
Modify the `plugin` to build your own plugin, then publish it to npm under your own account.
610-
611-
## License
612-
613-
[Add your license here]
614-
615-
## Contributing
616-
617-
[Add contribution guidelines here]

packages/plugin/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@btst/todo-plugin",
3-
"version": "0.0.1",
3+
"version": "0.0.2",
44
"type": "module",
55
"scripts": {
66
"build": "unbuild",

0 commit comments

Comments
 (0)