Skip to content

Publish to VS Code Marketplace #12

Publish to VS Code Marketplace

Publish to VS Code Marketplace #12

Workflow file for this run

name: Publish to VS Code Marketplace
on:
workflow_dispatch:
inputs:
version:
description: 'Version to publish (e.g., 1.0.0)'
required: true
type: string
release_type:
description: 'Release type'
required: true
type: choice
options:
- 'release'
- 'pre-release'
default: 'release'
publish_to_openvsx:
description: 'Also publish to OpenVSX Registry (Cursor Marketplace)'
required: false
type: boolean
default: true
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write
actions: read
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Update version
run: |
echo "Updating version to ${{ github.event.inputs.version }}"
npm version ${{ github.event.inputs.version }} --no-git-tag-version
- name: Build project
run: npm run build
- name: Install VSCE and OVSX
run: |
npm install -g @vscode/vsce
npm install -g ovsx
- name: Package extension
run: |
if [ "${{ github.event.inputs.release_type }}" = "pre-release" ]; then
vsce package --pre-release
else
vsce package
fi
- name: Publish to VS Code Marketplace
run: |
if [ "${{ github.event.inputs.release_type }}" = "pre-release" ]; then
vsce publish --pre-release -p "$VSCE_TOKEN"
else
vsce publish -p "$VSCE_TOKEN"
fi
env:
VSCE_TOKEN: ${{ secrets.VSCE_TOKEN }}
- name: Publish to OpenVSX Registry (Cursor Marketplace)
if: github.event.inputs.publish_to_openvsx == 'true'
run: |
if [ "${{ github.event.inputs.release_type }}" = "pre-release" ]; then
ovsx publish --pre-release -p "$OVSX_TOKEN"
else
ovsx publish -p "$OVSX_TOKEN"
fi
env:
OVSX_TOKEN: ${{ secrets.OVSX_TOKEN }}
continue-on-error: true
- name: Create Git Tag (for releases only)
if: github.event.inputs.release_type == 'release'
uses: actions/github-script@v7
with:
script: |
const tag = `v${{ github.event.inputs.version }}`;
const ref = `refs/tags/${tag}`;
try {
await github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: ref,
sha: context.sha
});
console.log(`Created tag: ${tag}`);
} catch (error) {
console.log(`Tag ${tag} might already exist: ${error.message}`);
}
- name: Create GitHub Release (for releases only)
if: github.event.inputs.release_type == 'release'
uses: softprops/action-gh-release@v1
with:
tag_name: "v${{ github.event.inputs.version }}"
files: "*.vsix"
generate_release_notes: true
make_latest: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload VSIX artifact
uses: actions/upload-artifact@v4
with:
name: commit-assistant-${{ github.event.inputs.release_type }}-${{ github.event.inputs.version }}
path: "*.vsix"
retention-days: 90