|
| 1 | +name: Release MCP server |
| 2 | + |
| 3 | +# Push a tag such as mcp-v0.1.0. PyPI and the MCP Registry both trust this |
| 4 | +# workflow through OIDC, so no token is stored anywhere. |
| 5 | +on: |
| 6 | + push: |
| 7 | + tags: ["mcp-v*"] |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + |
| 12 | +jobs: |
| 13 | + build: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + defaults: |
| 16 | + run: |
| 17 | + working-directory: mcp |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v7 |
| 20 | + - uses: astral-sh/setup-uv@v10.2.0 |
| 21 | + - name: Tag, package and server.json versions agree |
| 22 | + run: | |
| 23 | + version="$(uv version --short)" |
| 24 | + test "mcp-v$version" = "$GITHUB_REF_NAME" |
| 25 | + test "$(jq -r .version server.json)" = "$version" |
| 26 | + test "$(jq -r '.packages[0].version' server.json)" = "$version" |
| 27 | + - run: uv run --group dev pytest |
| 28 | + - run: uv build |
| 29 | + - uses: actions/upload-artifact@v7 |
| 30 | + with: |
| 31 | + name: mcp-dist |
| 32 | + path: mcp/dist/ |
| 33 | + |
| 34 | + pypi: |
| 35 | + needs: build |
| 36 | + runs-on: ubuntu-latest |
| 37 | + environment: |
| 38 | + name: pypi |
| 39 | + url: https://pypi.org/project/ng-postcode-mcp/ |
| 40 | + permissions: |
| 41 | + id-token: write |
| 42 | + steps: |
| 43 | + - uses: actions/download-artifact@v8 |
| 44 | + with: |
| 45 | + name: mcp-dist |
| 46 | + path: dist/ |
| 47 | + - uses: pypa/gh-action-pypi-publish@v1.14.2 |
| 48 | + |
| 49 | + registry: |
| 50 | + needs: pypi |
| 51 | + runs-on: ubuntu-latest |
| 52 | + permissions: |
| 53 | + contents: read |
| 54 | + id-token: write |
| 55 | + defaults: |
| 56 | + run: |
| 57 | + working-directory: mcp |
| 58 | + steps: |
| 59 | + - uses: actions/checkout@v7 |
| 60 | + - name: Install mcp-publisher |
| 61 | + run: | |
| 62 | + os="$(uname -s | tr '[:upper:]' '[:lower:]')" |
| 63 | + arch="$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/')" |
| 64 | + curl -fsSL "https://github.com/modelcontextprotocol/registry/releases/latest/download/mcp-publisher_${os}_${arch}.tar.gz" | tar xz mcp-publisher |
| 65 | + - run: ./mcp-publisher login github-oidc |
| 66 | + # The registry reads the README from PyPI, which can lag a fresh upload. |
| 67 | + - name: Publish to the MCP Registry |
| 68 | + run: | |
| 69 | + for attempt in 1 2 3 4 5; do |
| 70 | + ./mcp-publisher publish && exit 0 |
| 71 | + echo "attempt $attempt failed; retrying in 30s" |
| 72 | + sleep 30 |
| 73 | + done |
| 74 | + exit 1 |
0 commit comments