2.1.1 #14
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
| # Comprehensive CI/CD workflow for automated testing and publishing | |
| # Runs tests on PRs and pushes, publishes on releases | |
| name: CI/CD Pipeline | |
| on: | |
| push: | |
| branches: [ main, master, develop ] | |
| pull_request: | |
| branches: [ main, master, develop ] | |
| release: | |
| types: [ created ] | |
| env: | |
| NODE_VERSION_MATRIX: '[18, 20, 21]' | |
| jobs: | |
| # Quality checks and testing | |
| test: | |
| name: Test & Quality Checks | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| node-version: [18, 20, 21] | |
| 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: Check code formatting | |
| run: npm run format:check | |
| - name: Run unit tests | |
| run: npm run test:unit | |
| - name: Run integration tests | |
| run: npm run test:integration | |
| - name: Run test coverage | |
| run: npm run test:coverage | |
| if: matrix.node-version == 20 | |
| - name: Upload coverage reports | |
| uses: codecov/codecov-action@v3 | |
| if: matrix.node-version == 20 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| fail_ci_if_error: false | |
| # Build verification | |
| build: | |
| name: Build Verification | |
| runs-on: ubuntu-latest | |
| needs: test | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build project | |
| run: npm run build | |
| - name: Test CLI functionality | |
| run: | | |
| node dist/cli.js --help | |
| node dist/cli.js --version | |
| node dist/cli.js --format json > test-output.json | |
| test -s test-output.json | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: dist-files | |
| path: dist/ | |
| retention-days: 7 | |
| # Security audit | |
| security: | |
| name: Security Audit | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run security audit | |
| run: npm audit --audit-level=moderate | |
| - name: Check for known vulnerabilities | |
| run: npx audit-ci --moderate | |
| continue-on-error: true | |
| # Publish to npm (only on releases) | |
| publish: | |
| name: Publish to NPM | |
| runs-on: ubuntu-latest | |
| needs: [test, build, security] | |
| if: github.event_name == 'release' && github.event.action == 'created' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| registry-url: https://registry.npmjs.org/ | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build project | |
| run: npm run build | |
| - name: Verify package contents | |
| run: | | |
| npm pack --dry-run | |
| npm pack | |
| tar -tzf *.tgz | |
| - name: Publish to NPM | |
| run: npm publish --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Create GitHub release assets | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: '*.tgz' | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # Notify on workflow completion | |
| notify: | |
| name: Notify Results | |
| runs-on: ubuntu-latest | |
| needs: [test, build, security] | |
| if: always() && (github.event_name == 'push' || github.event_name == 'release') | |
| steps: | |
| - name: Notify success | |
| if: needs.test.result == 'success' && needs.build.result == 'success' && needs.security.result == 'success' | |
| run: echo "✅ All checks passed successfully!" | |
| - name: Notify failure | |
| if: needs.test.result == 'failure' || needs.build.result == 'failure' || needs.security.result == 'failure' | |
| run: | | |
| echo "❌ Some checks failed:" | |
| echo "Test: ${{ needs.test.result }}" | |
| echo "Build: ${{ needs.build.result }}" | |
| echo "Security: ${{ needs.security.result }}" |