@@ -328,6 +328,33 @@ jobs:
328328 - name : Checkout code
329329 uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
330330
331+ - name : Check marketplace version
332+ run : |
333+ LOCAL_VERSION="${{ needs.release.outputs.version }}"
334+ echo "Local version: $LOCAL_VERSION"
335+
336+ MARKETPLACE_VERSION=$(curl -s -X POST \
337+ "https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery?api-version=3.0-preview.1" \
338+ -H "Content-Type: application/json" \
339+ -H "Accept: application/json;api-version=3.0-preview.1" \
340+ -d '{"filters":[{"criteria":[{"filterType":7,"value":"RobBos.copilot-token-tracker"}]}],"flags":512}' \
341+ | jq -r '.results[0].extensions[0].versions[0].version // empty')
342+
343+ if [ -z "$MARKETPLACE_VERSION" ]; then
344+ echo "⚠️ Could not retrieve marketplace version — proceeding with publish."
345+ exit 0
346+ fi
347+
348+ echo "Marketplace version: $MARKETPLACE_VERSION"
349+
350+ if [ "$LOCAL_VERSION" == "$MARKETPLACE_VERSION" ]; then
351+ echo "❌ Version $LOCAL_VERSION is already published on the VS Code Marketplace."
352+ echo " Bump the version in vscode-extension/package.json before publishing."
353+ exit 1
354+ fi
355+
356+ echo "✅ Version check passed: $LOCAL_VERSION is newer than marketplace $MARKETPLACE_VERSION"
357+
331358 - name : Setup Node.js
332359 uses : actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
333360 with :
@@ -504,7 +531,7 @@ jobs:
504531 if : github.event_name == 'workflow_dispatch' && inputs.publish_marketplace == true
505532 shell : pwsh
506533 env :
507- VS_MARKETPLACE_PAT : ${{ secrets.VS_MARKETPLACE_PAT }}
534+ VS_MARKETPLACE_PAT : ${{ secrets.VSCE_PAT }} # same one for the VSCode Marketplace works for Visual Studio Marketplace as well
508535 run : |
509536 if (-not $env:VS_MARKETPLACE_PAT) {
510537 Write-Error "❌ VS_MARKETPLACE_PAT secret is not configured."
0 commit comments