Skip to content

Commit 6a5cd0a

Browse files
committed
chore: 新增发布 npm 包的工作流
1 parent 50ca4ca commit 6a5cd0a

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

.github/workflows/npm-publish.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
3+
# 在创建 release 后自动发布 npm 包
4+
5+
6+
name: Node.js Package
7+
8+
on:
9+
release:
10+
types: [created]
11+
12+
jobs:
13+
build:
14+
name: 编译文件
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v2
18+
- uses: actions/setup-node@v1
19+
with:
20+
node-version: 12
21+
- run: npm i
22+
- run: npm lint
23+
- run: npm run build
24+
- run: npm run dev
25+
26+
publish-npm:
27+
name: 发布到 npm
28+
needs: build
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v2
32+
- uses: actions/setup-node@v1
33+
with:
34+
node-version: 12
35+
registry-url: https://registry.npmjs.org/
36+
- run: npm publish
37+
env:
38+
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
39+
40+
publish-gpr:
41+
name: 发布到 github pkg
42+
needs: build
43+
runs-on: ubuntu-latest
44+
steps:
45+
- uses: actions/checkout@v2
46+
- uses: actions/setup-node@v1
47+
with:
48+
node-version: 12
49+
registry-url: https://npm.pkg.github.com/
50+
- run: npm publish
51+
env:
52+
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

0 commit comments

Comments
 (0)