Skip to content

Add GitHub Actions for CI/CD automation #1

Add GitHub Actions for CI/CD automation

Add GitHub Actions for CI/CD automation #1

Workflow file for this run

name: Publish to npm
on:
push:
branches: [ "main" ]
# Only trigger when package.json changes or when a release tag is created
paths:
- 'package.json'
- 'src/**'
- 'build/**'
release:
types: [created]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '20.x'
cache: 'npm'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm ci
- name: Run checks
run: npm run check
- name: Run security check
run: npm run security-check
- name: Build
run: npm run build
# This only runs on main branch pushes that have modified package.json or are from a release event
- name: Extract version from package.json
id: extract_version
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
- name: Check if version exists
id: version_check
run: |
if npm view cursor-azure-devops-mcp@${{ steps.extract_version.outputs.version }} version &> /dev/null; then
echo "exists=true" >> $GITHUB_OUTPUT
echo "Version ${{ steps.extract_version.outputs.version }} already exists on npm"
else
echo "exists=false" >> $GITHUB_OUTPUT
echo "Version ${{ steps.extract_version.outputs.version }} doesn't exist yet"
fi
continue-on-error: true
- name: Publish to npm
if: steps.version_check.outputs.exists != 'true'
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}