Skip to content

Enable Open VSX publishing on release tags (#75) #160

Enable Open VSX publishing on release tags (#75)

Enable Open VSX publishing on release tags (#75) #160

Workflow file for this run

name: Build VSIX
on:
push:
branches: [main]
tags: ['v*']
pull_request:
branches: [main]
workflow_dispatch:
# Default least-privilege token scope; jobs that need more elevate explicitly.
permissions:
contents: read
jobs:
build-index:
runs-on: ubuntu-latest
steps:
- name: Checkout (with submodule)
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
submodules: recursive
- name: Setup Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: '3.12'
cache: pip
cache-dependency-path: scripts/requirements.txt
- name: Install dependencies
run: pip install -r scripts/requirements.txt
- name: Run Python tests
run: pytest scripts/
- name: Build keyword index
run: |
python scripts/build_keyword_index.py \
--manual-dir opm-reference-manual \
--opm-common-dir opm-common/opm/input/eclipse/share/keywords \
--output keyword_index.json \
--compact vscode-extension/data/keyword_index_compact.json
- name: Upload keyword index
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: keyword-index
path: vscode-extension/data/keyword_index_compact.json
if-no-files-found: error
package:
needs: build-index
runs-on: ubuntu-latest
permissions:
contents: write
defaults:
run:
working-directory: vscode-extension
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v6
with:
node-version: '24'
cache: npm
cache-dependency-path: vscode-extension/package-lock.json
- name: Download freshly built keyword index
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: keyword-index
path: vscode-extension/data
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
- name: Compile TypeScript
run: npm run compile
- name: Package VSIX
run: npx --yes @vscode/vsce@3.9.1 package
- name: Upload VSIX artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: opm-flow-editor-support-vsix
path: vscode-extension/opm-flow-editor-support-*.vsix
if-no-files-found: error
- name: Attach VSIX to release
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@3d0d9888cb7fd7b750713d6e236d1fcb99157228 # v3
with:
files: vscode-extension/opm-flow-editor-support-*.vsix
publish-marketplace:
needs: package
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- name: Setup Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v6
with:
node-version: '24'
- name: Download VSIX
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: opm-flow-editor-support-vsix
path: .
- name: Publish to VS Code Marketplace
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
run: npx --yes @vscode/vsce@3.9.1 publish --packagePath opm-flow-editor-support-*.vsix --pat "$VSCE_PAT"
publish-ovsx:
needs: package
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- name: Setup Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v6
with:
node-version: '24'
- name: Download VSIX
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: opm-flow-editor-support-vsix
path: .
- name: Publish to Open VSX
env:
OVSX_PAT: ${{ secrets.OVSX_PAT }}
run: npx --yes ovsx@0.10.12 publish opm-flow-editor-support-*.vsix -p "$OVSX_PAT"