chore: comment #23
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: Build plugin | |
| on: | |
| push: | |
| branches: [main, master] | |
| tags: ['**'] | |
| pull_request: | |
| branches: [main, master] | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| name: Build Plugin | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: checkout repo | |
| uses: actions/checkout@v4 | |
| - name: env use node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| - name: build | |
| run: | | |
| npm install | |
| npm run build | |
| - name: upload build artifact | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: plugin-build | |
| path: | | |
| dist/main.js | |
| create-release: | |
| name: Create Release | |
| if: github.event_name == 'push' # no pr | |
| needs: [build] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # 允许无需 PAT 创建 Release | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: ./dist | |
| - name: List downloaded artifacts | |
| run: | | |
| echo "Listing contents of ./dist:" | |
| ls -R ./dist | |
| - name: Create Release | |
| if: startsWith(github.ref, 'refs/tags/') | |
| uses: ncipollo/release-action@v1 | |
| with: | |
| # token: ${{ secrets.Your_token_secrets_name }} # PAT GitHub Token。可选一,换成你的PAT,否则报错: `Error: Error undefined: Parameter token or opts.auth is required` | |
| token: ${{ secrets.GITHUB_TOKEN }} # 内置 Github Token。可选二 | |
| name: 'Release ${{ github.ref_name }}' | |
| body: 'Release for tag ${{ github.ref_name }}' | |
| artifacts: | | |
| ./dist/plugin-build/main.js | |
| generateReleaseNotes: false # 自动根据 commits 生成 release notes。此外,这里应该导向一个更新日志页 | |
| prerelease: ${{ endsWith(github.ref_name, 'beta') }} # 是否预发布 | |
| makeLatest: ${{ !endsWith(github.ref_name, 'beta') }} # 是否最后一个版本 | |
| allowUpdates: true # 如果 tag 已存在,允许更新 |