|
63 | 63 | pnpm run build:stable
|
64 | 64 | fi
|
65 | 65 |
|
| 66 | + - name: Get current version |
| 67 | + id: current_version |
| 68 | + run: | |
| 69 | + CURRENT_VERSION=$(node -p "require('./package.json').version") |
| 70 | + echo "version=${CURRENT_VERSION}" >> $GITHUB_OUTPUT |
| 71 | +
|
| 72 | + - name: Calculate new version |
| 73 | + id: new_version |
| 74 | + run: | |
| 75 | + CURRENT_VERSION="${{ steps.current_version.outputs.version }}" |
| 76 | + if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then |
| 77 | + # Split version into parts |
| 78 | + IFS='.' read -r -a version_parts <<< "$CURRENT_VERSION" |
| 79 | + PATCH=$((version_parts[2] + 1)) |
| 80 | + NEW_VERSION="${version_parts[0]}.${version_parts[1]}.${PATCH}" |
| 81 | + |
| 82 | + if [[ "${{ steps.release_type.outputs.type }}" == "alpha" ]]; then |
| 83 | + NEW_VERSION="${NEW_VERSION}-alpha" |
| 84 | + fi |
| 85 | + else |
| 86 | + NEW_VERSION="$CURRENT_VERSION" |
| 87 | + fi |
| 88 | + echo "version=${NEW_VERSION}" >> $GITHUB_OUTPUT |
| 89 | +
|
| 90 | + - name: Update package.json |
| 91 | + if: github.event_name == 'workflow_dispatch' |
| 92 | + run: | |
| 93 | + NEW_VERSION="${{ steps.new_version.outputs.version }}" |
| 94 | + # Use node to update package.json to preserve formatting |
| 95 | + node -e " |
| 96 | + const fs = require('fs'); |
| 97 | + const package = JSON.parse(fs.readFileSync('package.json')); |
| 98 | + package.version = '$NEW_VERSION'; |
| 99 | + fs.writeFileSync('package.json', JSON.stringify(package, null, 2) + '\n'); |
| 100 | + " |
| 101 | +
|
| 102 | + - name: Commit version update |
| 103 | + if: github.event_name == 'workflow_dispatch' |
| 104 | + run: | |
| 105 | + git config user.name 'github-actions[bot]' |
| 106 | + git config user.email 'github-actions[bot]@users.noreply.github.com' |
| 107 | + git add package.json |
| 108 | + git commit -m "chore: update package.json version to ${{ steps.new_version.outputs.version }}" |
| 109 | + git push |
| 110 | +
|
66 | 111 | - name: Get Package Version
|
67 | 112 | id: package_version
|
68 | 113 | run: |
|
|
0 commit comments