Skip to content

Release and Publish VS Code Extension #9

Release and Publish VS Code Extension

Release and Publish VS Code Extension #9

Workflow file for this run

name: Release and Publish VS Code Extension
on:
workflow_dispatch:
inputs:
type:
type: choice
description: Type
options:
- release
- pre-release
default: pre-release
jobs:
release-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
- name: Install dependencies
run: npm install
- name: Install Visual Studio Code Extension Manager
run: npm install -g @vscode/vsce
- name: Set version
run: |
echo "VERSION=$(jq -r .version package.json)" >> $GITHUB_ENV
- name: Set changelog
env:
VERSION: ${{ env.VERSION }}
run: |
awk -v version="## ${VERSION}" '
$0 == version {flag=1; next}
/^## / && flag {flag=0}
flag
' CHANGELOG.md >"CHANGELOG-${VERSION}.md"
echo "CHANGELOG=CHANGELOG-${VERSION}.md" >> $GITHUB_ENV
- name: Package extension
env:
GH_TOKEN: ${{ secrets.github_token }}
VERSION: ${{ env.VERSION }}
CHANGELOG: ${{ env.CHANGELOG }}
run: |
if [ "${{ github.event.inputs.type }}" = "pre-release" ]; then
vsce package --pre-release
gh release create ${VERSION} ./quarto-wizard-${VERSION}.vsix --prerelease --title ${VERSION} --notes-file ${CHANGELOG} --generate-notes
else
vsce package
gh release create ${VERSION} ./quarto-wizard-${VERSION}.vsix --title ${VERSION} --notes-file ${CHANGELOG} --generate-notes
fi
- name: Publish extension to Visual Studio Marketplace
env:
VS_MARKETPLACE_TOKEN: ${{ secrets.VS_MARKETPLACE_TOKEN }}
run: |
if [ "${{ github.event.inputs.type }}" = "pre-release" ]; then
vsce publish --pre-release --pat ${VS_MARKETPLACE_TOKEN}
else
vsce publish --pat ${VS_MARKETPLACE_TOKEN}
fi
- name: Publish extension to Open VSX Registry
env:
OPEN_VSX_REGISTRY_TOKEN: ${{ secrets.OPEN_VSX_REGISTRY_TOKEN }}
run: |
npm install --global ovsx
if [ "${{ github.event.inputs.type }}" = "pre-release" ]; then
npx ovsx publish --pre-release --pat ${OPEN_VSX_REGISTRY_TOKEN}
else
npx ovsx publish --pat ${OPEN_VSX_REGISTRY_TOKEN}
fi