|
1 | 1 | name: Sync with Upstream |
2 | 2 |
|
3 | 3 | on: |
4 | | - schedule: |
5 | | - - cron: '0 3 * * *' # Daily at 3 AM UTC |
6 | | - workflow_dispatch: |
| 4 | + schedule: |
| 5 | + - cron: '0 3 * * *' # Daily at 3 AM UTC |
| 6 | + workflow_dispatch: |
7 | 7 |
|
8 | 8 | jobs: |
9 | | - sync: |
10 | | - runs-on: ubuntu-latest |
11 | | - permissions: |
12 | | - contents: write |
13 | | - pull-requests: write |
14 | | - |
15 | | - steps: |
16 | | - - name: Checkout fork |
17 | | - uses: actions/checkout@v4 |
18 | | - with: |
19 | | - fetch-depth: 0 |
20 | | - token: ${{ secrets.GITHUB_TOKEN }} |
21 | | - |
22 | | - - name: Configure git |
23 | | - run: | |
24 | | - git config user.name "github-actions[bot]" |
25 | | - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
26 | | - |
27 | | - - name: Add upstream remote |
28 | | - run: | |
29 | | - git remote add upstream https://github.com/modelcontextprotocol/typescript-sdk.git |
30 | | - git fetch upstream |
31 | | - |
32 | | - - name: Check for upstream changes |
33 | | - id: check |
34 | | - run: | |
35 | | - UPSTREAM_VERSION=$(git show upstream/main:package.json | jq -r .version) |
36 | | - CURRENT_BASE=$(git show main:package.json | jq -r .version | cut -d'-' -f1) |
37 | | - |
38 | | - echo "upstream_version=$UPSTREAM_VERSION" >> $GITHUB_OUTPUT |
39 | | - echo "current_base=$CURRENT_BASE" >> $GITHUB_OUTPUT |
40 | | - |
41 | | - if [ "$UPSTREAM_VERSION" = "$CURRENT_BASE" ]; then |
42 | | - echo "needs_update=false" >> $GITHUB_OUTPUT |
43 | | - echo "✅ Already synced with upstream $UPSTREAM_VERSION" |
44 | | - else |
45 | | - echo "needs_update=true" >> $GITHUB_OUTPUT |
46 | | - echo "🚀 Update available: $CURRENT_BASE → $UPSTREAM_VERSION" |
47 | | - fi |
48 | | - |
49 | | - - name: Merge upstream changes |
50 | | - if: steps.check.outputs.needs_update == 'true' |
51 | | - run: | |
52 | | - UPSTREAM_VERSION="${{ steps.check.outputs.upstream_version }}" |
53 | | - BRANCH_NAME="sync/upstream-${UPSTREAM_VERSION}" |
54 | | - |
55 | | - git checkout -b "$BRANCH_NAME" |
56 | | - |
57 | | - # Merge upstream main, auto-resolve conflicts favoring our changes in critical files |
58 | | - git merge upstream/main --no-edit || true |
59 | | - |
60 | | - # If there are conflicts, resolve them |
61 | | - if [ -f package.json ] && git diff --name-only --diff-filter=U | grep -q package.json; then |
62 | | - # Update version with mcp-use suffix after merge |
63 | | - node -e " |
64 | | - const fs = require('fs'); |
65 | | - const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8')); |
66 | | - pkg.version = '${UPSTREAM_VERSION}-mcp-use.1'; |
67 | | - fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n'); |
68 | | - " |
69 | | - git add package.json |
70 | | - fi |
71 | | - |
72 | | - # Complete merge if needed |
73 | | - if git status | grep -q "You have unmerged paths"; then |
74 | | - git commit --no-edit |
75 | | - fi |
76 | | - |
77 | | - # Ensure version is correct |
78 | | - node -e " |
79 | | - const fs = require('fs'); |
80 | | - const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8')); |
81 | | - if (!pkg.version.includes('-mcp-use')) { |
82 | | - pkg.version = '${UPSTREAM_VERSION}-mcp-use.1'; |
83 | | - fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n'); |
84 | | - } |
85 | | - " |
86 | | - |
87 | | - git add package.json |
88 | | - git commit -m "chore: bump version to ${UPSTREAM_VERSION}-mcp-use.1" || true |
89 | | - git push origin "$BRANCH_NAME" |
90 | | - |
91 | | - # Create PR |
92 | | - gh pr create \ |
93 | | - --base main \ |
94 | | - --head "$BRANCH_NAME" \ |
95 | | - --title "Sync with upstream ${UPSTREAM_VERSION}" \ |
96 | | - --body "## 🔄 Upstream Sync |
97 | | - |
98 | | - Syncs fork with upstream @modelcontextprotocol/sdk ${UPSTREAM_VERSION} |
99 | | - |
100 | | - ### 📦 Changes |
101 | | - |
102 | | - - **Upstream Version**: ${UPSTREAM_VERSION} |
103 | | - - **Fork Version**: ${UPSTREAM_VERSION}-mcp-use.1 |
104 | | - |
105 | | - ### ⚠️ Review Required |
106 | | - |
107 | | - Please review the changes to ensure: |
108 | | - - [ ] Edge runtime support (PR #1209) is preserved |
109 | | - - [ ] All mcp-use specific modifications are maintained |
110 | | - - [ ] No breaking changes introduced |
111 | | - - [ ] Tests pass |
112 | | - |
113 | | - ### 🔗 References |
114 | | - |
115 | | - - [Upstream Repository](https://github.com/modelcontextprotocol/typescript-sdk) |
116 | | - - [Upstream Changelog](https://github.com/modelcontextprotocol/typescript-sdk/releases) |
117 | | - |
118 | | - --- |
119 | | - |
120 | | - 🤖 *This PR was automatically created by the sync workflow*" || echo "PR already exists or failed to create" |
121 | | - env: |
122 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
123 | | - |
124 | | - - name: Create release tag |
125 | | - if: steps.check.outputs.needs_update == 'true' |
126 | | - run: | |
127 | | - UPSTREAM_VERSION="${{ steps.check.outputs.upstream_version }}" |
128 | | - |
129 | | - # Wait a moment to ensure PR branch is fully pushed |
130 | | - sleep 5 |
131 | | - |
132 | | - # Create tag on the PR branch |
133 | | - git tag "v${UPSTREAM_VERSION}-mcp-use.1" || echo "Tag already exists" |
134 | | - git push origin "v${UPSTREAM_VERSION}-mcp-use.1" || echo "Tag push failed or already exists" |
135 | | - |
136 | | - echo "ℹ️ Tag v${UPSTREAM_VERSION}-mcp-use.1 created on branch. Merge PR to publish to main." |
| 9 | + sync: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + permissions: |
| 12 | + contents: write |
| 13 | + pull-requests: write |
137 | 14 |
|
| 15 | + steps: |
| 16 | + - name: Checkout fork |
| 17 | + uses: actions/checkout@v4 |
| 18 | + with: |
| 19 | + fetch-depth: 0 |
| 20 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 21 | + |
| 22 | + - name: Configure git |
| 23 | + run: | |
| 24 | + git config user.name "github-actions[bot]" |
| 25 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 26 | +
|
| 27 | + - name: Add upstream remote |
| 28 | + run: | |
| 29 | + git remote add upstream https://github.com/modelcontextprotocol/typescript-sdk.git |
| 30 | + git fetch upstream |
| 31 | +
|
| 32 | + - name: Check for upstream changes |
| 33 | + id: check |
| 34 | + run: | |
| 35 | + UPSTREAM_VERSION=$(git show upstream/main:package.json | jq -r .version) |
| 36 | + CURRENT_BASE=$(git show main:package.json | jq -r .version | cut -d'-' -f1) |
| 37 | +
|
| 38 | + echo "upstream_version=$UPSTREAM_VERSION" >> $GITHUB_OUTPUT |
| 39 | + echo "current_base=$CURRENT_BASE" >> $GITHUB_OUTPUT |
| 40 | +
|
| 41 | + if [ "$UPSTREAM_VERSION" = "$CURRENT_BASE" ]; then |
| 42 | + echo "needs_update=false" >> $GITHUB_OUTPUT |
| 43 | + echo "✅ Already synced with upstream $UPSTREAM_VERSION" |
| 44 | + else |
| 45 | + echo "needs_update=true" >> $GITHUB_OUTPUT |
| 46 | + echo "🚀 Update available: $CURRENT_BASE → $UPSTREAM_VERSION" |
| 47 | + fi |
| 48 | +
|
| 49 | + - name: Merge upstream changes |
| 50 | + if: steps.check.outputs.needs_update == 'true' |
| 51 | + run: | |
| 52 | + UPSTREAM_VERSION="${{ steps.check.outputs.upstream_version }}" |
| 53 | + BRANCH_NAME="sync/upstream-${UPSTREAM_VERSION}" |
| 54 | +
|
| 55 | + git checkout -b "$BRANCH_NAME" |
| 56 | +
|
| 57 | + # Merge upstream main, auto-resolve conflicts favoring our changes in critical files |
| 58 | + git merge upstream/main --no-edit || true |
| 59 | +
|
| 60 | + # If there are conflicts, resolve them |
| 61 | + if [ -f package.json ] && git diff --name-only --diff-filter=U | grep -q package.json; then |
| 62 | + # Update version with mcp-use suffix after merge |
| 63 | + node -e " |
| 64 | + const fs = require('fs'); |
| 65 | + const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8')); |
| 66 | + pkg.version = '${UPSTREAM_VERSION}-mcp-use.1'; |
| 67 | + fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n'); |
| 68 | + " |
| 69 | + git add package.json |
| 70 | + fi |
| 71 | +
|
| 72 | + # Complete merge if needed |
| 73 | + if git status | grep -q "You have unmerged paths"; then |
| 74 | + git commit --no-edit |
| 75 | + fi |
| 76 | +
|
| 77 | + # Ensure version is correct |
| 78 | + node -e " |
| 79 | + const fs = require('fs'); |
| 80 | + const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8')); |
| 81 | + if (!pkg.version.includes('-mcp-use')) { |
| 82 | + pkg.version = '${UPSTREAM_VERSION}-mcp-use.1'; |
| 83 | + fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n'); |
| 84 | + } |
| 85 | + " |
| 86 | +
|
| 87 | + git add package.json |
| 88 | + git commit -m "chore: bump version to ${UPSTREAM_VERSION}-mcp-use.1" || true |
| 89 | + git push origin "$BRANCH_NAME" |
| 90 | +
|
| 91 | + # Create PR |
| 92 | + gh pr create \ |
| 93 | + --base main \ |
| 94 | + --head "$BRANCH_NAME" \ |
| 95 | + --title "Sync with upstream ${UPSTREAM_VERSION}" \ |
| 96 | + --body "## 🔄 Upstream Sync |
| 97 | +
|
| 98 | + Syncs fork with upstream @modelcontextprotocol/sdk ${UPSTREAM_VERSION} |
| 99 | +
|
| 100 | + ### 📦 Changes |
| 101 | +
|
| 102 | + - **Upstream Version**: ${UPSTREAM_VERSION} |
| 103 | + - **Fork Version**: ${UPSTREAM_VERSION}-mcp-use.1 |
| 104 | +
|
| 105 | + ### ⚠️ Review Required |
| 106 | +
|
| 107 | + Please review the changes to ensure: |
| 108 | + - [ ] Edge runtime support (PR #1209) is preserved |
| 109 | + - [ ] All mcp-use specific modifications are maintained |
| 110 | + - [ ] No breaking changes introduced |
| 111 | + - [ ] Tests pass |
| 112 | +
|
| 113 | + ### 🔗 References |
| 114 | +
|
| 115 | + - [Upstream Repository](https://github.com/modelcontextprotocol/typescript-sdk) |
| 116 | + - [Upstream Changelog](https://github.com/modelcontextprotocol/typescript-sdk/releases) |
| 117 | +
|
| 118 | + --- |
| 119 | +
|
| 120 | + 🤖 *This PR was automatically created by the sync workflow*" || echo "PR already exists or failed to create" |
| 121 | + env: |
| 122 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 123 | + |
| 124 | + - name: Create release tag |
| 125 | + if: steps.check.outputs.needs_update == 'true' |
| 126 | + run: | |
| 127 | + UPSTREAM_VERSION="${{ steps.check.outputs.upstream_version }}" |
| 128 | +
|
| 129 | + # Wait a moment to ensure PR branch is fully pushed |
| 130 | + sleep 5 |
| 131 | +
|
| 132 | + # Create tag on the PR branch |
| 133 | + git tag "v${UPSTREAM_VERSION}-mcp-use.1" || echo "Tag already exists" |
| 134 | + git push origin "v${UPSTREAM_VERSION}-mcp-use.1" || echo "Tag push failed or already exists" |
| 135 | +
|
| 136 | + echo "ℹ️ Tag v${UPSTREAM_VERSION}-mcp-use.1 created on branch. Merge PR to publish to main." |
0 commit comments