From ff205a7d47ea78344e8e729a7aa179e0839dc7a2 Mon Sep 17 00:00:00 2001 From: Zhenglei Yang Date: Mon, 26 Aug 2024 16:54:04 +0800 Subject: [PATCH] Create npm-publish.yml --- .github/workflows/npm-publish.yml | 44 +++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .github/workflows/npm-publish.yml diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml new file mode 100644 index 0000000..5275754 --- /dev/null +++ b/.github/workflows/npm-publish.yml @@ -0,0 +1,44 @@ +name: Node.js Package + +on: + release: + types: [created] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: Install dependencies + run: npm ci + + - name: Run tests + run: npm test + + publish-npm: + needs: build + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + registry-url: https://registry.npmjs.org/ + + - name: Install dependencies + run: npm ci + + - name: Publish to npm + run: npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN }}