release 2.0.1-beta #5
Workflow file for this run
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: Publish and Create Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| jobs: | |
| publish: | |
| name: Publish and Create Release | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # 确保有权创建 Release | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: 'npm' | |
| - name: Install Dependencies | |
| run: npm install | |
| - name: Build Code | |
| run: npm run compile | |
| - name: Install vsce | |
| run: npm install -g @vscode/vsce | |
| - name: Build VSIX | |
| run: | | |
| if [[ ${{ github.ref_name }} == *-* ]]; then | |
| echo "检测到先行版本标签,正在打包预发布版..." | |
| vsce package --pre-release -o ./extension.vsix | |
| else | |
| echo "检测到正式版本标签,正在打包正式版..." | |
| vsce package -o ./extension.vsix | |
| fi | |
| - name: Publish to Marketplace | |
| env: | |
| VSCE_PAT: ${{ secrets.VSCE_PAT }} | |
| run: | | |
| if [[ ${{ github.ref_name }} == *-* ]]; then | |
| echo "检测到先行版本标签,正在发布预发布版..." | |
| vsce publish --pre-release -p $VSCE_PAT --packagePath ./extension.vsix | |
| else | |
| echo "检测到正式版本标签,正在发布正式版..." | |
| vsce publish -p $VSCE_PAT --packagePath ./extension.vsix | |
| fi | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| # 自动根据两个 Tag 之间的 Commit 记录生成日志,非常省心 | |
| generate_release_notes: true | |
| # 如果 Tag 包含 '-',GitHub 界面会标记为 Pre-release | |
| prerelease: ${{ contains(github.ref_name, '-') }} | |
| files: | | |
| ./extension.vsix | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |