-
Notifications
You must be signed in to change notification settings - Fork 0
46 lines (41 loc) · 1.34 KB
/
npm-publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
name: npm-publish
on:
# 通过推送或拉取主分支(main)事件触发工作流
push:
branches:
- main
# 这将启用“操作”选项卡上的“运行工作流”按钮
workflow_dispatch:
# 一个工作流中可以有一个或多个作业通过按顺序或者并行的方式执行。
jobs:
# 创建了一个名叫‘build’的作业
build:
# 指定了操作系统为‘ubuntu-latest’
runs-on: ubuntu-latest
# Steps 代表一系列任务作为作业的一部分而被执行
steps:
# 检查仓库以便作业能正常访问
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
cache: npm
# 执行多条脚本
- run: npm ci
- run: npm test
publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm run build
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}