From 55602b16f2cccb4168df53124aff42ebfa204573 Mon Sep 17 00:00:00 2001 From: GeWuYou <95328647+GeWuYou@users.noreply.github.com> Date: Thu, 2 Apr 2026 21:42:46 +0800 Subject: [PATCH] =?UTF-8?q?chore(workflow):=20=E6=BF=80=E6=B4=BB=20VS=20Co?= =?UTF-8?q?de=20=E6=89=A9=E5=B1=95=E5=8F=91=E5=B8=83=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E6=B5=81=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除注释符号以启用工作流定义 - 恢复完整的 GitHub Actions 工作流配置 - 保留所有扩展版本发布和包管理功能 - 维持 Node.js 和 Bun 环境设置步骤 - 保持 VSIX 包生成和市场发布的完整流程 --- .../workflows/publish-vscode-extension.yml | 188 +++++++++--------- 1 file changed, 94 insertions(+), 94 deletions(-) diff --git a/.github/workflows/publish-vscode-extension.yml b/.github/workflows/publish-vscode-extension.yml index faf5379d..e83d0612 100644 --- a/.github/workflows/publish-vscode-extension.yml +++ b/.github/workflows/publish-vscode-extension.yml @@ -1,94 +1,94 @@ -#name: Publish VS Code Extension -# -#on: -# workflow_dispatch: -# inputs: -# version: -# description: Extension version to publish, for example 0.1.0. Leave empty to use package.json or the pushed tag. -# required: false -# type: string -# publish_to_marketplace: -# description: Publish to the Visual Studio Marketplace after packaging. -# required: true -# type: boolean -# default: true -# push: -# tags: -# - 'gframework-config-tool-v*' -# -#permissions: -# contents: read -# -#jobs: -# publish: -# name: Package And Publish Marketplace Extension -# runs-on: ubuntu-latest -# -# defaults: -# run: -# working-directory: tools/gframework-config-tool -# -# steps: -# - name: Checkout repository -# uses: actions/checkout@v6 -# with: -# fetch-depth: 0 -# -# - name: Setup Node.js 20 -# uses: actions/setup-node@v5 -# with: -# node-version: 20 -# -# - name: Setup Bun -# uses: oven-sh/setup-bun@v2 -# with: -# bun-version: 1.2.15 -# -# - name: Determine extension version -# id: version -# shell: bash -# run: | -# set -euo pipefail -# -# PACKAGE_VERSION=$(node -p "require('./package.json').version") -# VERSION="${PACKAGE_VERSION}" -# -# if [[ "${GITHUB_REF:-}" == refs/tags/gframework-config-tool-v* ]]; then -# VERSION="${GITHUB_REF#refs/tags/gframework-config-tool-v}" -# elif [[ -n "${{ inputs.version || '' }}" ]]; then -# VERSION="${{ inputs.version }}" -# fi -# -# echo "Resolved extension version: ${VERSION}" -# echo "version=${VERSION}" >> "${GITHUB_OUTPUT}" -# -# - name: Install extension dependencies -# run: bun install -# -# - name: Synchronize package.json version -# shell: bash -# run: | -# set -euo pipefail -# node -e "const fs=require('fs'); const path='package.json'; const data=JSON.parse(fs.readFileSync(path,'utf8')); data.version='${{ steps.version.outputs.version }}'; fs.writeFileSync(path, JSON.stringify(data, null, 2) + '\n');" -# -# - name: Run extension tests -# run: bun run test -# -# - name: Package VSIX -# run: | -# set -euo pipefail -# mkdir -p ../../artifacts -# bun run package:vsix -- --out "../../artifacts/gframework-config-tool-${{ steps.version.outputs.version }}.vsix" -# -# - name: Upload VSIX artifact -# uses: actions/upload-artifact@v7 -# with: -# name: gframework-config-tool-vsix -# path: artifacts/gframework-config-tool-${{ steps.version.outputs.version }}.vsix -# if-no-files-found: error -# -# - name: Publish to Visual Studio Marketplace -# if: github.event_name == 'push' || inputs.publish_to_marketplace -# env: -# VSCE_PAT: ${{ secrets.VSCE_PAT }} -# run: bun run publish:marketplace +name: Publish VS Code Extension + +on: + workflow_dispatch: + inputs: + version: + description: Extension version to publish, for example 0.1.0. Leave empty to use package.json or the pushed tag. + required: false + type: string + publish_to_marketplace: + description: Publish to the Visual Studio Marketplace after packaging. + required: true + type: boolean + default: true + push: + tags: + - 'gframework-config-tool-v*' + +permissions: + contents: read + +jobs: + publish: + name: Package And Publish Marketplace Extension + runs-on: ubuntu-latest + + defaults: + run: + working-directory: tools/gframework-config-tool + + steps: + - name: Checkout repository + uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: Setup Node.js 20 + uses: actions/setup-node@v5 + with: + node-version: 20 + + - name: Setup Bun + uses: oven-sh/setup-bun@v2 + with: + bun-version: 1.2.15 + + - name: Determine extension version + id: version + shell: bash + run: | + set -euo pipefail + + PACKAGE_VERSION=$(node -p "require('./package.json').version") + VERSION="${PACKAGE_VERSION}" + + if [[ "${GITHUB_REF:-}" == refs/tags/gframework-config-tool-v* ]]; then + VERSION="${GITHUB_REF#refs/tags/gframework-config-tool-v}" + elif [[ -n "${{ inputs.version || '' }}" ]]; then + VERSION="${{ inputs.version }}" + fi + + echo "Resolved extension version: ${VERSION}" + echo "version=${VERSION}" >> "${GITHUB_OUTPUT}" + + - name: Install extension dependencies + run: bun install + + - name: Synchronize package.json version + shell: bash + run: | + set -euo pipefail + node -e "const fs=require('fs'); const path='package.json'; const data=JSON.parse(fs.readFileSync(path,'utf8')); data.version='${{ steps.version.outputs.version }}'; fs.writeFileSync(path, JSON.stringify(data, null, 2) + '\n');" + + - name: Run extension tests + run: bun run test + + - name: Package VSIX + run: | + set -euo pipefail + mkdir -p ../../artifacts + bun run package:vsix -- --out "../../artifacts/gframework-config-tool-${{ steps.version.outputs.version }}.vsix" + + - name: Upload VSIX artifact + uses: actions/upload-artifact@v7 + with: + name: gframework-config-tool-vsix + path: artifacts/gframework-config-tool-${{ steps.version.outputs.version }}.vsix + if-no-files-found: error + + - name: Publish to Visual Studio Marketplace + if: github.event_name == 'push' || inputs.publish_to_marketplace + env: + VSCE_PAT: ${{ secrets.VSCE_PAT }} + run: bun run publish:marketplace