name: CI/CD Pipeline
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
release:
types: [ published ]
jobs:
test:
runs-on: windows-latest
strategy:
matrix:
node-version: [18.x, 20.x]
steps:
- name: Checkout code
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: Build project
run: npm run build
- name: Run tests
run: npm test
- name: Check TypeScript compilation
run: npx tsc --noEmit
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run ESLint (if configured)
run: |
if [ -f .eslintrc.js ] || [ -f .eslintrc.json ] || [ -f package.json ]; then
npx eslint . --ext .ts,.js || echo "ESLint not configured, skipping..."
else
echo "ESLint not configured, skipping..."
fi
continue-on-error: true
security:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run security audit
run: npm audit --audit-level=moderate
continue-on-error: true
publish:
needs: [test, lint, security]
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build project
run: npm run build
- name: Publish to NPM
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
create-release-assets:
needs: [test, lint, security]
runs-on: windows-latest
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build project
run: npm run build
- name: Create distribution package
run: |
mkdir windows-mcp-dist
cp -r build windows-mcp-dist/
cp package.json windows-mcp-dist/
cp README.md windows-mcp-dist/
cp LICENSE windows-mcp-dist/
cp -r examples windows-mcp-dist/
- name: Create ZIP archive
run: |
Compress-Archive -Path windows-mcp-dist/* -DestinationPath windows-mcp-${{ github.event.release.tag_name }}.zip
- name: Upload release asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./windows-mcp-${{ github.event.release.tag_name }}.zip
asset_name: windows-mcp-${{ github.event.release.tag_name }}.zip
asset_content_type: application/zip