mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-28 17:50:56 +01:00
127 lines
3.8 KiB
YAML
127 lines
3.8 KiB
YAML
name: Publish MCP Package
|
|
|
|
on:
|
|
push:
|
|
branches: [main, develop]
|
|
paths:
|
|
- 'mcp/**'
|
|
pull_request:
|
|
branches: [main, develop]
|
|
paths:
|
|
- 'mcp/**'
|
|
release:
|
|
types: [created]
|
|
workflow_dispatch:
|
|
inputs:
|
|
publish_tag:
|
|
description: 'NPM tag to publish under (latest, dev, beta, alpha)'
|
|
required: false
|
|
default: 'dev'
|
|
type: choice
|
|
options:
|
|
- latest
|
|
- dev
|
|
- beta
|
|
- alpha
|
|
|
|
jobs:
|
|
publish:
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: ./mcp
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
registry-url: 'https://registry.npmjs.org'
|
|
|
|
- name: Setup pnpm
|
|
uses: pnpm/action-setup@v4
|
|
with:
|
|
version: '10.12.1'
|
|
|
|
- name: Get pnpm store directory
|
|
shell: bash
|
|
run: |
|
|
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
|
|
|
- name: Setup pnpm cache
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ${{ env.STORE_PATH }}
|
|
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-pnpm-store-
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Lint code
|
|
run: pnpm run lint
|
|
|
|
- name: Run tests
|
|
run: pnpm run test
|
|
|
|
- name: Build package
|
|
run: pnpm run build
|
|
|
|
- name: Determine npm tag
|
|
id: npm_tag
|
|
run: |
|
|
if [ "${{ github.event_name }}" = "release" ]; then
|
|
if [[ "${{ github.event.release.prerelease }}" == "true" ]]; then
|
|
echo "tag=beta" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "tag=latest" >> $GITHUB_OUTPUT
|
|
fi
|
|
elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
|
echo "tag=${{ github.event.inputs.publish_tag }}" >> $GITHUB_OUTPUT
|
|
elif [ "${{ github.ref }}" = "refs/heads/develop" ]; then
|
|
echo "tag=dev" >> $GITHUB_OUTPUT
|
|
elif [ "${{ github.ref }}" = "refs/heads/main" ]; then
|
|
echo "tag=latest" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "tag=dev" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Check if package builds correctly
|
|
run: |
|
|
if [ ! -f "dist/index.js" ]; then
|
|
echo "Build failed - dist/index.js not found"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Publish to NPM (dry-run for PRs)
|
|
if: github.event_name == 'pull_request'
|
|
run: pnpm publish --dry-run --no-git-checks --tag ${{ steps.npm_tag.outputs.tag }}
|
|
|
|
- name: Publish to NPM
|
|
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'))
|
|
run: |
|
|
echo "Publishing with tag: ${{ steps.npm_tag.outputs.tag }}"
|
|
pnpm publish --no-git-checks --tag ${{ steps.npm_tag.outputs.tag }}
|
|
env:
|
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
|
|
|
|
- name: Create GitHub Release Asset
|
|
if: github.event_name == 'release'
|
|
run: |
|
|
tar -czf mcp-server-crawlab-${{ github.ref_name }}.tar.gz dist/
|
|
|
|
- name: Upload Release Asset
|
|
if: github.event_name == 'release'
|
|
uses: actions/upload-release-asset@v1
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
upload_url: ${{ github.event.release.upload_url }}
|
|
asset_path: ./crawlab/mcp/mcp-server-crawlab-${{ github.ref_name }}.tar.gz
|
|
asset_name: mcp-server-crawlab-${{ github.ref_name }}.tar.gz
|
|
asset_content_type: application/gzip
|