Bump versions #24
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: | |
| 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: Extract version from ims-mcp | |
| id: extract_version | |
| run: | | |
| VERSION=$(grep '^version = ' ims-mcp-server/pyproject.toml | sed 's/version = "\(.*\)"/\1/') | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Extracted version: $VERSION" | |
| - name: Inject version into rosetta-mcp pyproject.toml | |
| working-directory: ./rosetta-mcp-server | |
| run: | | |
| VERSION="${{ steps.extract_version.outputs.version }}" | |
| sed -i "s/^version = .*/version = \"${VERSION}\"/" pyproject.toml | |
| sed -i "s/ims-mcp==[^\"]*\"/ims-mcp==${VERSION}\"/" pyproject.toml | |
| echo "Updated pyproject.toml:" | |
| cat pyproject.toml | |
| - 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: | | |
| VERSION="${{ steps.extract_version.outputs.version }}" | |
| 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/rosetta-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: ./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 derived from ims-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" |