From 28907be170c51a2c4bf21c29e053bedd5edefafb Mon Sep 17 00:00:00 2001 From: Juha Litola Date: Tue, 23 Jun 2026 16:41:19 +0300 Subject: [PATCH] fix: skip published MCP release tags Check the published npm version before enforcing that the MCP release tag points at HEAD, so normal Main runs with an unchanged MCP version skip cleanly instead of failing on the historical tag. --- .github/workflows/mcp-release.yml | 15 ++++++++++----- src/package-release-boundaries.test.ts | 12 ++++++++++++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/.github/workflows/mcp-release.yml b/.github/workflows/mcp-release.yml index 53f910b5..c4efb284 100644 --- a/.github/workflows/mcp-release.yml +++ b/.github/workflows/mcp-release.yml @@ -129,13 +129,21 @@ jobs: echo "version=$VERSION" >> "$GITHUB_OUTPUT" echo "tag=$TAG" >> "$GITHUB_OUTPUT" + if npm view "@githits/mcp@$VERSION" version >/dev/null 2>&1; then + NPM_PUBLISHED=true + echo "npm_published=true" >> "$GITHUB_OUTPUT" + else + NPM_PUBLISHED=false + echo "npm_published=false" >> "$GITHUB_OUTPUT" + fi + TAG_EXISTS=false TAG_REF="refs/tags/$TAG" if git rev-parse --verify "$TAG_REF^{commit}" >/dev/null 2>&1; then TAG_EXISTS=true TAG_COMMIT=$(git rev-parse "$TAG_REF^{commit}") HEAD_COMMIT=$(git rev-parse HEAD) - if [ "$TAG_COMMIT" != "$HEAD_COMMIT" ]; then + if [ "$NPM_PUBLISHED" != "true" ] && [ "$TAG_COMMIT" != "$HEAD_COMMIT" ]; then echo "::error::Existing tag $TAG points to $TAG_COMMIT, not HEAD $HEAD_COMMIT" exit 1 fi @@ -150,14 +158,11 @@ jobs: echo "release_exists=false" >> "$GITHUB_OUTPUT" fi - if npm view "@githits/mcp@$VERSION" version >/dev/null 2>&1; then + if [ "$NPM_PUBLISHED" = "true" ]; then if [ "$TAG_EXISTS" != "true" ]; then echo "::error::@githits/mcp@$VERSION is already published, but $TAG is missing. Refusing to mint an unverifiable release tag." exit 1 fi - echo "npm_published=true" >> "$GITHUB_OUTPUT" - else - echo "npm_published=false" >> "$GITHUB_OUTPUT" fi - name: Create MCP git tag diff --git a/src/package-release-boundaries.test.ts b/src/package-release-boundaries.test.ts index df186ef1..32a9dac4 100644 --- a/src/package-release-boundaries.test.ts +++ b/src/package-release-boundaries.test.ts @@ -70,10 +70,22 @@ describe("package release boundaries", () => { const publishIndex = workflow.indexOf( "- name: Publish @githits/mcp to npm", ); + const npmPublishedCheckIndex = workflow.indexOf( + 'if npm view "@githits/mcp@$VERSION" version', + ); + const tagHeadCheckIndex = workflow.indexOf( + "Existing tag $TAG points to $TAG_COMMIT, not HEAD $HEAD_COMMIT", + ); expect(workflow).toContain('TAG_REF="refs/tags/$TAG"'); expect(workflow).toContain('git rev-parse --verify "$TAG_REF^{commit}"'); + expect(workflow).toContain( + 'if [ "$NPM_PUBLISHED" != "true" ] && [ "$TAG_COMMIT" != "$HEAD_COMMIT" ]; then', + ); expect(workflow).toContain('git push origin "refs/tags/$TAG"'); + expect(npmPublishedCheckIndex).toBeGreaterThan(-1); + expect(tagHeadCheckIndex).toBeGreaterThan(-1); + expect(npmPublishedCheckIndex).toBeLessThan(tagHeadCheckIndex); expect(createTagIndex).toBeGreaterThan(-1); expect(publishIndex).toBeGreaterThan(-1); expect(createTagIndex).toBeLessThan(publishIndex);