chore(core): 初始化,实现功能 #1
This file contains hidden or 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
| name: npm publish # 定义工作流名称 | |
| on: | |
| workflow_dispatch: # 允许手动触发工作流,默认是不开启的 | |
| push: # 当有代码推送到仓库时触发 | |
| branches: | |
| - main | |
| jobs: | |
| build: # 工作流程中的一个作业 | |
| runs-on: ubuntu-latest # 指定运行作业的虚拟环境 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: enable pnpm | |
| run: corepack enable | |
| - name: install Dependencies | |
| run: | | |
| ls -al | |
| pnpm i | |
| pnpm build | |
| - name: Upload Build Artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: build-artifacts # 构建产物名称 | |
| path: ./dist # 构建产物路径 | |
| publish-npm: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| registry-url: https://registry.npmjs.org/ | |
| - name: Download Build Artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: build-artifacts # 构建产物名称,需与上传时的名称一致 | |
| path: ./ # 下载后存放路径 | |
| - name: List Build Directory | |
| run: ls -al ./ | |
| - name: Publish to NPM | |
| run: npm publish | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |