Skip to content
Latchkey

How to Build and Publish a VS Code Extension in GitHub Actions

Publishing a VS Code extension by hand from a laptop drifts from the tagged source; CI ties the published version to the tag.

Install @vscode/vsce, run vsce package to produce a .vsix, then vsce publish with a Marketplace PAT on tag pushes.

Steps

  • Create a Marketplace Personal Access Token and store it as VSCE_PAT.
  • Install dependencies and build the extension.
  • Package with vsce package to verify the .vsix is valid.
  • Run vsce publish on tag pushes so the version matches the tag.

Workflow

.github/workflows/publish-extension.yml
name: Publish Extension
on:
  push:
    tags: ['v*']
jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: '20' }
      - run: npm ci
      - run: npm run compile
      - run: npx @vscode/vsce package
      - run: npx @vscode/vsce publish --pat ${{ secrets.VSCE_PAT }}
      - uses: actions/upload-artifact@v4
        with:
          name: vsix
          path: '*.vsix'

Notes

  • The package.json version must match the tag, or the Marketplace will reject a duplicate.
  • Upload the .vsix as an artifact so you can attach it to a GitHub Release.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →