diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..422e240 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,44 @@ +name: CI + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '18' # Set the Node.js version + + - name: Install dependencies + run: npm install + + - name: Lint code + run: npm run lint + + - name: Format code + run: npm run format + + - name: Run tests + run: npm test + + - name: Generate test coverage report + run: npm run test -- --coverage + + - name: Publish to npm + if: github.ref == 'refs/heads/main' && github.event_name == 'push' + run: | + npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} + npm publish + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }}