Skip to content

Deploy

Deploy #9

Workflow file for this run

name: Deploy
on:
workflow_run:
workflows: [Test]
types: [completed]
branches: [main]
permissions:
contents: write
jobs:
publish-extension:
name: Publish to marketplace
runs-on: ubuntu-latest
environment: Production
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
ref: ${{ github.event.workflow_run.head_sha }}
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version-file: .nvmrc
cache: npm
- name: Install dependencies
run: npm --color ci
- name: Read version from package.json
run: |
VERSION=$(node -p "require('./package.json').version")
echo "version=$VERSION" >> $GITHUB_ENV
- name: Check whether this version is already published
run: |
if git ls-remote --exit-code --tags origin "refs/tags/${{ env.version }}" > /dev/null; then
echo "Version ${{ env.version }} is already tagged."
exit 1
fi
- name: Publish to Open VSX Registry
id: publishToOpenVSX
uses: HaaLeo/publish-vscode-extension@v2
with:
pat: ${{ secrets.OPEN_VSX_TOKEN }}
- name: Publish to Visual Studio Marketplace
uses: HaaLeo/publish-vscode-extension@v2
with:
pat: ${{ secrets.VS_MARKETPLACE_TOKEN }}
registryUrl: https://marketplace.visualstudio.com
extensionFile: ${{ steps.publishToOpenVSX.outputs.vsixPath }}
- name: Create Git tag
run: |
git tag "${{ env.version }}"
git push origin "${{ env.version }}"