Skip to content

Commit 2ef07aa

Browse files
committed
fix(ci): use version-specific npm tag for version branches
1 parent 032691f commit 2ef07aa

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

.github/workflows/release.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,19 @@ jobs:
4545
# Extract pre-release tag (e.g., beta, rc)
4646
NPM_TAG=${BASH_REMATCH[1]}
4747
else
48-
# Check if the commit is on the main branch
48+
# Check if the commit is on the main branch or a version branch
4949
git fetch origin main
50-
if git merge-base --is-ancestor "$GITHUB_SHA" origin/main; then
50+
CURRENT_BRANCH=$(git branch -r --contains "$GITHUB_SHA" | grep -E 'origin/(main|v[0-9]+\.[0-9]+\.x)' | head -1 | sed 's/.*origin\///')
51+
52+
if [[ "$CURRENT_BRANCH" == "main" ]]; then
5153
NPM_TAG="latest"
54+
elif [[ "$CURRENT_BRANCH" =~ ^v([0-9]+\.[0-9]+)\.x$ ]]; then
55+
# For version branches like v1.3.x, v1.4.x, use the version as npm tag
56+
# Use "release-X.Y" format to avoid SemVer range conflict (npm rejects "1.4" and "v1.4")
57+
NPM_TAG="release-${BASH_REMATCH[1]}"
5258
else
53-
echo "The tagged commit is not on the main branch."
54-
echo "::error ::Releases with the 'latest' npm tag must be on the main branch."
59+
echo "The tagged commit is not on the main branch or a version branch (v*.*.x)."
60+
echo "::error ::Releases must be on the main branch or a version branch (v*.*.x)."
5561
exit 1
5662
fi
5763
fi

0 commit comments

Comments
 (0)