ci: fix release.yml (#4773)

This commit is contained in:
Alex Yang
2025-09-19 11:50:17 -07:00
committed by GitHub
parent b3ead859e6
commit a3e46c1b70

View File

@@ -45,13 +45,18 @@ jobs:
# Extract pre-release tag (e.g., beta, rc)
NPM_TAG=${BASH_REMATCH[1]}
else
# Check if the commit is on the main branch
# Check if the commit is on the main branch or a version branch
git fetch origin main
if git merge-base --is-ancestor "$GITHUB_SHA" origin/main; then
CURRENT_BRANCH=$(git branch -r --contains "$GITHUB_SHA" | grep -E 'origin/(main|v[0-9]+\.[0-9]+\.x-latest)' | head -1 | sed 's/.*origin\///')
if [[ "$CURRENT_BRANCH" == "main" ]]; then
NPM_TAG="latest"
elif [[ "$CURRENT_BRANCH" =~ ^v[0-9]+\.[0-9]+\.x-latest$ ]]; then
# For version branches like v1.3.x-latest, v1.4.x-latest, use "latest" tag
NPM_TAG="latest"
else
echo "The tagged commit is not on the main branch."
echo "::error ::Releases with the 'latest' npm tag must be on the main branch."
echo "The tagged commit is not on the main branch or a version branch (v*.*.x-latest)."
echo "::error ::Releases with the 'latest' npm tag must be on the main branch or a version branch."
exit 1
fi
fi