diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9f60e0c1..5d3a1a6d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -72,11 +72,19 @@ jobs: run: | cd packages/${{ github.event.inputs.package }} 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 - 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 - 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"