Release - Parallel Publishing #13
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: Release | |
| on: | |
| release: | |
| types: [published] | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # 允许上传文件到 Release | |
| actions: read # 允许读取 Actions 信息 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build extension | |
| run: npm run vscode:prepublish | |
| - name: Package extension | |
| id: package | |
| run: | | |
| # 从 package.json 中读取版本号 | |
| VERSION=$(node -p "require('./package.json').version") | |
| PACKAGE_NAME="xkcoding-api-navigator-v${VERSION}.vsix" | |
| npx @vscode/vsce package --out "${PACKAGE_NAME}" | |
| echo "package_name=${PACKAGE_NAME}" >> $GITHUB_OUTPUT | |
| echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
| - name: Publish to VSCode Marketplace | |
| env: | |
| VSCE_PAT: ${{ secrets.VSCE_PAT }} | |
| run: npx @vscode/vsce publish --packagePath ${{ steps.package.outputs.package_name }} | |
| - name: Publish to OpenVSX Registry | |
| env: | |
| OVSX_PAT: ${{ secrets.OVSX_PAT }} | |
| run: npx ovsx publish ${{ steps.package.outputs.package_name }} --pat $OVSX_PAT | |
| - name: Upload VSIX to release | |
| run: | | |
| gh release upload ${{ github.event.release.tag_name }} "${{ steps.package.outputs.package_name }}" --clobber | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |