Skip to content

Fixes CIMD validation issue #36

Fixes CIMD validation issue

Fixes CIMD validation issue #36

name: Publish IMS MCP
on:
push:
branches:
- main
paths:
- 'ims-mcp-server/**'
- '.github/workflows/publish-ims-mcp.yml'
workflow_dispatch:
jobs:
build-test-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build twine pytest pytest-asyncio mypy
- name: Run type validation
run: |
chmod +x validate-types.sh
./validate-types.sh
- name: Build package
working-directory: ./ims-mcp-server
run: |
# V2: bootstrap.md no longer bundled (loaded from Rosetta Server at startup)
chmod +x build.sh
./build.sh
- name: Check package
working-directory: ./ims-mcp-server
run: |
twine check dist/*
- name: Run tests
working-directory: ./ims-mcp-server
run: |
# Install the package in development mode
pip install -e .
# Run tests if they exist
if [ -d "tests" ]; then
pytest tests/ -v
else
echo "No tests directory found, skipping tests"
fi
continue-on-error: false
- name: Check if version exists on PyPI
id: check_version
working-directory: ./ims-mcp-server
run: |
# Extract version from pyproject.toml (single source of truth)
VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
echo "version=$VERSION" >> $GITHUB_OUTPUT
# Check if version exists on PyPI using the JSON API (most reliable method)
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" https://pypi.org/pypi/ims-mcp/${VERSION}/json)
if [ "$HTTP_CODE" = "200" ]; then
echo "exists=true" >> $GITHUB_OUTPUT
echo "::warning::Version $VERSION already exists on PyPI"
else
echo "exists=false" >> $GITHUB_OUTPUT
echo "Version $VERSION is new, will publish"
fi
- name: Publish to PyPI
if: steps.check_version.outputs.exists == 'false'
working-directory: ./ims-mcp-server
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.IMS_MCP_PYPI_PASSWORD }}
run: |
twine upload dist/*
- name: Fail if version exists
if: steps.check_version.outputs.exists == 'true'
run: |
echo "::error::Version ${{ steps.check_version.outputs.version }} already exists on PyPI"
echo ""
echo "PyPI does not allow re-publishing the same version."
echo "Please increment the version number in:"
echo " ims-mcp-server/pyproject.toml (version field - single source of truth)"
echo ""
echo "Current version: ${{ steps.check_version.outputs.version }}"
exit 1
- name: Publish Success
if: steps.check_version.outputs.exists == 'false'
run: |
echo "Successfully published version ${{ steps.check_version.outputs.version }} to PyPI!"
echo "Package available at: https://pypi.org/project/ims-mcp/${{ steps.check_version.outputs.version }}/"
echo ""
echo "Install with: pip install ims-mcp==${{ steps.check_version.outputs.version }}"
echo "Or with uvx: uvx ims-mcp"