Skip to content

Conversation

manudeli
Copy link
Collaborator

@manudeli manudeli commented May 28, 2025

We can check failed workflow

Below is the error message

Publishing all packages to npm with tag "v4"
  Publishing @tanstack/[email protected] to npm...
  npm error Tag name must not be a valid SemVer range: v4
  npm error A complete log of this run can be found in: /home/runner/.npm/_logs/2025-05-26T12_12_25_592Z-debug-0.log
  Error: Command failed: cd /home/runner/work/query/query/packages/query-core && pnpm publish --tag v4 --access=public --no-git-checks

Fix publish failure when tag is set to v{number}

While publishing from the v4 branch of TanStack Query, we encountered an issue caused by the tag option. The current npm publish logic treats v4 as a valid SemVer range, which triggers an error:

Below is the publish function node/22.12.0/lib/node_modules/npm/lib/commands

image

I’ve tested this behavior locally with --dry-run, and the issue no longer occurs after rewriting --tag to query-v4 only for the v4 branch, not for main, beta, alpha, or rc.

AS-IS(Not work)

v4 is valid range of semver so It can't be npm tag name

pnpm publish --tag v4 // invalid tag name

To-BE(Work)

query-v4 is invalid range of semver, so it can be npm tag name

pnpm publish --tag query-v4 // valid tag name

@manudeli manudeli self-assigned this May 28, 2025
Copy link

nx-cloud bot commented May 28, 2025

View your CI Pipeline Execution ↗ for commit ab87f51.

Command Status Duration Result
nx affected --targets=test:eslint,test:lib,test... ✅ Succeeded 56s View ↗
nx affected --targets=test:lib --base=9af0b7546... ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2025-05-29 04:16:53 UTC

Copy link

codesandbox-ci bot commented May 28, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit ab87f51:

Sandbox Source
@tanstack/query-example-react-basic-typescript Configuration
@tanstack/query-example-solid-basic-typescript Configuration
@tanstack/query-example-svelte-basic Configuration
@tanstack/query-example-vue-basic Configuration

@manudeli manudeli requested review from TkDodo, Copilot and lachlancollins and removed request for Copilot May 28, 2025 18:04
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR addresses the npm publish error when using branch tags like v4 by conditionally omitting the --tag flag for purely numeric version branches.

  • Skip --tag argument if npmTag matches v<digits> to avoid SemVer range conflicts
  • Retain --tag for other channels (e.g., latest, beta, alpha, rc)
Comments suppressed due to low confidence (2)

scripts/publish.ts:376

  • [nitpick] The regex is clear but consider naming it or the predicate (e.g. isMajorBranchTag) to document intent and make the check self-explanatory.
/^v\d+$/.test(npmTag) ? `` : `--tag ${npmTag}`

scripts/publish.ts:374

  • Add unit tests or a dry-run integration test to verify that the command omits --tag correctly for tags like v4 and includes it for channels such as beta or rc.
const cmd = `cd ${packageDir} && pnpm publish ${

@manudeli manudeli marked this pull request as ready for review May 28, 2025 18:05
@TanStack TanStack deleted a comment from Copilot AI May 28, 2025
@lachlancollins
Copy link
Member

See #9225

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants