From 98db8e304da658cc2261ad021bf6b5418770d2b3 Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 4 Nov 2024 15:55:08 +0800 Subject: [PATCH] Add ci yml --- .github/workflows/publish.yaml | 26 ++++++++++++++++++++++++++ .github/workflows/test.yaml | 22 ++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 .github/workflows/publish.yaml create mode 100644 .github/workflows/test.yaml diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..f1c6ed5 --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,26 @@ +name: Publish + +on: + release: + types: [published] + +jobs: + publish: + name: "Publish to npm registry" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: '18.17.0' + + - run: | + npm ci + npm test + + - uses: JS-DevTools/npm-publish@4b07b26a2f6e0a51846e1870223e545bae91c552 + if: github.event_name == 'release' + with: + token: ${{ secrets.NPM_PUBLISH_FOR_PUBLIC_REPO }} + registry: "https://registry.npmjs.org" + diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..77ae43c --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,22 @@ +name: test +run-name: ${{ github.actor }} - test +on: [pull_request, push] +jobs: + test: + strategy: + fail-fast: false + matrix: + os: [windows-latest, macos-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '18.17.0' + + - run: | + node --version + npm --version + npm ci + npm run build + npm test