Skip to content

Auto Publish

Auto Publish #4

Workflow file for this run

# 工作流名称
name: Auto Publish
# 运行时显示的名称
run-name: Auto Publish
# 触发条件配置
on:
push:
tags:
- 'v*'
# 定义工作流中的作业
jobs:
build:
# 指定运行环境为最新版本的ubuntu
runs-on: ubuntu-latest
steps:
# 步骤1: 检出代码
- name: CheckOut Code
uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}
# 步骤2: 设置pnpm包管理器
- name: Setup pnpm
uses: pnpm/action-setup@v4
# 步骤3: 设置Node.js环境
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20 # 使用Node.js 20版本
registry-url: 'https://registry.npmjs.org' # 设置npm registry地址
# 步骤4: 获取pnpm缓存目录路径
- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT
# 步骤5: 配置pnpm缓存
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
# 使用操作系统类型和pnpm-lock.yaml的哈希值作为缓存键
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
# 步骤6: 安装项目依赖
- name: Install dependencies
run: pnpm i --no-frozen-lockfile
# 步骤7: 构建组件
- name: Run Build Components
run: pnpm build
# 步骤8: 发布组件到NPM
- name: Publish components
run: pnpm --filter @opentiny/tiny-vue-mcp publish --access=public --no-git-checks
env:
# 使用NPM令牌进行身份验证
NODE_AUTH_TOKEN: ${{ secrets.NPM_TINY_VUE_MCP_TOKEN }}
- name: Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref_name }}
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}