docs: 添加 tutorials 教程 #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
- run: npm run build | |
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 publish | |
env: | |
NODE_AUTH_TOKEN: ${{secrets.npm_token}} |