DEV Community

Cover image for #DevHack: Publishing your Code Extensions from GitHub Actions
Elio Struyf
Elio Struyf

Posted on

2 2

#DevHack: Publishing your Code Extensions from GitHub Actions

Automation is key! That is how I think anyway. I'm not too fond of repetition, but for some reason, I had not yet automated my Visual Studio Code extension publishing. I always did this manually from my terminal by running vsce publish.

With my latest extension, I thought, now is the time to automate this as well.

Setting up your workflow

When publishing your Code extensions, you need to use the Visual Studio Code Extension command-line tool: vsce. Typically this is something you install locally by running npm i -g vsce.

In this case, we will do this on GitHub Actions instead, but before you can start, you need to create your Personal Access Token or also called PAT.

Important: Get your personal access token to publish to the VS Code Marketplace

When you got this PAT, add it as a GitHub Secret to your project.

PAT Secret in GitHub

We will use this secret in the GitHub Actions workflow which looks as follows:

name: Release
on:
  release:
    types:
      - published
  workflow_dispatch:

jobs:
  release:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: 14
          registry-url: https://registry.npmjs.org/

      - name: Install the dependencies
        run: npm i

      - name: Install vsce
        run: npm i -g vsce

      - name: Publish
        run: vsce publish -p ${{ secrets.VSCE_PAT }}
Enter fullscreen mode Exit fullscreen mode

Info: The GitHub Actions workflow gets triggered whenever you create and publish a new release. In the last step, the PAT will be used to publish your extension.

Important: Make sure to set the publisher to your account in the package.json file. For me, this is eliostruyf.

Article first published on eliostruyf.com

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (0)

The best way to debug slow web pages cover image

The best way to debug slow web pages

Tools like Page Speed Insights and Google Lighthouse are great for providing advice for front end performance issues. But what these tools can’t do, is evaluate performance across your entire stack of distributed services and applications.

Watch video

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay