name: Release NPM Packages on: workflow_dispatch: inputs: package: description: '选择要发布的包' required: true type: choice options: - core - behavior-tree version: description: '版本号 (例如: 2.2.9 或 1.0.1)' required: true type: string permissions: contents: write pull-requests: write id-token: write jobs: release-package: name: Release ${{ github.event.inputs.package }} Package runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 token: ${{ secrets.GITHUB_TOKEN }} - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: '20.x' registry-url: 'https://registry.npmjs.org' cache: 'npm' - name: Install dependencies run: npm ci - name: Build core package (if needed) if: ${{ github.event.inputs.package == 'behavior-tree' }} run: | cd packages/core npm run build - name: Run tests run: | cd packages/${{ github.event.inputs.package }} npm run test:ci - name: Update version run: | cd packages/${{ github.event.inputs.package }} npm version ${{ github.event.inputs.version }} --no-git-tag-version - name: Build package run: | cd packages/${{ github.event.inputs.package }} npm run build:npm - name: Publish to npm env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} run: | cd packages/${{ github.event.inputs.package }}/dist npm publish - name: Create Pull Request uses: peter-evans/create-pull-request@v6 with: token: ${{ secrets.GITHUB_TOKEN }} commit-message: "chore(${{ github.event.inputs.package }}): release v${{ github.event.inputs.version }}" branch: release/${{ github.event.inputs.package }}-v${{ github.event.inputs.version }} delete-branch: true title: "chore(${{ github.event.inputs.package }}): Release v${{ github.event.inputs.version }}" body: | ## 🚀 Release v${{ github.event.inputs.version }} 此 PR 更新 `@esengine/${{ github.event.inputs.package }}` 包的版本号 ### 变更 - ✅ 已发布到 npm: [@esengine/${{ github.event.inputs.package }}@${{ github.event.inputs.version }}](https://www.npmjs.com/package/@esengine/${{ github.event.inputs.package }}/v/${{ github.event.inputs.version }}) - ✅ 更新 `packages/${{ github.event.inputs.package }}/package.json` → `${{ github.event.inputs.version }}` --- *此 PR 由发布工作流自动创建* labels: | release ${{ github.event.inputs.package }} automated pr