Skip to content

Commit 3770c01

Browse files
committed
ci: pipeline improvement
1 parent 2355e8a commit 3770c01

1 file changed

Lines changed: 38 additions & 37 deletions

File tree

.github/workflows/version-bump.yaml

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ on:
44
workflow_dispatch:
55
inputs:
66
release_type:
7-
description: 'Select version bump type'
7+
description: "Select version bump type"
88
required: true
9-
default: 'patch'
9+
default: "patch"
1010
type: choice
1111
options:
1212
- patch
@@ -17,55 +17,56 @@ jobs:
1717
bump-version:
1818
runs-on: ubuntu-latest
1919
steps:
20-
- name: Checkout code
21-
uses: actions/checkout@v5
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
2222
with:
23-
token: ${{ secrets.GITHUB_TOKEN }}
2423
fetch-depth: 0
2524

26-
- name: Setup pnpm
27-
uses: pnpm/action-setup@v4
28-
with:
29-
version: 10.13.1
30-
run_install: false
31-
32-
- name: Set up Node
25+
- name: Setup Node.js
3326
uses: actions/setup-node@v4
3427
with:
35-
node-version: 22
28+
node-version: 20
3629

37-
- name: Install dependencies
38-
run: pnpm install --frozen-lockfile
30+
- name: Setup pnpm
31+
uses: pnpm/action-setup@v4
32+
with:
33+
version: 9
34+
run_install: true
3935

40-
- name: Generate new version
41-
id: version
36+
- name: Configure Git
4237
run: |
43-
NEW_VERSION=$(pnpm version ${{ inputs.release_type }} --no-git-tag-version | awk '{print $NF}')
44-
echo "new_version=$NEW_VERSION" >> $GITHUB_ENV
38+
git config user.name "github-actions[bot]"
39+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
4540
46-
- name: Create new branch
41+
- name: Bump version and commit to main
42+
id: bump
4743
run: |
48-
git checkout -b release/${{ env.new_version }}
44+
RAW_VERSION=$(pnpm version ${{ inputs.release_type }} --no-git-tag-version | tail -n1)
45+
CLEAN_VERSION=$(echo "$RAW_VERSION" | sed 's/^v//')
46+
47+
echo "raw_version=$RAW_VERSION" >> $GITHUB_ENV
48+
echo "clean_version=$CLEAN_VERSION" >> $GITHUB_ENV
4949
50-
- name: Commit & Push changes
51-
run: |
52-
git config user.name "github-actions[bot]"
53-
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
5450
git add package.json pnpm-lock.yaml
55-
git commit -m "chore(release): bump version to ${{ env.new_version }}"
56-
git push origin release/${{ env.new_version }}
51+
if git diff --cached --quiet; then
52+
echo "⚠️ No version bump changes detected. Skipping commit & PR."
53+
exit 0
54+
fi
5755
58-
- name: Create Pull Request
56+
git commit -m "chore(release): bump version to $RAW_VERSION"
57+
git push origin main
58+
59+
- name: Create release branch
5960
run: |
60-
gh pr create \
61-
--base main \
62-
--head release/${{ env.new_version }} \
63-
--title "Release: ${{ env.new_version }}" \
64-
--body "Auto-generated release PR for version ${{ env.new_version }}"
61+
git checkout -b release/v${{ env.clean_version }}
62+
git push origin release/v${{ env.clean_version }}
63+
64+
- name: Create Pull Request
6565
env:
6666
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67-
68-
- name: Notify about Major Release (if major)
69-
if: inputs.release_type == 'major'
7067
run: |
71-
echo "🚨 Major version update detected! Please review and merge manually."
68+
gh pr create \
69+
--base main \
70+
--head release/v${{ env.clean_version }} \
71+
--title "Release: v${{ env.raw_version }}" \
72+
--body "Auto-generated release PR for version ${{ env.raw_version }}"

0 commit comments

Comments
 (0)