name: Release VS Code Extension
# This workflow builds and releases the ExcelMcp VS Code extension
# Triggered by pushing tags matching 'vscode-v*'
on:
push:
tags:
- 'vscode-v*'
jobs:
release-vscode-extension:
runs-on: windows-latest
permissions:
contents: write
issues: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.x
- name: Update MCP Server Version
run: |
$tagName = "${{ github.ref_name }}"
$version = $tagName -replace '^vscode-v', ''
Write-Output "Updating MCP Server to version $version for bundled executable"
# Update MCP Server project version
$mcpCsprojPath = "src/ExcelMcp.McpServer/ExcelMcp.McpServer.csproj"
$mcpContent = Get-Content $mcpCsprojPath -Raw
$mcpContent = $mcpContent -replace '<Version>[\d\.]+</Version>', "<Version>$version</Version>"
$mcpContent = $mcpContent -replace '<AssemblyVersion>[\d\.]+\.[\d\.]+</AssemblyVersion>', "<AssemblyVersion>$version.0</AssemblyVersion>"
$mcpContent = $mcpContent -replace '<FileVersion>[\d\.]+\.[\d\.]+</FileVersion>', "<FileVersion>$version.0</FileVersion>"
Set-Content $mcpCsprojPath $mcpContent
Write-Output "Updated MCP Server project to version $version"
shell: pwsh
- name: Update Extension Version
run: |
$tagName = "${{ github.ref_name }}"
$version = $tagName -replace '^vscode-v', ''
Write-Output "Updating VS Code extension to version $version"
# Update package.json version
cd vscode-extension
npm version "$version" --no-git-tag-version
# Update CHANGELOG.md - replace [Unreleased] with the new version and date
$date = Get-Date -Format 'yyyy-MM-dd'
$changelogPath = 'CHANGELOG.md'
$changelogContent = Get-Content $changelogPath -Raw
$changelogContent = $changelogContent -replace '## \[Unreleased\]', "## [$version] - $date"
Set-Content $changelogPath $changelogContent -NoNewline
Write-Output "Updated extension version to $version"
Write-Output "Updated CHANGELOG.md: [Unreleased] -> [$version] - $date"
"PACKAGE_VERSION=$version" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
shell: pwsh
- name: Install Dependencies
run: |
cd vscode-extension
npm install
- name: Build and Package Extension
run: |
cd vscode-extension
# Run the package script which does: build:mcp-server + vsce package
npm run package
env:
# Application Insights connection string is embedded at build time by MSBuild
# See ExcelMcp.McpServer.csproj for the GenerateTelemetryConfig target
APPINSIGHTS_CONNECTION_STRING: ${{ secrets.APPINSIGHTS_CONNECTION_STRING }}
- name: Prepare VSIX
run: |
cd vscode-extension
$version = "${{ env.PACKAGE_VERSION }}"
# vsce creates filename based on package.json name (excel-mcp)
$actualVsix = Get-ChildItem -Path . -Filter "*.vsix" -File | Select-Object -First 1
if (-not $actualVsix) {
Write-Error "No VSIX file found"
exit 1
}
$targetName = "excelmcp-$version.vsix"
if ($actualVsix.Name -ne $targetName) {
Rename-Item $actualVsix.FullName -NewName $targetName
Write-Output "Renamed $($actualVsix.Name) to $targetName"
} Write-Output "Created $targetName"
Get-Item $targetName | Format-Table Name, Length
"VSIX_PATH=vscode-extension/$targetName" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
shell: pwsh
- name: Publish to VS Code Marketplace
uses: HaaLeo/publish-vscode-extension@v2
with:
pat: ${{ secrets.VSCE_TOKEN }}
registryUrl: https://marketplace.visualstudio.com
extensionFile: ${{ env.VSIX_PATH }}
continue-on-error: true
id: publishToMarketplace
- name: Extract Changelog for Version
id: extract-changelog
run: |
$version = "${{ env.PACKAGE_VERSION }}"
$changelogPath = "vscode-extension/CHANGELOG.md"
Write-Output "Extracting changelog entries for version $version..."
# Read the changelog file
$content = Get-Content $changelogPath -Raw
# Extract the section for this version (from ## [version] to next ## or end)
$pattern = "(?s)## \[$version\][^\n]*\n(.*?)(?=\n## \[|$)"
if ($content -match $pattern) {
$versionChanges = $matches[1].Trim()
Write-Output "Found changelog entry for $version"
# Save to environment file for next step
# Use a delimiter for multiline content
$delimiter = "EOF_CHANGELOG"
"CHANGELOG_CONTENT<<$delimiter" | Out-File -FilePath $env:GITHUB_ENV -Append
$versionChanges | Out-File -FilePath $env:GITHUB_ENV -Append
$delimiter | Out-File -FilePath $env:GITHUB_ENV -Append
} else {
Write-Output "No specific changelog entry found for $version, using generic message"
"CHANGELOG_CONTENT=See CHANGELOG.md for details" | Out-File -FilePath $env:GITHUB_ENV -Append
}
shell: pwsh
- name: Create GitHub Release
run: |
$tagName = "${{ github.ref_name }}"
$version = "${{ env.PACKAGE_VERSION }}"
$vsixFile = "${{ env.VSIX_PATH }}"
$changelogContent = "${{ env.CHANGELOG_CONTENT }}"
$marketplaceStatus = "Not published"
if ("${{ steps.publishToMarketplace.outcome }}" -eq "success") {
$marketplaceStatus = "Published to VS Code Marketplace"
}
$notes = "## ExcelMcp VS Code Extension $tagName`n`n"
# Add changelog content at the top
$notes += "### What's New`n`n"
$notes += "$changelogContent`n`n"
$notes += "### One-Click Excel MCP Server Installation for VS Code`n`n"
$notes += "This extension automatically registers the ExcelMcp MCP server with VS Code.`n`n"
$notes += "### Installation Options`n`n"
$notes += "**Option 1: VS Code Marketplace** - Search for ExcelMcp and click Install`n"
$notes += "**Option 2: Manual VSIX** - Download excelmcp-$version.vsix below and install via VS Code`n`n"
$notes += "### Publishing Status: $marketplaceStatus`n`n"
$notes += "### Key Features`n"
$notes += "- Zero Configuration - Automatic MCP server registration`n"
$notes += "- Automatic .NET Installation`n"
$notes += "- Bundled MCP Server`n"
$notes += "- Works in all VS Code workspaces`n"
$notes += "- 12 Excel Tools with 180 operations`n`n"
$notes += "### Requirements`n"
$notes += "- Windows OS`n"
$notes += "- Microsoft Excel 2016+`n"
$notes += "- VS Code 1.105.0+`n"
$notes += "- .NET 10 Runtime (auto-installed by extension)`n`n"
$notes += "### Documentation`n"
$notes += "- [Full Changelog](https://github.com/sbroenne/mcp-server-excel/blob/main/vscode-extension/CHANGELOG.md)`n"
$notes += "- [Installation Guide](https://github.com/sbroenne/mcp-server-excel/blob/main/vscode-extension/INSTALL.md)`n"
$notes += "- [Main Repository](https://github.com/sbroenne/mcp-server-excel)`n"
$notes | Out-File -FilePath "release_notes.md" -Encoding utf8
gh release create "$tagName" "$vsixFile" --title "ExcelMcp VS Code Extension $tagName" --notes-file release_notes.md
Write-Output "Released ExcelMcp VS Code Extension $version"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: pwsh