Files
wehub-resource-sync db1d565b64
Integration Tests / melodic (push) Has been cancelled
Integration Tests / noetic (push) Has been cancelled
Integration Tests / humble (push) Has been cancelled
Integration Tests / jazzy (push) Has been cancelled
Ruff Lint & Format / ruff (push) Has been cancelled
Sync main to develop / Check if sync is needed (push) Has been cancelled
Sync main to develop / Sync main to develop (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:36:23 +08:00

111 lines
3.4 KiB
YAML

name: Publish (PyPI + MCP Registry)
on:
workflow_dispatch:
push:
tags:
- 'v*'
concurrency:
group: publish-${{ github.ref }}
cancel-in-progress: true
jobs:
pypi:
name: Publish to PyPI
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
id-token: write # REQUIRED for PyPI Trusted Publishing (OIDC)
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Validate version matches tag
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
run: |
set -euo pipefail
TAG_VERSION="${GITHUB_REF#refs/tags/v}"
PYPROJECT_VERSION=$(grep -oP '^version = "\K[^"]+' pyproject.toml)
SERVER_VERSION=$(grep -oP '"version":\s*"\K[^"]+' server.json | head -1)
SERVER_PKG_VERSION=$(grep -oP '"version":\s*"\K[^"]+' server.json | tail -1)
ERRORS=0
[ "$PYPROJECT_VERSION" != "$TAG_VERSION" ] && echo "pyproject.toml: $PYPROJECT_VERSION != $TAG_VERSION" && ERRORS=1
[ "$SERVER_VERSION" != "$TAG_VERSION" ] && echo "server.json: $SERVER_VERSION != $TAG_VERSION" && ERRORS=1
[ "$SERVER_PKG_VERSION" != "$TAG_VERSION" ] && echo "server.json package: $SERVER_PKG_VERSION != $TAG_VERSION" && ERRORS=1
if [ $ERRORS -eq 1 ]; then
echo "Please update all version fields to $TAG_VERSION before creating the tag."
exit 1
fi
echo "All versions match: $TAG_VERSION"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install uv
run: pipx install uv
- name: Sync dependencies
run: uv sync --extra dev
- name: Run ruff lint
run: uvx ruff check .
- name: Run ruff format check
run: uvx ruff format --check .
- name: Run tests
run: |
if [ -d tests ]; then
uv run pytest -q -m "not slow and not integration" || [ $? -eq 5 ] # exit 5 = no tests collected
else
echo "No tests/ directory; skipping."
fi
- name: Build package
run: uv build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist
registry:
name: Publish to MCP Registry
runs-on: ubuntu-latest
timeout-minutes: 10
needs: pypi
permissions:
contents: read
id-token: write # REQUIRED for MCP Registry GitHub OIDC login
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Wait for PyPI metadata propagation
run: sleep 20
- name: Install MCP Publisher
run: |
set -euo pipefail
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/')
echo "Get the latest release version"
LATEST_VERSION=$(curl -s https://api.github.com/repos/modelcontextprotocol/registry/releases/latest | jq -r '.tag_name')
echo "Installing MCP Publisher version: $LATEST_VERSION"
curl -L "https://github.com/modelcontextprotocol/registry/releases/latest/download/mcp-publisher_${OS}_${ARCH}.tar.gz" \
| tar xz mcp-publisher
- name: Login to MCP Registry
run: ./mcp-publisher login github-oidc
- name: Publish to MCP Registry
run: ./mcp-publisher publish