Publish Rosetta MCP #28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish Rosetta MCP | |
| on: | |
| workflow_run: | |
| workflows: ["Publish IMS MCP"] | |
| branches: [main] | |
| types: [completed] | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'rosetta-mcp-server/**' | |
| - '.github/workflows/publish-rosetta-mcp.yml' | |
| workflow_dispatch: | |
| jobs: | |
| build-test-deploy: | |
| if: github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' | |
| 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 | |
| - name: Read versions from rosetta-mcp pyproject.toml | |
| id: read_versions | |
| working-directory: ./rosetta-mcp-server | |
| run: | | |
| ROSETTA_VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/') | |
| DEPENDENCY_VERSION=$(grep 'ims-mcp==' pyproject.toml | sed 's/.*ims-mcp==\([^"]*\)".*/\1/') | |
| echo "rosetta_version=$ROSETTA_VERSION" >> $GITHUB_OUTPUT | |
| echo "dependency_version=$DEPENDENCY_VERSION" >> $GITHUB_OUTPUT | |
| echo "Read rosetta-mcp version: $ROSETTA_VERSION" | |
| echo "Read ims-mcp dependency version: $DEPENDENCY_VERSION" | |
| - name: Wait for ims-mcp dependency on PyPI | |
| env: | |
| DEPENDENCY_VERSION: ${{ steps.read_versions.outputs.dependency_version }} | |
| run: | | |
| ATTEMPTS=30 | |
| SLEEP_SECONDS=10 | |
| for attempt in $(seq 1 "$ATTEMPTS"); do | |
| HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" "https://pypi.org/pypi/ims-mcp/${DEPENDENCY_VERSION}/json") | |
| if [ "$HTTP_CODE" = "200" ]; then | |
| echo "ims-mcp ${DEPENDENCY_VERSION} is available on PyPI" | |
| exit 0 | |
| fi | |
| echo "ims-mcp ${DEPENDENCY_VERSION} is not available on PyPI yet (attempt ${attempt}/${ATTEMPTS}, status ${HTTP_CODE})" | |
| if [ "$attempt" -lt "$ATTEMPTS" ]; then | |
| sleep "$SLEEP_SECONDS" | |
| fi | |
| done | |
| echo "::error::Timed out waiting for ims-mcp ${DEPENDENCY_VERSION} to appear on PyPI" | |
| exit 1 | |
| - name: Build package | |
| working-directory: ./rosetta-mcp-server | |
| run: | | |
| python -m build | |
| - name: Check package | |
| working-directory: ./rosetta-mcp-server | |
| run: | | |
| twine check dist/* | |
| - name: Check if version exists on PyPI | |
| id: check_version | |
| run: | | |
| ROSETTA_VERSION="${{ steps.read_versions.outputs.rosetta_version }}" | |
| echo "version=$ROSETTA_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/rosetta-mcp/${ROSETTA_VERSION}/json) | |
| if [ "$HTTP_CODE" = "200" ]; then | |
| echo "exists=true" >> $GITHUB_OUTPUT | |
| echo "::warning::Version $ROSETTA_VERSION already exists on PyPI" | |
| else | |
| echo "exists=false" >> $GITHUB_OUTPUT | |
| echo "Version $ROSETTA_VERSION is new, will publish" | |
| fi | |
| - name: Publish to PyPI | |
| if: steps.check_version.outputs.exists == 'false' | |
| working-directory: ./rosetta-mcp-server | |
| env: | |
| TWINE_USERNAME: __token__ | |
| TWINE_PASSWORD: ${{ secrets.ROSETTA_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 "The rosetta-mcp version is read from rosetta-mcp-server/pyproject.toml." | |
| echo "Bump the version there to publish a new rosetta-mcp release." | |
| 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 rosetta-mcp ${{ steps.check_version.outputs.version }} to PyPI!" | |
| echo "Package available at: https://pypi.org/project/rosetta-mcp/${{ steps.check_version.outputs.version }}/" | |
| echo "" | |
| echo "Install with: pip install rosetta-mcp==${{ steps.check_version.outputs.version }}" | |
| echo "Or with uvx: uvx rosetta-mcp" |