Skip to content

Publish Extension

Publish Extension #25

Workflow file for this run

name: Publish Extension
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Version to publish (e.g., 1.0.0)'
required: true
pre_release:
description: 'Mark this version as a pre-release'
required: false
default: true
type: boolean
jobs:
build:
name: Build and Publish Extension
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '14'
- name: Install Dependencies
run: npm install
- name: Compile TypeScript to Extension
run: npm run compile
- name: Set Version from Tag or Input and Determine Pre-Release Status
id: set_version
run: |
if [[ ${{ github.event_name }} == 'push' ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
elif [[ ${{ github.event_name }} == 'workflow_dispatch' ]]; then
VERSION=${{ github.event.inputs.version }}
fi
PRE_RELEASE='false'
if [[ "${{ github.event.inputs.pre_release }}" == 'true' ]] || [[ "$VERSION" == *"-SNAPSHOT"* ]]; then
PRE_RELEASE='true'
fi
VERSION=${VERSION//-SNAPSHOT/}
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "PRE_RELEASE=$PRE_RELEASE" >> $GITHUB_ENV
echo "::set-output name=version::$VERSION"
echo "::set-output name=pre_release::$PRE_RELEASE"
shell: bash
- name: Update version in package.json
run: |
jq '.version="${{ steps.set_version.outputs.version }}"' package.json > package.tmp.json && mv package.tmp.json package.json
shell: bash
- name: Package Extension
run: npx vsce package
- name: Publish to VS Code Marketplace
if: env.PRE_RELEASE == 'false'
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
run: npx vsce publish -p $VSCE_PAT
- name: Publish to VS Code Marketplace (Pre-release)
if: env.PRE_RELEASE == 'true'
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
run: npx vsce publish -p $VSCE_PAT --pre-release