Skip to content

Publish VS Code Extension #24

Publish VS Code Extension

Publish VS Code Extension #24

name: Publish VS Code Extension
on:
workflow_dispatch:
inputs:
releaseChannel:
description: "Release Channel"
required: true
type: choice
default: edge
options:
- stable
- edge
workflow_run:
workflows: ["CD"]
types:
- completed
branches:
- main
permissions: {}
defaults:
run:
shell: bash
working-directory: ./vscode
jobs:
publish-latest-vscode-extension:
name: Publish Latest VS Code Extension
runs-on: ubuntu-latest
# we are very restrictive when this runs, i.e. only on main, only on success and only with the bazel-eclipse repository (not on forks)
if: >
( !github.event.workflow_run ||
( github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.event != 'pull_request' )
) &&
github.repository == 'eclipseguru/bazel-eclipse' &&
github.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Get Time for BUILD_ID
id: time
uses: nanzm/[email protected]
with:
format: "YYYYMMDD_HHmm"
- name: Get Branch name for BUILD_LABEL
id: branch_name
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
- name: Setup Node version
uses: actions/setup-node@v6
with:
cache: 'npm'
cache-dependency-path: 'vscode/package-lock.json'
node-version-file: 'vscode/package.json'
- name: 📦 Install dependencies
run: |
npm ci
npm install -g vsce
- name: Download Bazel JDT Language Server extension
run: node scripts/index.mjs download-server
- name: 🏗 Build project
env:
BUILD_ID: "${{ steps.time.outputs.time }}"
BUILD_TYPE: "S"
BUILD_LABEL: "CI ${{ steps.time.outputs.time }} (${{ steps.branch_name.outputs.branch }})"
run: npm run vscode:prepublish
- name: 📦 Prepare packaging of pre-release extension
if: ${{ github.event.workflow_run || github.event.inputs.releaseChannel == 'edge' }}
run: node scripts/index.mjs prepare-pre-release
- name: 🚀 Publish to Visual Studio Marketplace
uses: HaaLeo/publish-vscode-extension@v2
id: publishToVscMktp
with:
packagePath: ./vscode
preRelease: ${{ github.event.workflow_run && true || github.event.inputs.releaseChannel == 'edge' && true || false }}
pat: ${{ secrets.VSC_MKTP_TOKEN }}
registryUrl: https://marketplace.visualstudio.com
- name: 🚀 Publish to Open VSX Registry
uses: HaaLeo/publish-vscode-extension@v2
with:
packagePath: ./vscode
preRelease: ${{ github.event.workflow_run && true || github.event.inputs.releaseChannel == 'edge' && true || false }}
pat: ${{ secrets.OPEN_VSX_TOKEN }}
extensionFile: ${{ steps.publishToVscMktp.outputs.vsixPath }}