Skip to content

Publish Extension

Publish Extension #13

Workflow file for this run

name: Publish Extension
on:
# Trigger when Semantic Release has published a new GitHub release (Release workflow completed)
workflow_run:
workflows: [Release]
types: [completed]
branches: [main]
# Also allow manual run and trigger on release UI events
release:
types: [published, created]
workflow_dispatch:
inputs:
version:
description: 'Version to publish (e.g., 1.0.0)'
required: false
jobs:
publish:
name: Publish to Marketplace
runs-on: ubuntu-latest
# When triggered by workflow_run, only run if Release workflow succeeded (a release was actually published)
if: github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success'
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v6
with:
# When triggered after Release, get latest main (with version bump and changelog)
ref: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_branch || github.ref }}
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version-file: '.nvmrc'
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10
- name: Get pnpm store directory
id: pnpm-store
shell: bash
run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Cache pnpm store
uses: actions/cache@v5
with:
path: ${{ steps.pnpm-store.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build extension
run: |
pnpm run compile
pnpm run webpack
- name: Package extension
run: pnpm run package
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
- name: Upload VSIX artifact
uses: actions/upload-artifact@v4
with:
name: extension-vsix
path: '*.vsix'
retention-days: 30
- name: Publish to Marketplace
# Publish when triggered by a release event or after Semantic Release (workflow_run); skip for manual workflow_dispatch
if: github.event_name == 'release' || github.event_name == 'workflow_run'
run: pnpm run publish
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}