name: VS Code extension
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
publish:
description: 'Publish the packages (otherwise only build them)'
type: boolean
default: false
jobs:
package:
name: Package ${{ matrix.vsce_target }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
rust_target: x86_64-unknown-linux-musl
vsce_target: linux-x64
exe: gridmcp
- os: windows-latest
rust_target: x86_64-pc-windows-msvc
vsce_target: win32-x64
exe: gridmcp.exe
- os: macos-latest
rust_target: aarch64-apple-darwin
vsce_target: darwin-arm64
exe: gridmcp
steps:
- uses: actions/checkout@v4
- name: Fetch benchmark-grids
if: runner.os == 'Linux'
run: git submodule update --init --depth 1 tests/data/benchmark-grids
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.rust_target }}
- name: Install musl tools
if: contains(matrix.rust_target, 'musl')
run: sudo apt-get update && sudo apt-get install -y musl-tools
- uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-${{ matrix.rust_target }}-cargo-vscode-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-${{ matrix.rust_target }}-cargo-vscode-
- name: Build gridmcp
run: cargo build --release -p gridoxide-mcp --target ${{ matrix.rust_target }}
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Check extension version matches the workspace
shell: bash
run: |
crate=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)
ext=$(node -p "require('./editors/vscode/package.json').version")
if [ "$crate" != "$ext" ]; then
echo "editors/vscode/package.json is $ext, the workspace is $crate" >&2
exit 1
fi
- name: Package
shell: bash
working-directory: editors/vscode
run: |
mkdir -p server
cp ../../target/${{ matrix.rust_target }}/release/${{ matrix.exe }} server/
npm ci
npx vsce package --target ${{ matrix.vsce_target }}
- name: Smoke test
if: runner.os == 'Linux'
working-directory: editors/vscode
run: xvfb-run -a npm test
- uses: actions/upload-artifact@v4
with:
name: vsix-${{ matrix.vsce_target }}
path: editors/vscode/*.vsix
publish:
name: Publish
needs: package
if: startsWith(github.ref, 'refs/tags/') || inputs.publish
runs-on: ubuntu-latest
environment: vscode-release
steps:
- uses: actions/download-artifact@v4
with:
pattern: vsix-*
merge-multiple: true
- uses: actions/setup-node@v4
with:
node-version: 20
- name: Publish to the Visual Studio Marketplace
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
run: npx --yes @vscode/vsce@3 publish --skip-duplicate --packagePath *.vsix
- name: Publish to Open VSX
env:
OVSX_PAT: ${{ secrets.OVSXAT }}
run: npx --yes ovsx@0 publish --skip-duplicate --packagePath *.vsix