ci: add github workflow4 #4
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: | |
| 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 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 | |
| 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.AnyBlockPro_Repo }} | |
| name: 'Release ${{ github.ref_name }}' | |
| body: 'Release for tag ${{ github.ref_name }}' | |
| artifacts: | | |
| ./dist/main.js | |
| generateReleaseNotes: false # 自动根据 commits 生成 release notes。此外,这里应该导向一个更新日志页 | |
| prerelease: true # 是否预发布 (可以在release上修改该项,我就不判断tag是否beta结尾了) | |
| makeLatest: false # 是否最后一个版本 (可以在release上修改该项,我就不判断tag是否beta结尾了) | |
| allowUpdates: true # 如果 tag 已存在,允许更新 |