name: CI
on:
push:
branches: [main]
tags: ["v*"]
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18, 20, 22]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Type check
run: npm run build
- name: Test startup
run: |
# For stdio-based MCP servers, we just verify it can start and load data
# The server will exit when stdin closes, which is expected behavior
echo '' | timeout 10s node dist/index.js 2>&1 | tee output.log || true
# Check if the expected startup messages appear
if grep -q "W3C MCP Server: Data loaded" output.log; then
echo "✅ Server started and loaded data successfully"
exit 0
else
echo "❌ Server failed to start properly"
cat output.log
exit 1
fi
publish:
if: startsWith(github.ref, 'refs/tags/v')
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
registry-url: "https://registry.npmjs.org"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Publish to npm
run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}