GFramework/.github/workflows/publish-vscode-extension.yml
GeWuYou 4c6deb4097 feat(vscode-extension): 添加 GFramework 配置工具扩展
- 创建 VS Code 扩展用于浏览、验证和编辑 GFramework 项目的配置文件
- 实现配置文件浏览器视图和相关命令功能
- 添加 YAML 文件和匹配模式文件的打开功能
- 实现嵌套对象字段的轻量级表单预览功能
- 添加批量编辑配置域的功能
- 集成轻量级模式验证支持
- 创建 GitHub Actions 工作流用于打包和发布扩展
- 配置扩展的激活事件和菜单贡献点
- 设置工作区配置选项用于指定配置和模式路径
2026-04-01 22:58:47 +08:00

95 lines
2.8 KiB
YAML

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/vscode-config-extension
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