first commit #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| node-version: [18.x, 20.x, 22.x] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run linting | |
| run: npm run lint | |
| - name: Run formatting check | |
| run: npm run format -- --check | |
| - name: Build project | |
| run: npm run build | |
| - name: Verify build output | |
| run: | | |
| if [ ! -d "dist" ]; then | |
| echo "Build failed: dist directory not found" | |
| exit 1 | |
| fi | |
| if [ ! -f "dist/index.js" ]; then | |
| echo "Build failed: main file not found" | |
| exit 1 | |
| fi | |
| if [ ! -f "dist/index.d.ts" ]; then | |
| echo "Build failed: type definitions not found" | |
| exit 1 | |
| fi | |
| echo "✅ Build verification passed" | |
| - name: Check package.json | |
| run: | | |
| node -e " | |
| const pkg = require('./package.json'); | |
| if (!pkg.name) throw new Error('Package name is required'); | |
| if (!pkg.version) throw new Error('Package version is required'); | |
| if (!pkg.main) throw new Error('Package main entry is required'); | |
| if (!pkg.types) throw new Error('Package types entry is required'); | |
| if (!pkg.files || !pkg.files.includes('dist')) throw new Error('Package files must include dist'); | |
| console.log('✅ Package.json validation passed'); | |
| " | |
| - name: Dry run publish | |
| run: npm publish --dry-run | |
| security: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run security audit | |
| run: npm audit --audit-level=moderate | |
| - name: Check for known vulnerabilities | |
| run: npm audit --audit-level=high --production |