11name : Update Stable Branch
22
33on :
4- pull_request :
5- types : [closed]
4+ push :
65 branches :
76 - main
87
98permissions :
109 contents : write
1110
1211jobs :
13- update-stable :
14- if : github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name , 'stable- release')
12+ prepare-release :
13+ if : contains(github.event.head_commit.message , '# release')
1514 runs-on : ubuntu-latest
16- permissions :
17- contents : write
18- pull-requests : read
1915
2016 steps :
2117 - uses : actions/checkout@v4
2218 with :
2319 fetch-depth : 0
24- token : ${{ secrets.GITHUB_TOKEN }}
20+
2521 - name : Configure Git
2622 run : |
2723 git config --global user.name 'github-actions[bot]'
5248 restore-keys : |
5349 ${{ runner.os }}-pnpm-store-
5450
55- - name : Determine Version Bump
56- id : version_bump
57- run : |
58- if [[ "${{ contains(github.event.pull_request.labels.*.name, 'major') }}" == "true" ]]; then
59- echo "bump=major" >> $GITHUB_OUTPUT
60- elif [[ "${{ contains(github.event.pull_request.labels.*.name, 'minor') }}" == "true" ]]; then
61- echo "bump=minor" >> $GITHUB_OUTPUT
62- else
63- echo "bump=patch" >> $GITHUB_OUTPUT
64- fi
65-
6651 - name : Get Current Version
6752 id : current_version
6853 run : |
7257 - name : Install semver
7358 run : pnpm add -g semver
7459
60+ - name : Determine Version Bump
61+ id : version_bump
62+ run : |
63+ COMMIT_MSG="${{ github.event.head_commit.message }}"
64+ if [[ $COMMIT_MSG =~ "#release:major" ]]; then
65+ echo "bump=major" >> $GITHUB_OUTPUT
66+ elif [[ $COMMIT_MSG =~ "#release:minor" ]]; then
67+ echo "bump=minor" >> $GITHUB_OUTPUT
68+ else
69+ echo "bump=patch" >> $GITHUB_OUTPUT
70+ fi
71+
7572 - name : Bump Version
7673 id : bump_version
7774 run : |
@@ -161,32 +158,30 @@ jobs:
161158 echo "$CHANGELOG_CONTENT" >> $GITHUB_OUTPUT
162159 echo "EOF" >> $GITHUB_OUTPUT
163160
164- - name : Commit Version Update
161+ - name : Commit and Tag Release
165162 run : |
166163 git pull
167164 git add package.json pnpm-lock.yaml changelog.md
168- git commit -m "chore: bump version to ${{ steps.bump_version.outputs.new_version }}"
165+ git commit -m "chore: release version ${{ steps.bump_version.outputs.new_version }}"
166+ git tag "v${{ steps.bump_version.outputs.new_version }}"
169167 git push
168+ git push --tags
170169
171170 - name : Update Stable Branch
172171 run : |
173- # Ensure stable branch exists
174- git checkout stable 2>/dev/null || git checkout -b stable
175- git merge main --no-ff -m "chore: merge main into stable for version ${{ steps.bump_version.outputs.new_version }}"
176- git push --set-upstream origin stable
172+ if ! git checkout stable 2>/dev/null; then
173+ echo "Creating new stable branch..."
174+ git checkout -b stable
175+ fi
176+ git merge main --no-ff -m "chore: release version ${{ steps.bump_version.outputs.new_version }}"
177+ git push --set-upstream origin stable --force
177178
178- - name : Create and Push Tag
179+ - name : Create GitHub Release
180+ env :
181+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
179182 run : |
180183 VERSION="v${{ steps.bump_version.outputs.new_version }}"
181- git tag -a "$VERSION" -m "Release $VERSION"
182- git push origin "$VERSION"
183-
184- # - name: Create GitHub Release
185- # env:
186- # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
187- # run: |
188- # VERSION="v${{ steps.bump_version.outputs.new_version }}"
189- # gh release create "$VERSION" \
190- # --title "Release $VERSION" \
191- # --notes "${{ steps.changelog.outputs.content }}" \
192- # --target stable
184+ gh release create "$VERSION" \
185+ --title "Release $VERSION" \
186+ --notes "${{ steps.changelog.outputs.content }}" \
187+ --target stable
0 commit comments