119 lines
3.1 KiB
YAML
119 lines
3.1 KiB
YAML
name: Extension CI
|
|
|
|
on:
|
|
pull_request:
|
|
push:
|
|
branches:
|
|
- main
|
|
tags:
|
|
- "v*"
|
|
|
|
jobs:
|
|
build:
|
|
name: Build and Package
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
steps:
|
|
- name: Check out repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 22
|
|
cache: npm
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Type-check
|
|
run: npm run check
|
|
|
|
- name: Compile extension
|
|
run: npm run compile
|
|
|
|
- name: Package VSIX
|
|
run: |
|
|
rm -f ./*.vsix
|
|
npm run package:vsix
|
|
|
|
- name: Locate VSIX artifact
|
|
id: locate_vsix
|
|
run: |
|
|
VSIX_PATH="$(find . -maxdepth 1 -name '*.vsix' -print -quit)"
|
|
if [ -z "${VSIX_PATH}" ]; then
|
|
echo "No VSIX artifact was produced."
|
|
exit 1
|
|
fi
|
|
echo "path=${VSIX_PATH#./}" >> "${GITHUB_OUTPUT}"
|
|
|
|
- name: Upload VSIX artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: packaged-vsix
|
|
path: ${{ steps.locate_vsix.outputs.path }}
|
|
if-no-files-found: error
|
|
|
|
release:
|
|
name: Release and Publish
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
steps:
|
|
- name: Check out repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 22
|
|
cache: npm
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Assert tag matches package version
|
|
run: |
|
|
PACKAGE_VERSION="$(node -p "require('./package.json').version")"
|
|
EXPECTED_TAG="v${PACKAGE_VERSION}"
|
|
if [ "${GITHUB_REF_NAME}" != "${EXPECTED_TAG}" ]; then
|
|
echo "Tag ${GITHUB_REF_NAME} does not match ${EXPECTED_TAG}."
|
|
exit 1
|
|
fi
|
|
|
|
- name: Download VSIX artifact
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: packaged-vsix
|
|
path: release-assets
|
|
|
|
- name: Locate VSIX artifact
|
|
id: locate_vsix
|
|
run: |
|
|
VSIX_PATH="$(find release-assets -name '*.vsix' -print -quit)"
|
|
if [ -z "${VSIX_PATH}" ]; then
|
|
echo "Downloaded artifact does not contain a VSIX package."
|
|
exit 1
|
|
fi
|
|
echo "path=${VSIX_PATH}" >> "${GITHUB_OUTPUT}"
|
|
|
|
- name: Create GitHub Release
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
tag_name: ${{ github.ref_name }}
|
|
generate_release_notes: true
|
|
files: ${{ steps.locate_vsix.outputs.path }}
|
|
|
|
- name: Publish to Visual Studio Marketplace
|
|
env:
|
|
VSCE_PAT: ${{ secrets.VSCE_PAT }}
|
|
run: |
|
|
if [ -z "${VSCE_PAT}" ]; then
|
|
echo "VSCE_PAT secret is required to publish to the Visual Studio Marketplace."
|
|
exit 1
|
|
fi
|
|
npx vsce publish --packagePath "${{ steps.locate_vsix.outputs.path }}" --pat "${VSCE_PAT}"
|