@@ -221,6 +221,7 @@ jobs:
221221 needs : [preflight, test, lint, build]
222222 permissions :
223223 contents : write
224+ pull-requests : write
224225
225226 steps :
226227 - name : Checkout
@@ -268,10 +269,19 @@ jobs:
268269 echo "next=$NEXT" >> $GITHUB_OUTPUT
269270 echo "Bumping from $CURRENT to $NEXT"
270271
271- - name : Update version files
272+ - name : Update version files and create PR
273+ id : version_pr
272274 working-directory : cli
275+ env :
276+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
273277 run : |
274278 VERSION="${{ steps.version.outputs.next }}"
279+ BRANCH="release/v${VERSION}"
280+
281+ # Create and switch to release branch
282+ git config user.name "github-actions[bot]"
283+ git config user.email "github-actions[bot]@users.noreply.github.com"
284+ git checkout -b "$BRANCH"
275285
276286 # Update extension.yaml
277287 sed -i "s/^version: .*/version: $VERSION/" extension.yaml
@@ -306,15 +316,71 @@ jobs:
306316 } > CHANGELOG.new.md
307317 mv CHANGELOG.new.md CHANGELOG.md
308318
309- # Commit version bump
319+ # Commit and push to branch
320+ git add extension.yaml CHANGELOG.md
321+ git commit -m "chore: bump version to $VERSION"
322+ git push origin "$BRANCH"
323+
324+ # Create PR
310325 cd ..
326+ PR_URL=$(gh pr create \
327+ --title "chore: Release v${VERSION}" \
328+ --body "Automated version bump to ${VERSION} for release." \
329+ --base main \
330+ --head "$BRANCH")
331+
332+ echo "pr_url=$PR_URL" >> $GITHUB_OUTPUT
333+ echo "branch=$BRANCH" >> $GITHUB_OUTPUT
334+
335+ # Extract PR number
336+ PR_NUMBER=$(echo "$PR_URL" | grep -oP '\d+$')
337+ echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT
338+
339+ - name : Wait for CI and auto-merge
340+ env :
341+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
342+ run : |
343+ PR_NUMBER="${{ steps.version_pr.outputs.pr_number }}"
344+
345+ echo "Waiting for CI checks to complete on PR #${PR_NUMBER}..."
346+
347+ # Enable auto-merge
348+ gh pr merge "$PR_NUMBER" --auto --squash
349+
350+ # Wait for PR to be merged (with timeout)
351+ TIMEOUT=600 # 10 minutes
352+ ELAPSED=0
353+ INTERVAL=10
354+
355+ while [ $ELAPSED -lt $TIMEOUT ]; do
356+ STATE=$(gh pr view "$PR_NUMBER" --json state --jq '.state')
357+
358+ if [ "$STATE" = "MERGED" ]; then
359+ echo "PR merged successfully!"
360+ break
361+ fi
362+
363+ echo "PR state: $STATE. Waiting..."
364+ sleep $INTERVAL
365+ ELAPSED=$((ELAPSED + INTERVAL))
366+ done
367+
368+ if [ "$STATE" != "MERGED" ]; then
369+ echo "ERROR: PR did not merge within timeout"
370+ exit 1
371+ fi
372+
373+ - name : Checkout main and create tag
374+ run : |
375+ VERSION="${{ steps.version.outputs.next }}"
376+
377+ # Switch to main and pull latest
378+ git checkout main
379+ git pull origin main
380+
381+ # Create and push version tag
311382 git config user.name "github-actions[bot]"
312383 git config user.email "github-actions[bot]@users.noreply.github.com"
313- git add cli/extension.yaml cli/CHANGELOG.md
314- git commit -m "chore: bump version to $VERSION"
315- git push
316-
317- # Create and push version tag for future releases
318384 git tag -a "v${VERSION}" -m "Release version ${VERSION}"
319385 git push origin "v${VERSION}"
320386
0 commit comments