Initial commit #1
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
name: Release and Publish # 发布和发布的工作流程名称 | |
on: | |
push: | |
branches: | |
- main # 仅当推送到 main 分支时触发 | |
permissions: | |
contents: write # 设置内容的权限为写 | |
pull-requests: write # 设置拉取请求的权限为写 | |
jobs: | |
release-please: | |
# 设置工作流程运行环境为 Ubuntu | |
runs-on: ubuntu-latest | |
steps: | |
# 使用 release-please-action@v3 动作 | |
- uses: google-github-actions/release-please-action@v3 | |
id: release | |
with: | |
# 设置发布类型为 Node.js | |
release-type: node | |
# 设置包名 | |
package-name: karin-plugin-template-ts | |
# 设置发起PR的默认分支 | |
default-branch: main | |
# 检出代码 | |
- uses: actions/checkout@v4 | |
if: ${{ steps.release.outputs.release_created }} | |
# 设置 Node.js 环境 | |
- uses: actions/setup-node@v4 | |
with: | |
# 设置 Node.js 版本 | |
node-version: 20 | |
# 设置 npm 注册表 URL | |
registry-url: "https://registry.npmjs.org" | |
if: ${{ steps.release.outputs.release_created }} | |
# 添加node-karin并安装依赖 | |
- run: npm install --save-dev node-karin && npm install | |
if: ${{ steps.release.outputs.release_created }} | |
# 编译 | |
- run: npm run build | |
if: ${{ steps.release.outputs.release_created }} | |
# 安装jq工具 删除开发依赖 | |
- run: sudo apt-get install jq && jq 'del(.devDependencies)' package.json > package.json.tmp && mv package.json.tmp package.json | |
if: ${{ steps.release.outputs.release_created }} | |
# 发布带npm | |
- run: npm run pub | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
if: ${{ steps.release.outputs.release_created }} |