fix(ci): 使用纯 bash+node 实现版本更新绕过 workspace 协议问题

This commit is contained in:
yhh
2025-11-23 22:49:54 +08:00
parent eea7ed9e58
commit 8ab25fe293

View File

@@ -72,11 +72,19 @@ jobs:
run: | run: |
cd packages/${{ github.event.inputs.package }} cd packages/${{ github.event.inputs.package }}
if [ "${{ github.event.inputs.version_type }}" = "custom" ]; then if [ "${{ github.event.inputs.version_type }}" = "custom" ]; then
pnpm version ${{ github.event.inputs.custom_version }} --no-git-tag-version --allow-same-version NEW_VERSION=${{ github.event.inputs.custom_version }}
else else
pnpm version ${{ github.event.inputs.version_type }} --no-git-tag-version # Get current version and bump it
CURRENT=$(node -p "require('./package.json').version")
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT"
case "${{ github.event.inputs.version_type }}" in
major) NEW_VERSION="$((MAJOR+1)).0.0" ;;
minor) NEW_VERSION="$MAJOR.$((MINOR+1)).0" ;;
patch) NEW_VERSION="$MAJOR.$MINOR.$((PATCH+1))" ;;
esac
fi fi
NEW_VERSION=$(node -p "require('./package.json').version") # Update package.json using node
node -e "const fs=require('fs'); const pkg=JSON.parse(fs.readFileSync('package.json')); pkg.version='$NEW_VERSION'; fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2)+'\n')"
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "发布版本: $NEW_VERSION" echo "发布版本: $NEW_VERSION"