Skip to content

Commit da11bf9

Browse files
fix(mcp): fix git fetch into checked out branch error
Can't fetch into a branch that's checked out. Instead, fetch origin/main and push HEAD directly to main. Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 798bc50 commit da11bf9

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

.github/workflows/release-mcp.yml

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -157,37 +157,27 @@ jobs:
157157
cd packages/mcp
158158
npm publish --provenance --access public
159159
160-
- name: Fast-forward main to temporary branch
160+
- name: Push release commit to main
161161
env:
162162
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
163-
TEMP_BRANCH: ${{ steps.push_temp_branch.outputs.temp_branch }}
164163
run: |
165-
# Fetch main branch
166-
git fetch origin main:main
167-
git checkout main
164+
# Fetch latest main to check if fast-forward is possible
165+
git fetch origin main
168166
169-
# Check if fast-forward is possible
170-
if ! git merge-base --is-ancestor main "$TEMP_BRANCH"; then
167+
# Check if fast-forward is possible (current HEAD must be ahead of origin/main)
168+
if ! git merge-base --is-ancestor origin/main HEAD; then
171169
echo "❌ ERROR: Cannot fast-forward main branch to release commit"
172170
echo ""
173171
echo "This means new commits were pushed to main after the release process started."
174172
echo ""
175173
echo "Recent commits on main that caused the conflict:"
176-
git log --oneline $TEMP_BRANCH..main | head -5
174+
git log --oneline HEAD..origin/main | head -5
177175
exit 1
178176
fi
179177
180-
# Fast-forward main to release commit
181-
git merge --ff-only "$TEMP_BRANCH"
182-
183-
echo "✓ Successfully fast-forwarded main to release commit"
184-
185-
- name: Push main
186-
env:
187-
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
188-
run: |
189-
git push origin main
190-
echo "Pushed main branch"
178+
# Push current HEAD to main (fast-forward)
179+
git push origin HEAD:main
180+
echo "✓ Successfully pushed release commit to main"
191181
192182
- name: Delete temporary branch
193183
if: always()

0 commit comments

Comments
 (0)