Skip to content

Commit 7ad4d9e

Browse files
committed
feat: release
1 parent 744e7a3 commit 7ad4d9e

File tree

5 files changed

+2140
-30
lines changed

5 files changed

+2140
-30
lines changed

.github/workflows/publish.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Publish to NPM
2+
3+
on:
4+
push:
5+
branches:
6+
- release
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
12+
permissions:
13+
contents: write # Required for creating Git tags
14+
id-token: write # Required for npm provenance
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0 # Fetch all history for proper versioning
21+
22+
- name: Setup Node.js
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: '20' # Use LTS version, adjust as needed
26+
registry-url: 'https://registry.npmjs.org'
27+
28+
- name: Install dependencies
29+
run: npm ci
30+
31+
- name: Run tests
32+
run: npm test
33+
continue-on-error: false # Fail if tests fail
34+
35+
- name: Build library
36+
run: npm run build:npm
37+
38+
- name: Test package installation
39+
run: |
40+
npm pack
41+
npm install -g $(npm pack | tail -1)
42+
43+
- name: Publish to NPM
44+
run: npm publish --provenance --access public
45+
env:
46+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
47+
48+
- name: Create Git tag
49+
run: |
50+
VERSION=$(node -p "require('./package.json').version")
51+
git tag "v$VERSION"
52+
git push origin "v$VERSION"
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.npmignore

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Source files
2+
src/
3+
4+
# Config files
5+
.eslintrc.json
6+
.eslintignore
7+
.prettierrc
8+
.prettierignore
9+
tsconfig.json
10+
jest.config.js
11+
rollup.config.js
12+
vercel.json
13+
.yarnrc.yml
14+
15+
# CI/CD
16+
.github/
17+
18+
# Development
19+
.storybook/
20+
storybook-static/
21+
assets/
22+
23+
# Test files
24+
*.test.ts
25+
*.test.tsx
26+
*.spec.ts
27+
*.spec.tsx
28+
__tests__/
29+
30+
# Logs and artifacts
31+
*.log
32+
debug-storybook.log
33+
*.tgz
34+
35+
# IDE and tools
36+
.claude/
37+
.vscode/
38+
.idea/
39+
40+
# Documentation (optional - remove if you want these in package)
41+
CONTRIBUTING.md
42+
43+
# Lock files
44+
yarn.lock
45+
package-lock.json

jest.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
preset: 'ts-jest',
3+
testEnvironment: 'jsdom',
4+
roots: ['<rootDir>/src'],
5+
testMatch: ['**/__tests__/**/*.ts?(x)', '**/?(*.)+(spec|test).ts?(x)'],
6+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'],
7+
collectCoverageFrom: ['src/**/*.{ts,tsx}', '!src/**/*.d.ts', '!src/**/*.stories.{ts,tsx}'],
8+
};

package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@
1010
],
1111
"scripts": {
1212
"build": "yarn clean && rollup -c",
13+
"build:npm": "npm run clean && rollup -c",
1314
"build:storybook": "storybook build",
1415
"build:vercel": "storybook build",
1516
"dev": "rollup -c -w",
1617
"clean": "rimraf dist",
17-
"test": "jest",
18+
"test": "jest --passWithNoTests",
1819
"lint": "eslint src --ext .ts,.tsx",
1920
"format": "prettier --write \"src/**/*.{ts,tsx}\"",
2021
"prepare": "yarn build",
22+
"prepublishOnly": "npm run build:npm && npm test",
2123
"storybook": "storybook dev -p 6006",
2224
"build-storybook": "storybook build"
2325
},
@@ -30,6 +32,7 @@
3032
"@storybook/addon-links": "^10.1.11",
3133
"@storybook/react": "^10.1.11",
3234
"@storybook/react-vite": "^10.1.11",
35+
"@types/jest": "^30.0.0",
3336
"@types/react": "^18.2.0",
3437
"@types/react-dom": "^18.2.0",
3538
"@typescript-eslint/eslint-plugin": "^7.0.0",
@@ -39,13 +42,16 @@
3942
"eslint-plugin-react": "^7.33.2",
4043
"eslint-plugin-react-hooks": "^4.6.0",
4144
"eslint-plugin-storybook": "10.1.11",
45+
"jest": "^30.2.0",
46+
"jest-environment-jsdom": "^30.2.0",
4247
"prettier": "^3.2.5",
4348
"react": "^19.2.0",
4449
"react-dom": "^19.2.0",
4550
"rimraf": "^5.0.5",
4651
"rollup": "^4.9.6",
4752
"rollup-plugin-typescript2": "^0.36.0",
4853
"storybook": "^10.1.11",
54+
"ts-jest": "^29.4.6",
4955
"typescript": "^5.8.3",
5056
"vite": "^7.2.6"
5157
},

0 commit comments

Comments
 (0)