From 2c1355e5af38c4488d2833fca155c6d0665cbc9b Mon Sep 17 00:00:00 2001 From: Iago Araujo Date: Wed, 5 Aug 2026 16:07:55 -0300 Subject: [PATCH] fix(ci): publish releases under an explicit dist-tag npm refuses to implicitly move "latest" backwards, so publishing 6.51.1 failed because 7.4.2 already holds that tag. The publish step now resolves the dist-tag from the major version, keeping the 7.x line on "latest" and sending older majors to their own tag. Co-authored-by: Cursor --- .github/workflows/publish-npm.yml | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index 5ae31c61f..0dfd1dc8a 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -87,9 +87,23 @@ jobs: set -euo pipefail TARBALL=$(ls -1 *.tgz | head -n 1) - TAG_FLAG="" - if [ "${{ github.event.inputs.environment }}" = "beta" ]; then - TAG_FLAG="--tag beta" + VERSION="${{ github.event.inputs.version }}" + ENVIRONMENT="${{ github.event.inputs.environment }}" + + if [ "${ENVIRONMENT}" = "beta" ]; then + TAG="beta" + else + # The version input carries the git tag name, so it may be prefixed with "v". + MAJOR="${VERSION%%.*}" + MAJOR="${MAJOR#v}" + # npm refuses to implicitly move "latest" backwards, so majors below the + # current one publish under their own dist-tag instead. + if [ "${MAJOR}" -ge 7 ]; then + TAG="latest" + else + TAG="v${MAJOR}-latest" + fi fi - echo "Publishing ${TARBALL} to npmjs..." - npm publish "${TARBALL}" --provenance --access public ${TAG_FLAG} + + echo "Publishing ${TARBALL} to npmjs with tag ${TAG}..." + npm publish "${TARBALL}" --provenance --access public --tag "${TAG}"