publish-simple.yml•2.98 kB
name: Simple NPM Publish
on:
workflow_dispatch:
inputs:
npm_tag:
description: 'npm dist-tag (latest, beta, next, etc.)'
required: false
default: 'latest'
dry_run:
description: 'Dry run (test without publishing)'
required: false
type: boolean
default: false
permissions:
contents: read
jobs:
simple-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'npm'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm ci
- name: Run full validation
run: |
echo "🔍 Running validation pipeline..."
npm run type-check
npm run lint
npm run test:ci
npm run build
echo "✅ All validation checks passed"
- name: Verify build output
run: |
echo "🔍 Verifying build output..."
ls -la dist/
test -f dist/index.js || (echo "❌ dist/index.js not found" && exit 1)
test -f dist/cli.js || (echo "❌ dist/cli.js not found" && exit 1)
echo "✅ Build verification passed"
- name: Test package locally
run: |
echo "🧪 Testing package installation..."
npm pack
PACKAGE_FILE=$(ls *.tgz)
echo "Testing local installation of $PACKAGE_FILE"
npm install -g "$PACKAGE_FILE"
context-mcp --help
echo "✅ Package installation test passed"
- name: Show package info
run: |
echo "📦 Package Information:"
npm pkg get name version description
echo ""
echo "📋 Files to be published:"
npm pack --dry-run
- name: Dry run publish
if: inputs.dry_run
run: |
echo "🧪 Dry run mode - testing publish without actually publishing"
npm publish --dry-run --tag=${{ inputs.npm_tag }}
echo "✅ Dry run completed successfully"
echo ""
echo "ℹ️ To publish for real, run this workflow again with dry_run=false"
- name: Publish to npm
if: '!inputs.dry_run'
run: |
echo "🚀 Publishing to npm..."
npm publish --tag=${{ inputs.npm_tag }}
echo "✅ Published successfully!"
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Verify npm publication
if: '!inputs.dry_run'
run: |
echo "🔍 Verifying npm publication..."
sleep 10
PACKAGE_NAME=$(npm pkg get name | tr -d '"')
PACKAGE_VERSION=$(npm pkg get version | tr -d '"')
npm view "$PACKAGE_NAME@$PACKAGE_VERSION" version
echo "✅ Package successfully published to npm registry"
echo ""
echo "📋 Installation command:"
echo "npm install -g $PACKAGE_NAME"