From 61a68fbd4176427da8d58944741f13d36e33149a Mon Sep 17 00:00:00 2001 From: xion Date: Sat, 28 Sep 2024 19:37:35 +0800 Subject: [PATCH] feat: add publish workflow --- .github/workflow/publish.yml | 35 +++++++++++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 .github/workflow/publish.yml diff --git a/.github/workflow/publish.yml b/.github/workflow/publish.yml new file mode 100644 index 0000000..ced819d --- /dev/null +++ b/.github/workflow/publish.yml @@ -0,0 +1,35 @@ +name: Publish to npm +on: + push: + tags: + - 'v*.*.*' # 当推送带有版本号的 tag 时触发,例如 v1.0.0 + +jobs: + publish: + runs-on: ubuntu-latest + steps: + # Step 1: Clone current Git repository + - name: Checkout this repository + uses: actions/checkout@v3 + # Setop 2: list files in current directory + - name: List files in current directory + run: ls -al + # Step 3: Setup Node.js and install dependencies + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: '20.6' + registry-url: 'https://registry.npmjs.org/' + - name: npm whoami + run: | + npm whoami + echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc + # Step 4: Install dependencies + - name: Install dependencies + run: npm install + # Step 5: Publish to npm + - name: Publish package + run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # 使用 GitHub Secrets 来安全存储 npm token + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} # 使用 GitHub Secrets 来安全存储 npm token \ No newline at end of file diff --git a/package.json b/package.json index d69213c..85ddef3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@kevisual/query", - "version": "0.0.3", + "version": "0.0.5", "main": "dist/index.js", "module": "dist/index.js", "types": "dist/index.d.ts",