| 123456789101112131415161718192021222324252627282930313233343536373839 |
- # 当分支 main 有 push 事件并且此次 push 包含了 tag ,并且 tag 的格式为 v* 时,执行以下任务
- # 使用 GitHub Actions secrets 存储的 NPM_TOKEN 自动将本仓库 components 目录下的所有文件发布到 npm 上
- name: Auto publish npm
- on:
- push:
- branches:
- - main
- jobs:
- publish:
- runs-on: ubuntu-latest
- steps:
- - name: Checkout
- uses: actions/checkout@v2
- # 读取最新push的 tag 内容,如果是 v 开头,则往下执行,否则退出
- - name: Check tag
- run: |
- if [[ $GITHUB_REF != 'refs/tags/v'* ]]; then
- echo "This is not a tag push. Skipping."
- exit 78
- fi
- - name: Setup Node.js environment
- uses: actions/setup-node@v1
- with:
- node-version: 18.x
- - name: Publish
- run: |
- cd components
- npm config set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN
- npm publish
- env:
- CI: true
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|