Skip to content

Commit ebf909c

Browse files
committed
chore: update release workflow to create PR instead of direct push
1 parent f5143c2 commit ebf909c

File tree

1 file changed

+42
-4
lines changed

1 file changed

+42
-4
lines changed

.github/workflows/release.yml

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
runs-on: ubuntu-latest
2222
permissions:
2323
contents: write
24+
pull-requests: write
2425

2526
steps:
2627
- name: Checkout
@@ -54,9 +55,11 @@ jobs:
5455
echo "next=$NEXT" >> $GITHUB_OUTPUT
5556
echo "Bumping from $CURRENT to $NEXT"
5657
57-
- name: Update version files
58+
- name: Create version bump branch and PR
59+
id: pr
5860
run: |
5961
VERSION="${{ steps.version.outputs.next }}"
62+
BRANCH="release/v$VERSION"
6063
6164
# Update extension.yaml
6265
sed -i "s/^version: .*/version: $VERSION/" cli/extension.yaml
@@ -75,14 +78,49 @@ jobs:
7578
cat CHANGELOG.md
7679
} > CHANGELOG.new.md
7780
mv CHANGELOG.new.md CHANGELOG.md
78-
79-
# Commit version bump
8081
cd ..
82+
83+
# Create branch and push
8184
git config user.name "github-actions[bot]"
8285
git config user.email "github-actions[bot]@users.noreply.github.com"
86+
git checkout -b "$BRANCH"
8387
git add cli/extension.yaml cli/CHANGELOG.md
8488
git commit -m "chore: bump version to $VERSION"
85-
git push
89+
git push origin "$BRANCH"
90+
91+
# Create PR
92+
PR_URL=$(gh pr create \
93+
--base main \
94+
--head "$BRANCH" \
95+
--title "chore: release v$VERSION" \
96+
--body "Automated release for version $VERSION")
97+
98+
echo "pr_url=$PR_URL" >> $GITHUB_OUTPUT
99+
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
100+
env:
101+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
102+
103+
- name: Auto-merge PR and wait
104+
run: |
105+
# Enable auto-merge
106+
gh pr merge "${{ steps.pr.outputs.pr_url }}" --squash --auto
107+
108+
# Wait for PR to be merged (checks will run)
109+
echo "Waiting for CI checks and PR merge..."
110+
for i in {1..60}; do
111+
if gh pr view "${{ steps.pr.outputs.pr_url }}" --json state --jq .state | grep -q "MERGED"; then
112+
echo "PR merged successfully!"
113+
break
114+
fi
115+
echo "Waiting... ($i/60)"
116+
sleep 10
117+
done
118+
119+
# Pull latest main
120+
git checkout main
121+
git pull origin main
122+
env:
123+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
86124

87125
- name: Set up Node.js
88126
uses: actions/setup-node@v4

0 commit comments

Comments
 (0)