fix: scripts #8
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: release | |
| on: | |
| push: | |
| # 监听 main 分支的 push 事件 | |
| branches: | |
| - main | |
| # 赋予 release-please-action 权限 | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| # 设置 release-please 任务 | |
| release-please: | |
| # 设置任务运行环境为 ubuntu-latest | |
| runs-on: ubuntu-latest | |
| steps: | |
| # 使用 release-please-action 动作来自动创建发布 PR | |
| - uses: googleapis/release-please-action@v4 | |
| id: release | |
| with: | |
| # 设置发布类型为 node | |
| release-type: node | |
| # 检出代码 | |
| - uses: actions/checkout@v4 | |
| if: ${{ steps.release.outputs.release_created }} | |
| # 设置 Node.js 环境 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| # 设置 Node.js 版本 | |
| node-version: 20 | |
| # 设置 npm 源 | |
| registry-url: "https://registry.npmjs.org" | |
| # 安装依赖 | |
| - run: npm install | |
| if: ${{ steps.release.outputs.release_created }} | |
| # 下载编译完成的pty | |
| - run: npm run download | |
| if: ${{ steps.release.outputs.release_created }} | |
| # 构建输出 | |
| - run: npm run build | |
| if: ${{ steps.release.outputs.release_created }} | |
| # 增加install script | |
| - run: npm pkg set "scripts.install"="node lib/scripts/index.js" | |
| if: ${{ steps.release.outputs.release_created }} | |
| # 删除开发依赖 | |
| - run: npm pkg delete devDependencies | |
| if: ${{ steps.release.outputs.release_created }} | |
| # 发布到 npm | |
| - run: npm run pub | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| if: ${{ steps.release.outputs.release_created }} |