Skip to content

Commit 6f85271

Browse files
committed
refactor: simplify npm tag determination in GitHub Actions workflow
1 parent 1394fe0 commit 6f85271

File tree

1 file changed

+3
-50
lines changed

1 file changed

+3
-50
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -94,57 +94,10 @@ jobs:
9494
- name: Determine npm tag
9595
if: success()
9696
run: |
97-
echo "Determining npm tag for publishing..."
98-
99-
# Get current version from framework package
100-
CURRENT_VERSION=$(node -p "require('./framework/package.json').version")
101-
echo "Current version: $CURRENT_VERSION"
102-
103-
# Strategy 1: Get npm tag from git tag (most reliable)
104-
GIT_TAG=$(git describe --tags --exact-match HEAD 2>/dev/null || echo "")
105-
if [ ! -z "$GIT_TAG" ]; then
106-
echo "Found git tag: $GIT_TAG"
107-
# Extract npm tag from git tag (e.g., v1.1.98-rc.3 -> rc)
108-
if [[ "$GIT_TAG" == *"-rc"* ]]; then
109-
NPM_TAG="rc"
110-
elif [[ "$GIT_TAG" == *"-alpha"* ]]; then
111-
NPM_TAG="alpha"
112-
elif [[ "$GIT_TAG" == *"-beta"* ]]; then
113-
NPM_TAG="beta"
114-
elif [[ "$GIT_TAG" == *"-next"* ]]; then
115-
NPM_TAG="next"
116-
else
117-
NPM_TAG="latest"
118-
fi
119-
echo "Using npm tag from git tag: $NPM_TAG"
120-
else
121-
# Strategy 2: Analyze version pattern (fallback)
122-
if [[ "$CURRENT_VERSION" == *"-rc"* ]]; then
123-
NPM_TAG="rc"
124-
elif [[ "$CURRENT_VERSION" == *"-alpha"* ]]; then
125-
NPM_TAG="alpha"
126-
elif [[ "$CURRENT_VERSION" == *"-beta"* ]]; then
127-
NPM_TAG="beta"
128-
elif [[ "$CURRENT_VERSION" == *"-next"* ]]; then
129-
NPM_TAG="next"
130-
else
131-
NPM_TAG="latest"
132-
fi
133-
echo "Using version-based tag (no git tag found): $NPM_TAG"
134-
fi
135-
136-
# Strategy 3: Check commit message for explicit tag (override)
137-
COMMIT_MESSAGE=$(git log -1 --pretty=%B)
138-
if [[ "$COMMIT_MESSAGE" == *"npmTag:"* ]]; then
139-
COMMIT_TAG=$(echo "$COMMIT_MESSAGE" | grep -o "npmTag:[a-zA-Z0-9-]*" | cut -d: -f2)
140-
if [ ! -z "$COMMIT_TAG" ]; then
141-
NPM_TAG="$COMMIT_TAG"
142-
echo "Using tag from commit message (override): $NPM_TAG"
143-
fi
144-
fi
145-
97+
VERSION=$(node -p "require('./framework/package.json').version")
98+
NPM_TAG=$(node -e "const m='$VERSION'.match(/-(alpha|beta|rc|next)/); console.log(m?m[1]:'latest')")
99+
echo "Version: $VERSION → npm tag: $NPM_TAG"
146100
echo "NPM_TAG=$NPM_TAG" >> $GITHUB_ENV
147-
echo "Final npm tag: $NPM_TAG"
148101
149102
- name: Publish with Lerna
150103
if: success()

0 commit comments

Comments
 (0)