Skip to content

Commit 950dd9a

Browse files
committed
create pr for version bump gh bot
1 parent a9ab4aa commit 950dd9a

File tree

1 file changed

+61
-8
lines changed

1 file changed

+61
-8
lines changed

.github/workflows/publish.yml

Lines changed: 61 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ on:
2020

2121
permissions:
2222
contents: write
23+
pull-requests: write
2324

2425
jobs:
2526
build-and-publish:
@@ -108,11 +109,68 @@ jobs:
108109
git config --local user.email "[email protected]"
109110
git config --local user.name "GitHub Action"
110111
111-
- name: Commit version bump
112+
- name: Create version bump branch and PR
113+
env:
114+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
112115
run: |
116+
NEW_VERSION="${{ steps.version.outputs.new_version }}"
117+
BRANCH_NAME="release/v${NEW_VERSION}"
118+
119+
# Create and switch to new branch
120+
git checkout -b "$BRANCH_NAME"
121+
122+
# Commit changes
113123
git add pyproject.toml stagehand/__init__.py
114-
git commit -m "Bump version to ${{ steps.version.outputs.new_version }}"
115-
git tag "v${{ steps.version.outputs.new_version }}"
124+
git commit -m "Bump version to v${NEW_VERSION}"
125+
126+
# Push branch
127+
git push origin "$BRANCH_NAME"
128+
129+
# Create PR
130+
gh pr create \
131+
--title "Release v${NEW_VERSION}" \
132+
--body "Automated version bump to v${NEW_VERSION} for ${{ github.event.inputs.release_type }} release." \
133+
--base main \
134+
--head "$BRANCH_NAME"
135+
136+
- name: Wait for PR to be merged
137+
env:
138+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
139+
run: |
140+
NEW_VERSION="${{ steps.version.outputs.new_version }}"
141+
BRANCH_NAME="release/v${NEW_VERSION}"
142+
143+
echo "Waiting for PR to be merged..."
144+
145+
# Wait for PR to be merged (check every 30 seconds for up to 10 minutes)
146+
for i in {1..20}; do
147+
if gh pr view "$BRANCH_NAME" --json state --jq '.state' | grep -q "MERGED"; then
148+
echo "PR has been merged!"
149+
break
150+
elif gh pr view "$BRANCH_NAME" --json state --jq '.state' | grep -q "CLOSED"; then
151+
echo "PR was closed without merging. Exiting."
152+
exit 1
153+
else
154+
echo "PR is still open. Waiting 30 seconds... (attempt $i/20)"
155+
sleep 30
156+
fi
157+
158+
if [ $i -eq 20 ]; then
159+
echo "Timeout waiting for PR to be merged."
160+
exit 1
161+
fi
162+
done
163+
164+
- name: Checkout main and create tag
165+
run: |
166+
# Switch back to main and pull latest changes
167+
git checkout main
168+
git pull origin main
169+
170+
# Create and push tag
171+
NEW_VERSION="${{ steps.version.outputs.new_version }}"
172+
git tag "v${NEW_VERSION}"
173+
git push origin "v${NEW_VERSION}"
116174
117175
- name: Build package
118176
run: |
@@ -125,11 +183,6 @@ jobs:
125183
run: |
126184
twine upload dist/*
127185
128-
- name: Push version bump
129-
run: |
130-
git push
131-
git push --tags
132-
133186
- name: Create GitHub Release
134187
if: ${{ github.event.inputs.create_release == 'true' }}
135188
uses: softprops/action-gh-release@v1

0 commit comments

Comments
 (0)