From 53940916a0f373842c48d86cf3369fe3e30fa044 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Fri, 19 Sep 2025 11:50:17 -0700 Subject: [PATCH] ci: fix release.yml (#4773) --- .github/workflows/release.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cfd2c56ad9..f5d333c90a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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