|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +concurrency: |
| 10 | + group: release-${{ github.ref }} |
| 11 | + cancel-in-progress: false |
| 12 | + |
| 13 | +jobs: |
| 14 | + semantic-release: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + outputs: |
| 17 | + released: ${{ steps.release.outputs.released }} |
| 18 | + tag: ${{ steps.release.outputs.tag }} |
| 19 | + permissions: |
| 20 | + contents: write |
| 21 | + issues: write |
| 22 | + pull-requests: write |
| 23 | + id-token: write |
| 24 | + |
| 25 | + steps: |
| 26 | + - name: Checkout |
| 27 | + uses: actions/checkout@v5 |
| 28 | + with: |
| 29 | + fetch-depth: 0 |
| 30 | + persist-credentials: true |
| 31 | + |
| 32 | + - name: Setup Node.js |
| 33 | + uses: actions/setup-node@v5 |
| 34 | + with: |
| 35 | + node-version: 'lts/*' |
| 36 | + registry-url: 'https://registry.npmjs.org' |
| 37 | + |
| 38 | + - name: Install dependencies |
| 39 | + run: npm ci |
| 40 | + |
| 41 | + - name: Build |
| 42 | + run: npm run build --if-present |
| 43 | + |
| 44 | + - name: Semantic release |
| 45 | + id: release |
| 46 | + env: |
| 47 | + GH_TOKEN: ${{ secrets.GH_TOKEN }} |
| 48 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 49 | + run: | |
| 50 | + set -e |
| 51 | + BEFORE=$(git describe --tags --abbrev=0 2>/dev/null || true) |
| 52 | + npx semantic-release |
| 53 | + AFTER=$(git describe --tags --abbrev=0 2>/dev/null || true) |
| 54 | + if [ -n "$AFTER" ] && [ "$BEFORE" != "$AFTER" ]; then |
| 55 | + echo "released=true" >> "$GITHUB_OUTPUT" |
| 56 | + echo "tag=$AFTER" >> "$GITHUB_OUTPUT" |
| 57 | + else |
| 58 | + echo "released=false" >> "$GITHUB_OUTPUT" |
| 59 | + fi |
| 60 | +
|
| 61 | + mcp-publish: |
| 62 | + needs: semantic-release |
| 63 | + if: needs.semantic-release.outputs.released == 'true' |
| 64 | + runs-on: ubuntu-latest |
| 65 | + permissions: |
| 66 | + id-token: write |
| 67 | + contents: read |
| 68 | + |
| 69 | + steps: |
| 70 | + - name: Checkout tag |
| 71 | + uses: actions/checkout@v5 |
| 72 | + with: |
| 73 | + ref: ${{ needs.semantic-release.outputs.tag }} |
| 74 | + |
| 75 | + - name: Setup Node.js |
| 76 | + uses: actions/setup-node@v5 |
| 77 | + with: |
| 78 | + node-version: 'lts/*' |
| 79 | + |
| 80 | + - name: Install dependencies |
| 81 | + run: npm ci |
| 82 | + |
| 83 | + - name: Build package |
| 84 | + run: npm run build --if-present |
| 85 | + |
| 86 | + - name: Install MCP Publisher |
| 87 | + run: | |
| 88 | + curl -L "https://github.com/modelcontextprotocol/registry/releases/download/v1.1.0/mcp-publisher_1.1.0_$(uname -s | tr '[:upper:]' '[:lower:]')_$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/').tar.gz" | tar xz mcp-publisher |
| 89 | +
|
| 90 | + - name: Login to MCP Registry |
| 91 | + run: ./mcp-publisher login github-oidc |
| 92 | + |
| 93 | + - name: Publish to MCP Registry |
| 94 | + run: ./mcp-publisher publish |
0 commit comments