Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 18 additions & 21 deletions .github/workflows/create-tag-and-exit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:

permissions:
contents: write
pull-requests: write

jobs:
tag:
Expand Down Expand Up @@ -73,7 +74,9 @@ jobs:
echo ""
done >> CHANGELOG.md

- name: Commit and push CHANGELOG.md
- name: Create PR for CHANGELOG.md update
env:
GH_TOKEN: ${{ github.token }}
run: |
git config user.name "github-actions"
git config user.email "github-actions@github.com"
Expand All @@ -82,25 +85,19 @@ jobs:
echo "No changelog changes to commit"
exit 0
fi

BRANCH_NAME="chore/update-changelog-${{ steps.version.outputs.tag }}"
git checkout -B "$BRANCH_NAME"
git commit -m "chore: update changelog for ${{ steps.version.outputs.tag }}"
git push --force-with-lease origin "$BRANCH_NAME"

# Pull with rebase and push, with retry on failure
max_retries=3
for i in $(seq 1 $max_retries); do
git fetch origin main
if ! git rebase origin/main; then
if git diff --name-only --diff-filter=U | grep -q .; then
echo "Rebase failed due to conflicts; aborting."
git rebase --abort
exit 1
fi
echo "Rebase failed; aborting."
git rebase --abort || true
exit 1
fi
git push origin main && exit 0
echo "Push attempt $i failed, retrying..."
sleep 2
done
echo "Failed to push after $max_retries attempts"
exit 1
# Create PR only if one doesn't already exist for this branch
if gh pr view "$BRANCH_NAME" --json state -q '.state' 2>/dev/null | grep -q "OPEN"; then
echo "PR already exists for $BRANCH_NAME; skipping creation."
else
gh pr create \
--title "chore: update changelog for ${{ steps.version.outputs.tag }}" \
--body "Automated changelog update for release ${{ steps.version.outputs.tag }}" \
--base main \
--head "$BRANCH_NAME"
fi