name: Publish Release
on:
pull_request:
types:
- closed
branches:
- main
workflow_dispatch:
jobs:
publish:
# Run on merged release PR or manual trigger
if: |
(github.event_name == 'pull_request' && github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/')) ||
(github.event_name == 'workflow_dispatch')
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write # Required for MCP registry OIDC auth
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Get version
id: extract
run: |
# On PR merge, extract from branch name; on manual dispatch, read from pyproject.toml
if [ "${{ github.event_name }}" = "pull_request" ]; then
BRANCH="${{ github.event.pull_request.head.ref }}"
VERSION="${BRANCH#release/}"
else
VERSION=$(grep -m1 '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag_name=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
- name: Find and publish draft release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ steps.extract.outputs.version }}"
TAG_NAME="${{ steps.extract.outputs.tag_name }}"
echo "🔍 Looking for draft release: $TAG_NAME"
# Check if draft release exists
RELEASE_INFO=$(gh release view "$TAG_NAME" --json isDraft,tagName 2>/dev/null || echo "")
if [ -z "$RELEASE_INFO" ]; then
echo "::error::Draft release $TAG_NAME not found!"
echo "::error::Expected a draft release to be created by the pr-release workflow."
exit 1
fi
# Check if it's a draft
IS_DRAFT=$(echo "$RELEASE_INFO" | jq -r '.isDraft')
if [ "$IS_DRAFT" = "false" ]; then
echo "⚠️ Release $TAG_NAME is already published"
echo "Skipping publish step (release may have been manually published)"
exit 0
fi
echo "📦 Publishing draft release $TAG_NAME..."
# Edit release to mark as published and latest
gh release edit "$TAG_NAME" \
--draft=false \
--latest
echo "✅ Release $TAG_NAME published successfully!"
- name: Verify release is published
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG_NAME="${{ steps.extract.outputs.tag_name }}"
# Wait a moment for the edit to propagate
sleep 2
# Verify release is published
RELEASE_INFO=$(gh release view "$TAG_NAME" --json isDraft,url)
IS_DRAFT=$(echo "$RELEASE_INFO" | jq -r '.isDraft')
RELEASE_URL=$(echo "$RELEASE_INFO" | jq -r '.url')
if [ "$IS_DRAFT" = "true" ]; then
echo "::error::Release is still marked as draft!"
exit 1
fi
echo "✅ Release verification passed:"
echo " - Draft: $IS_DRAFT"
echo " - URL: $RELEASE_URL"
- name: Add workflow summary
if: always()
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ steps.extract.outputs.version }}"
TAG_NAME="${{ steps.extract.outputs.tag_name }}"
echo "## 🎉 Release Published" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Version**: $VERSION" >> $GITHUB_STEP_SUMMARY
echo "- **Tag**: $TAG_NAME" >> $GITHUB_STEP_SUMMARY
echo "- **PR**: #${{ github.event.pull_request.number }}" >> $GITHUB_STEP_SUMMARY
echo "- **Merged by**: @${{ github.event.pull_request.merged_by.login }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
# Get release URL
RELEASE_URL=$(gh release view "$TAG_NAME" --json url --jq '.url' 2>/dev/null || echo "")
if [ -n "$RELEASE_URL" ]; then
echo "[🔗 View Published Release]($RELEASE_URL)" >> $GITHUB_STEP_SUMMARY
fi
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Next Steps" >> $GITHUB_STEP_SUMMARY
echo "1. Verify installation from PyPI: \`pip install ai-debugger-inc==$VERSION\`" >> $GITHUB_STEP_SUMMARY
echo "2. Test VS Code extension from release assets" >> $GITHUB_STEP_SUMMARY
echo "3. Announce release to community" >> $GITHUB_STEP_SUMMARY
publish-mcp-registry:
# Publish to MCP Registry after GitHub release is published
needs: publish
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write # Required for OIDC authentication
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Get version from server.json
id: extract
run: |
VERSION=$(jq -r '.version' server.json)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Version from server.json: $VERSION"
- name: Install mcp-publisher
run: |
curl -sL https://github.com/modelcontextprotocol/registry/releases/latest/download/mcp-publisher_linux_amd64.tar.gz | tar xz
chmod +x mcp-publisher
./mcp-publisher --version
- name: Authenticate with MCP Registry (OIDC)
run: ./mcp-publisher login github-oidc
- name: Publish to MCP Registry
run: |
./mcp-publisher publish
echo "✅ Published to MCP Registry"
- name: Verify MCP Registry publication
run: |
# Give the registry a moment to index
sleep 5
# Query the registry to verify
curl -s "https://registry.modelcontextprotocol.io/v0.1/servers?search=io.github.ai-debugger-inc/aidb" | jq .
- name: Add MCP Registry summary
if: always()
run: |
VERSION="${{ steps.extract.outputs.version }}"
echo "## 📦 MCP Registry Publication" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Server**: io.github.ai-debugger-inc/aidb" >> $GITHUB_STEP_SUMMARY
echo "- **Version**: $VERSION" >> $GITHUB_STEP_SUMMARY
echo "- **Registry**: https://registry.modelcontextprotocol.io" >> $GITHUB_STEP_SUMMARY