1616jobs :
1717 bump-version :
1818 runs-on : ubuntu-latest
19+ permissions :
20+ contents : write
21+ pull-requests : write
1922 steps :
2023 - name : Checkout code
2124 uses : actions/checkout@v5
@@ -37,32 +40,40 @@ jobs:
3740 - name : Install dependencies
3841 run : pnpm install --frozen-lockfile
3942
40- - name : Generate new version
41- id : version
43+ # Create release branch first
44+ - name : Create release branch
45+ run : |
46+ NEW_VERSION=$(node -p "require('./package.json').version")
47+ echo "current_version=$NEW_VERSION" >> $GITHUB_ENV
48+ echo "Checking out release branch..."
49+ git checkout -b release/temp || true
50+
51+ # Bump version & commit on the new branch
52+ - name : Bump version and commit
4253 run : |
4354 NEW_VERSION=$(pnpm version ${{ inputs.release_type }} --no-git-tag-version | awk '{print $NF}')
4455 echo "new_version=$NEW_VERSION" >> $GITHUB_ENV
4556 echo "New version: $NEW_VERSION"
4657
47- - name : Create release branch
48- run : git checkout -b release/${{ env.new_version }}
49-
50- - name : Commit version bump
51- run : |
5258 git config user.name "github-actions[bot]"
5359 git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
60+
5461 git add package.json pnpm-lock.yaml
5562 if git diff --cached --quiet; then
5663 echo "⚠️ No version bump changes detected. Skipping commit & PR."
5764 exit 0
5865 fi
59- git commit -m "chore(release): bump version to ${{ env.new_version }}"
60- git push origin release/${{ env.new_version }}
66+
67+ git commit -m "chore(release): bump version to $NEW_VERSION"
68+
69+ # Rename branch with actual version number
70+ git branch -m release/$NEW_VERSION
71+ git push origin release/$NEW_VERSION
6172
6273 - name : Check if branch has differences
6374 run : |
6475 if git diff origin/main..origin/release/${{ env.new_version }} --quiet; then
65- echo "⚠️ No changes detected between main and release/${{ env.new_version}}. Skipping PR."
76+ echo "⚠️ No changes detected between main and release/${{ env.new_version }}. Skipping PR."
6677 exit 0
6778 fi
6879
0 commit comments