Release #35
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 | |
on: | |
workflow_dispatch: | |
inputs: | |
release_type: | |
description: Type of release | |
required: true | |
type: choice | |
options: | |
- patch | |
- minor | |
- major | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write # 允许创建 GitHub Releases | |
packages: write # 允许发布 npm 包 | |
steps: | |
# 检出代码 | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: pnpm/action-setup@v4 | |
with: | |
run_install: false | |
# 设置 Node.js | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
registry-url: 'https://registry.npmjs.org/' | |
cache: pnpm | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
# 配置 Git 用户信息 | |
- name: Setup Git user info | |
run: | | |
git config --local user.name "github-actions[bot]" | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
- name: Install dependencies and build | |
run: | | |
pnpm install --frozen-lockfile | |
pnpm build | |
continue-on-error: false | |
- name: Run publish script | |
run: | | |
pnpm zx scripts/ci-publish.js ${{ github.event.inputs.release_type }} | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |