diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0ce9274..e715497 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -242,11 +242,89 @@ name: dist-${{ needs.validate-release.outputs.version }} path: dist/ retention-days: 90 - - notify-success: + + publish-mcp-registry: runs-on: ubuntu-latest needs: [validate-release, build-and-publish] - if: success() + if: ${{ github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && !inputs.dry_run) }} + permissions: + id-token: write # Required for GitHub OIDC authentication + contents: read + + steps: + - name: ⚙️ Harden Runner + uses: step-security/harden-runner@v2 + with: + egress-policy: audit + + - name: ⚙️ Checkout the project + uses: actions/checkout@v5 + + - name: ⚙️ Update server.json version + run: | + # Determine the target version + if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then + TARGET_VERSION="${{ github.event.inputs.version }}" + echo "Using version from manual trigger: $TARGET_VERSION" + elif [[ "${{ github.event_name }}" == "release" ]]; then + RELEASE_TAG="${{ github.event.release.tag_name }}" + TARGET_VERSION=$(echo "$RELEASE_TAG" | sed 's/^v//') + echo "Using version from release tag: $TARGET_VERSION (tag: $RELEASE_TAG)" + else + echo "Error: Unexpected event type: ${{ github.event_name }}" + exit 1 + fi + + # Update version in server.json (with validation) + if ! jq --arg v "$TARGET_VERSION" '.version = $v | .packages[0].version = $v' server.json > tmp; then + echo "Error: jq failed to update server.json" + rm -f tmp + exit 1 + fi + + # Verify the updated content is valid JSON before replacing + if ! jq empty tmp 2>/dev/null; then + echo "Error: Updated server.json is not valid JSON" + cat tmp + rm -f tmp + exit 1 + fi + + # Replace original with validated update + mv tmp server.json + + echo "Updated server.json:" + cat server.json + + - name: ⚙️ Install MCP Publisher + run: | + curl -fL "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 xzf - mcp-publisher + chmod +x mcp-publisher + + - name: ⚙️ Login to MCP Registry + if: ${{ github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && !inputs.dry_run) }} + run: ./mcp-publisher login github-oidc + + - name: ⚙️ Publish to MCP Registry + if: ${{ github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && !inputs.dry_run) }} + run: ./mcp-publisher publish + + - name: ⚙️ Dry run notification + if: ${{ github.event_name == 'workflow_dispatch' && inputs.dry_run == true }} + run: | + VERSION=$(jq -r '.version' server.json) + echo "🔍 DRY RUN MODE - MCP Registry preparation successful!" + echo "" + echo "server.json is valid JSON and ready to publish" + echo "Server: io.github.redis/mcp-redis" + echo "Version: $VERSION" + echo "" + echo "To actually publish to MCP Registry, run this workflow again without dry_run enabled" + + notify-success: + runs-on: ubuntu-latest + needs: [validate-release, build-and-publish, publish-mcp-registry] + if: ${{ always() && !cancelled() && needs.build-and-publish.result == 'success' }} steps: - name: ⚙️ Success notification run: | @@ -255,12 +333,18 @@ echo "📦 Package built successfully but not published" echo "🎯 Target environment: ${{ github.event.inputs.environment || 'pypi' }}" else - echo "🎉 Successfully released Redis MCP Server v${{ github.event.inputs.version || needs.validate-release.outputs.version }} to ${{ github.event.inputs.environment || 'PyPI' }}!" + echo "🎉 Successfully released Redis MCP Server v${{ github.event.inputs.version || needs.validate-release.outputs.version }}!" + echo "" + echo "📦 PyPI Package:" if [[ "${{ github.event.inputs.environment }}" == "testpypi" ]]; then - echo "📦 Package: https://test.pypi.org/project/redis-mcp-server/${{ github.event.inputs.version || needs.validate-release.outputs.version }}/" + echo " https://test.pypi.org/project/redis-mcp-server/${{ github.event.inputs.version || needs.validate-release.outputs.version }}/" else - echo "📦 Package: https://pypi.org/project/redis-mcp-server/${{ github.event.inputs.version || needs.validate-release.outputs.version }}/" + echo " https://pypi.org/project/redis-mcp-server/${{ github.event.inputs.version || needs.validate-release.outputs.version }}/" fi + echo "" + echo "🔌 MCP Registry:" + echo " https://registry.modelcontextprotocol.io/v0/servers?search=redis" + echo "" if [[ "${{ github.event_name }}" == "release" ]]; then echo "🏷️ Release: https://github.com/${{ github.repository }}/releases/tag/${{ github.ref_name }}" else diff --git a/server.json b/server.json index 2108439..da31b84 100644 --- a/server.json +++ b/server.json @@ -3,19 +3,12 @@ "name": "io.github.redis/mcp-redis", "title": "Redis MCP Server", "description": "Natural language interface designed for agentic applications to manage and search data in Redis.", - "version": "0.3.6", + "version": "$VERSION", "packages": [ { "registryType": "pypi", "identifier": "redis-mcp-server", - "version": "0.3.6", - "transport": { - "type": "stdio" - } - }, - { - "registryType": "oci", - "identifier": "docker.io/mcp/redis:latest", + "version": "$VERSION", "transport": { "type": "stdio" }