Publish VS Code Extension workflow (BUPT-GAMMA/MASFactory)
The Publish VS Code Extension workflow from BUPT-GAMMA/MASFactory, explained and optimized by Latchkey.
CI health: B - good
Point runs-on at Latchkey and get job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the Publish VS Code Extension workflow from the BUPT-GAMMA/MASFactory repository, a real project running GitHub Actions. It is shown here with attribution under its Apache-2.0 license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
name: Publish VS Code Extension
on:
workflow_dispatch:
inputs:
target:
description: Publish target
required: true
default: both
type: choice
options:
- both
- vscode-marketplace
- open-vsx
dry_run:
description: Package only and skip actual publishing
required: true
default: false
type: boolean
permissions:
contents: read
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache-dependency-path: |
masfactory-visualizer/package-lock.json
masfactory-visualizer/webview-ui/package-lock.json
- name: Install extension dependencies
working-directory: masfactory-visualizer
run: npm ci
- name: Install webview dependencies
working-directory: masfactory-visualizer/webview-ui
run: npm ci
- name: Package VSIX
id: package_extension
uses: HaaLeo/publish-vscode-extension@v2
with:
pat: dry-run-token
packagePath: ./masfactory-visualizer
dryRun: true
- name: Upload VSIX artifact
uses: actions/upload-artifact@v4
with:
name: masfactory-visualizer-vsix
path: ${{ steps.package_extension.outputs.vsixPath }}
- name: Publish to Open VSX
if: ${{ !inputs.dry_run && (inputs.target == 'both' || inputs.target == 'open-vsx') }}
uses: HaaLeo/publish-vscode-extension@v2
with:
pat: ${{ secrets.OPEN_VSX_TOKEN }}
extensionFile: ${{ steps.package_extension.outputs.vsixPath }}
skipDuplicate: true
- name: Publish to Visual Studio Marketplace
if: ${{ !inputs.dry_run && (inputs.target == 'both' || inputs.target == 'vscode-marketplace') }}
uses: HaaLeo/publish-vscode-extension@v2
with:
pat: ${{ secrets.VS_MARKETPLACE_TOKEN }}
registryUrl: https://marketplace.visualstudio.com
extensionFile: ${{ steps.package_extension.outputs.vsixPath }}
skipDuplicate: true
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: Publish VS Code Extension on: workflow_dispatch: inputs: target: description: Publish target required: true default: both type: choice options: - both - vscode-marketplace - open-vsx dry_run: description: Package only and skip actual publishing required: true default: false type: boolean permissions: contents: read jobs: publish: timeout-minutes: 30 runs-on: latchkey-small steps: - name: Checkout source uses: actions/checkout@v4 - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: 20 cache: npm cache-dependency-path: | masfactory-visualizer/package-lock.json masfactory-visualizer/webview-ui/package-lock.json - name: Install extension dependencies working-directory: masfactory-visualizer run: npm ci - name: Install webview dependencies working-directory: masfactory-visualizer/webview-ui run: npm ci - name: Package VSIX id: package_extension uses: HaaLeo/publish-vscode-extension@v2 with: pat: dry-run-token packagePath: ./masfactory-visualizer dryRun: true - name: Upload VSIX artifact uses: actions/upload-artifact@v4 with: name: masfactory-visualizer-vsix path: ${{ steps.package_extension.outputs.vsixPath }} - name: Publish to Open VSX if: ${{ !inputs.dry_run && (inputs.target == 'both' || inputs.target == 'open-vsx') }} uses: HaaLeo/publish-vscode-extension@v2 with: pat: ${{ secrets.OPEN_VSX_TOKEN }} extensionFile: ${{ steps.package_extension.outputs.vsixPath }} skipDuplicate: true - name: Publish to Visual Studio Marketplace if: ${{ !inputs.dry_run && (inputs.target == 'both' || inputs.target == 'vscode-marketplace') }} uses: HaaLeo/publish-vscode-extension@v2 with: pat: ${{ secrets.VS_MARKETPLACE_TOKEN }} registryUrl: https://marketplace.visualstudio.com extensionFile: ${{ steps.package_extension.outputs.vsixPath }} skipDuplicate: true
What changed
- Run on Latchkey managed runners with one line (
runs-on), which apply the fixes below automatically and self-heal transient failures. This example useslatchkey-small; pick the runner size that fits the job. - Add a job timeout so a hung step cannot burn hours of runner time.
1 third-party action is referenced by a movable tag. Pin it to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.
What Latchkey heals here
This workflow has steps that commonly fail on transient issues (network, registries, flaky browsers). On Latchkey managed runners they are detected, retried, and self-healed instead of failing your build:
- Dependency installs
This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.