diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..a82b54f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,65 @@ +name: CI + +on: + schedule: + - cron: "0 0 * * *" + push: + branches: + - "main" + tags: ["v[0-9]+.[0-9]+.[0-9]+"] + pull_request: + branches: + - "main" + + workflow_dispatch: + inputs: + logLevel: + description: "Log level" + required: true + default: "warning" + type: choice + options: + - info + - warning + - debug + +jobs: + test: + runs-on: ubuntu-latest + name: Run unit and integration tests + strategy: + matrix: + version: [18, 20] + steps: + - uses: actions/checkout@v4 + - name: Using Node.js ${{ matrix.version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.version }} + - name: Install dependencies + run: npm install + - name: Run tests + run: npm test + + build_and_publish: + needs: [test] + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags') + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 20 + registry-url: "https://registry.npmjs.org" + + - name: Install dependencies + run: npm install + + - name: Build + run: npm run build + + - name: Publish + run: npm publish + env: + NPM_PUBLISH_TOKEN: ${{ secrets.NPM_TOKEN }}