Skip to content

Publish Extension

Publish Extension #161

Workflow file for this run

name: Publish Extension
permissions:
contents: read
on:
schedule:
- cron: '0 0 * * *' # every day at 00:00 UTC
workflow_dispatch: {} # allow manual runs
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code (last 2 commits)
uses: actions/checkout@v4
with:
ref: refs/heads/master
fetch-depth: 2
- name: Determine if package.json changed in the last 24 hours
id: pkg_changed
run: |
# Look for any commits touching package.json in the last 24 hours.
# If this is a shallow clone, try to fetch more history and retry.
CHANGED=$(git log --since="24 hours ago" --pretty=format:%H -- package.json || true)
if [ -z "$CHANGED" ]; then
# If the repo may be shallow, try to unshallow or fetch more history and retry
if git rev-parse --is-shallow-repository >/dev/null 2>&1 && [ "$(git rev-parse --is-shallow-repository)" = "true" ]; then
git fetch --prune --unshallow || git fetch --prune --depth=50 origin || true
fi
CHANGED=$(git log --since="24 hours ago" --pretty=format:%H -- package.json || true)
fi
if [ -n "$CHANGED" ]; then
echo "changed=true" >> $GITHUB_OUTPUT
else
echo "changed=false" >> $GITHUB_OUTPUT
fi
- name: Setup Node.js
if: steps.pkg_changed.outputs.changed == 'true'
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
if: steps.pkg_changed.outputs.changed == 'true'
run: |
npm install
cd views/chat-view
npm install
- name: Install vsce
if: steps.pkg_changed.outputs.changed == 'true'
run: npm install -g vsce
- name: Package extension (.vsix)
if: steps.pkg_changed.outputs.changed == 'true'
run: |
vsce package
- name: Publish to VS Code Marketplace
if: steps.pkg_changed.outputs.changed == 'true'
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
run: vsce publish -p $VSCE_PAT
- name: Install ovsx
if: steps.pkg_changed.outputs.changed == 'true'
run: npm install -g ovsx
- name: Publish to Open VSX
if: steps.pkg_changed.outputs.changed == 'true'
env:
OVSX_TOKEN: ${{ secrets.OVSX_TOKEN }}
run: |
ovsx publish *.vsix --pat $OVSX_TOKEN