|
1 | 1 | name: Release |
2 | 2 |
|
3 | 3 | on: |
4 | | - release: |
5 | | - types: |
6 | | - - published |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + |
| 8 | +concurrency: ${{ github.workflow }}-${{ github.ref }} |
7 | 9 |
|
8 | 10 | jobs: |
9 | 11 | release: |
10 | 12 | name: Release |
11 | 13 | runs-on: ubuntu-latest |
12 | 14 | permissions: |
13 | 15 | id-token: write # Required for OIDC authentication with MCP Registry |
14 | | - contents: read |
| 16 | + contents: write |
| 17 | + pull-requests: write |
15 | 18 | steps: |
16 | 19 | - name: Checkout Repo |
17 | 20 | uses: actions/checkout@v3 |
18 | 21 |
|
19 | | - - name: Set env |
20 | | - run: | |
21 | | - VERSION="${GITHUB_REF##refs/*/}" |
22 | | - # Remove 'v' prefix if it exists |
23 | | - VERSION="${VERSION#v}" |
24 | | - echo "VERSION=$VERSION" >> $GITHUB_ENV |
25 | | -
|
26 | 22 | - name: Setup Node |
27 | 23 | uses: actions/setup-node@v4 |
28 | 24 | with: |
29 | | - node-version: lts/* |
| 25 | + node-version: "20" |
30 | 26 |
|
31 | | - - name: Setup Bun |
32 | | - uses: oven-sh/setup-bun@v2 |
| 27 | + - name: Setup pnpm |
| 28 | + uses: pnpm/action-setup@v4 |
33 | 29 | with: |
34 | | - bun-version: latest |
| 30 | + version: 9 |
35 | 31 |
|
36 | | - - name: Set package version |
| 32 | + - name: Configure npm authentication |
37 | 33 | run: | |
38 | | - echo $(jq --arg v "${{ env.VERSION }}" '(.version) = $v' package.json) > package.json |
39 | | -
|
40 | | - - name: Update version in source file |
41 | | - run: | |
42 | | - sed -i "s/version: \"[0-9]*\.[0-9]*\.[0-9]*\"/version: \"${{ env.VERSION }}\"/" src/index.ts |
43 | | -
|
44 | | - - name: Update package version in server.json |
45 | | - run: | |
46 | | - echo $(jq --arg v "${{ env.VERSION }}" '.version = $v | .packages[0].version = $v' server.json) > server.json |
| 34 | + echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc |
47 | 35 |
|
48 | 36 | - name: Install Dependencies |
49 | | - run: bun install |
50 | | - |
51 | | - - name: Build |
52 | | - run: bun run build |
| 37 | + run: pnpm install --frozen-lockfile |
53 | 38 |
|
54 | | - - name: Set NPM_TOKEN |
55 | | - run: npm config set //registry.npmjs.org/:_authToken=${{secrets.NPM_TOKEN}} |
| 39 | + - name: Build all packages |
| 40 | + run: pnpm build |
56 | 41 |
|
57 | | - - name: Publish |
58 | | - if: "!github.event.release.prerelease" |
| 42 | + - name: Create Release PR or Publish |
| 43 | + id: changesets |
| 44 | + uses: changesets/action@v1 |
| 45 | + with: |
| 46 | + publish: pnpm release |
| 47 | + commit: "chore(release): version packages" |
| 48 | + title: "chore(release): version packages" |
| 49 | + env: |
| 50 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 51 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 52 | + |
| 53 | + - name: Check if MCP was published |
| 54 | + id: check-mcp |
| 55 | + if: steps.changesets.outputs.published == 'true' |
59 | 56 | run: | |
60 | | - npm pkg delete scripts.prepare |
61 | | - npm publish --access public |
62 | | -
|
63 | | - - name: Publish release candidate |
64 | | - if: "github.event.release.prerelease" |
| 57 | + PUBLISHED='${{ steps.changesets.outputs.publishedPackages }}' |
| 58 | + if echo "$PUBLISHED" | jq -e '.[] | select(.name == "@upstash/context7-mcp")' > /dev/null; then |
| 59 | + VERSION=$(echo "$PUBLISHED" | jq -r '.[] | select(.name == "@upstash/context7-mcp") | .version') |
| 60 | + echo "mcp_published=true" >> $GITHUB_OUTPUT |
| 61 | + echo "mcp_version=$VERSION" >> $GITHUB_OUTPUT |
| 62 | + fi |
| 63 | +
|
| 64 | + - name: Update version in MCP source file |
| 65 | + if: steps.check-mcp.outputs.mcp_published == 'true' |
65 | 66 | run: | |
66 | | - npm pkg delete scripts.prepare |
67 | | - npm publish --access public --tag=canary |
68 | | -
|
69 | | - - name: Validate server.json |
70 | | - if: "!github.event.release.prerelease" |
71 | | - run: npx mcp-registry-validator validate server.json |
72 | | - |
73 | | - - name: Install MCP Publisher |
74 | | - if: "!github.event.release.prerelease" |
| 67 | + VERSION="${{ steps.check-mcp.outputs.mcp_version }}" |
| 68 | + sed -i "s/version: \"[0-9]*\.[0-9]*\.[0-9]*\"/version: \"$VERSION\"/" packages/mcp/src/index.ts |
| 69 | + git config user.name "github-actions[bot]" |
| 70 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 71 | + git add packages/mcp/src/index.ts |
| 72 | + git commit -m "chore: update MCP version in source to $VERSION" || true |
| 73 | + git push || true |
| 74 | +
|
| 75 | + - name: Update server.json |
| 76 | + if: steps.check-mcp.outputs.mcp_published == 'true' |
75 | 77 | run: | |
76 | | - curl -L "https://github.com/modelcontextprotocol/registry/releases/download/v1.3.3/mcp-publisher_$(uname -s | tr '[:upper:]' '[:lower:]')_$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/').tar.gz" | tar xz mcp-publisher |
77 | | -
|
78 | | - - name: Login to MCP Registry |
79 | | - if: "!github.event.release.prerelease" |
80 | | - run: ./mcp-publisher login github-oidc |
| 78 | + VERSION="${{ steps.check-mcp.outputs.mcp_version }}" |
| 79 | + echo $(jq --arg v "$VERSION" '.version = $v | .packages[0].version = $v' server.json) > server.json |
| 80 | + git add server.json |
| 81 | + git commit -m "chore: update server.json to v$VERSION" || true |
| 82 | + git push || true |
81 | 83 |
|
82 | 84 | - name: Publish to MCP Registry |
83 | | - if: "!github.event.release.prerelease" |
84 | | - run: ./mcp-publisher publish |
| 85 | + if: steps.check-mcp.outputs.mcp_published == 'true' |
| 86 | + run: | |
| 87 | + curl -L "https://github.com/modelcontextprotocol/registry/releases/download/v1.3.3/mcp-publisher_$(uname -s | tr '[:upper:]' '[:lower:]')_$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/').tar.gz" | tar xz mcp-publisher |
| 88 | + ./mcp-publisher login github-oidc |
| 89 | + ./mcp-publisher publish |
0 commit comments