-
Notifications
You must be signed in to change notification settings - Fork 2
ci: publish to the MCP Registry via GitHub OIDC on each release #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json | ||
| name: Publish to MCP Registry | ||
|
|
||
| on: | ||
| release: | ||
| types: [published] | ||
| workflow_dispatch: | ||
|
|
||
| permissions: {} | ||
|
|
||
| jobs: | ||
| publish-mcp: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| id-token: write # OIDC proof that this run comes from block/model-ledger | ||
| contents: read | ||
| steps: | ||
| - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | ||
|
|
||
| - name: Sync server.json version from pyproject.toml | ||
| run: | | ||
| VERSION=$(grep -m 1 'version =' pyproject.toml | awk -F'"' '{print $2}') | ||
| jq --arg v "$VERSION" \ | ||
| '.version = $v | ||
| | .packages[0].version = $v | ||
| | .packages[0].runtimeArguments[0].value = "model-ledger[mcp,cli]==" + $v' \ | ||
| server.json > server.tmp && mv server.tmp server.json | ||
| echo "Publishing version $VERSION" | ||
|
|
||
| - name: Wait for the version to be visible on PyPI | ||
| run: | | ||
| VERSION=$(jq -r '.version' server.json) | ||
| for i in $(seq 1 30); do | ||
| curl -sf "https://pypi.org/pypi/model-ledger/${VERSION}/json" > /dev/null && exit 0 | ||
| echo "PyPI does not serve ${VERSION} yet (attempt ${i}/30)" | ||
| sleep 10 | ||
| done | ||
| echo "model-ledger ${VERSION} never appeared on PyPI" >&2 | ||
| exit 1 | ||
|
|
||
| - name: Install mcp-publisher | ||
| run: | | ||
| curl -L "https://github.com/modelcontextprotocol/registry/releases/latest/download/mcp-publisher_$(uname -s | tr '[:upper:]' '[:lower:]')_$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/').tar.gz" | tar xz mcp-publisher | ||
|
|
||
| - name: Authenticate to MCP Registry (GitHub OIDC) | ||
| run: ./mcp-publisher login github-oidc | ||
|
|
||
| - name: Publish to MCP Registry | ||
| run: ./mcp-publisher publish | ||
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a release is published, this new workflow starts from the same
release.publishedevent as.github/workflows/release.yml, but that separate release job only uploads the distribution to PyPI at its final step. If the release job is queued behind this job or takes more than this workflow's five-minute PyPI polling window, the MCP publish fails even though the package would publish successfully shortly afterward; the MCP publish should run after the PyPI publish step/job rather than racing it from an independent workflow trigger.Useful? React with 👍 / 👎.