Repository navigation
1.2.0 #21
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/CD Pipeline | |
| on: | |
| push: | |
| branches: [ master, main ] | |
| pull_request: | |
| branches: [ master, main ] | |
| release: | |
| types: [ published ] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| node-version: [14.x, 16.x, 18.x, 20.x] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Use 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 -- --quiet | |
| - name: Run tests | |
| run: npm test | |
| - name: Generate documentation | |
| run: npm run docs | |
| publish: | |
| needs: test | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'release' && github.ref == 'refs/tags/v*' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Use Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20.x' | |
| registry-url: 'https://registry.npmjs.org' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build package | |
| run: npm run build | |
| - name: Publish to npm | |
| run: npm publish | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| notify: | |
| needs: [test, publish] | |
| runs-on: ubuntu-latest | |
| if: always() | |
| steps: | |
| - name: Notify on success | |
| if: needs.test.result == 'success' && (needs.publish.result == 'success' || needs.publish.result == 'skipped') | |
| run: | | |
| echo "✅ All tests passed!" | |
| echo "🚀 Package is ready for production" | |
| - name: Notify on failure | |
| if: needs.test.result == 'failure' || needs.publish.result == 'failure' | |
| run: | | |
| echo "❌ Pipeline failed!" | |
| exit 1 |