Skip to content

Commit 658ab2a

Browse files
authored
fix: release-trigger uses release branch + PR instead of direct push to main (#1733)
* fix: use release branch + PR instead of direct push to main Bypass branch protection rules by pushing version bump to a chore/release-vX.Y.Z branch, tagging that commit, then opening an auto PR to merge back into main. The release workflow still triggers immediately from the tag push. * fix: remove --label automated from gh pr create (label does not exist)
1 parent 2c41d36 commit 658ab2a

File tree

2 files changed

+55
-28
lines changed

2 files changed

+55
-28
lines changed

.github/workflows/RELEASE-PROCESS.md

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,10 @@ The workflow will:
6060
- Auto-increment the patch version (e.g., `0.1.10``0.1.11`)
6161
- Update `pyproject.toml`
6262
- Update `CHANGELOG.md` by adding a new section for the release based on commits since the last tag
63-
- Commit changes
64-
- Create and push git tag
65-
- Trigger the release workflow automatically
63+
- Commit changes to a `chore/release-vX.Y.Z` branch
64+
- Create and push the git tag from that branch
65+
- Open a PR to merge the version bump into `main`
66+
- Trigger the release workflow automatically via the tag push
6667

6768
### Option 2: Manual Version (For major/minor bumps)
6869

@@ -75,19 +76,23 @@ The workflow will:
7576
- Use your specified version
7677
- Update `pyproject.toml`
7778
- Update `CHANGELOG.md` by adding a new section for the release based on commits since the last tag
78-
- Commit changes
79-
- Create and push git tag
80-
- Trigger the release workflow automatically
79+
- Commit changes to a `chore/release-vX.Y.Z` branch
80+
- Create and push the git tag from that branch
81+
- Open a PR to merge the version bump into `main`
82+
- Trigger the release workflow automatically via the tag push
8183

8284
## What Happens Next
8385

8486
Once the release trigger workflow completes:
8587

86-
1. The git tag is pushed to GitHub
87-
2. The **Release Workflow** is automatically triggered
88-
3. Release artifacts are built for all supported agents
89-
4. A GitHub Release is created with all assets
90-
5. Release notes are generated from PR titles
88+
1. A `chore/release-vX.Y.Z` branch is pushed with the version bump commit
89+
2. The git tag is pushed, pointing to that commit
90+
3. The **Release Workflow** is automatically triggered by the tag push
91+
4. Release artifacts are built for all supported agents
92+
5. A GitHub Release is created with all assets
93+
6. A PR is opened to merge the version bump branch into `main`
94+
95+
> **Note**: Merge the auto-opened PR after the release is published to keep `main` in sync.
9196
9297
## Workflow Details
9398

@@ -103,10 +108,12 @@ Once the release trigger workflow completes:
103108
1. Checkout repository
104109
2. Determine version (manual or auto-increment)
105110
3. Check if tag already exists (prevents duplicates)
106-
4. Update `pyproject.toml`
107-
5. Update `CHANGELOG.md`
108-
6. Commit changes
109-
7. Create and push tag
111+
4. Create `chore/release-vX.Y.Z` branch
112+
5. Update `pyproject.toml`
113+
6. Update `CHANGELOG.md` from git commits
114+
7. Commit changes
115+
8. Push branch and tag
116+
9. Open PR to merge version bump into `main`
110117

111118
### Release Workflow
112119

.github/workflows/release-trigger.yml

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ jobs:
1313
runs-on: ubuntu-latest
1414
permissions:
1515
contents: write
16+
pull-requests: write
1617
steps:
1718
- name: Checkout repository
1819
uses: actions/checkout@v6
@@ -45,18 +46,18 @@ jobs:
4546
# Auto-increment patch version
4647
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
4748
echo "Latest tag: $LATEST_TAG"
48-
49+
4950
# Extract version number and increment
5051
VERSION=$(echo $LATEST_TAG | sed 's/v//')
5152
IFS='.' read -ra VERSION_PARTS <<< "$VERSION"
5253
MAJOR=${VERSION_PARTS[0]:-0}
5354
MINOR=${VERSION_PARTS[1]:-0}
5455
PATCH=${VERSION_PARTS[2]:-0}
55-
56+
5657
# Increment patch version
5758
PATCH=$((PATCH + 1))
5859
NEW_VERSION="$MAJOR.$MINOR.$PATCH"
59-
60+
6061
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
6162
echo "tag=v$NEW_VERSION" >> $GITHUB_OUTPUT
6263
echo "Auto-incremented version: $NEW_VERSION"
@@ -69,6 +70,12 @@ jobs:
6970
exit 1
7071
fi
7172
73+
- name: Create release branch
74+
run: |
75+
BRANCH="chore/release-${{ steps.version.outputs.tag }}"
76+
git checkout -b "$BRANCH"
77+
echo "branch=$BRANCH" >> $GITHUB_ENV
78+
7279
- name: Update pyproject.toml
7380
run: |
7481
sed -i "s/version = \".*\"/version = \"${{ steps.version.outputs.version }}\"/" pyproject.toml
@@ -78,22 +85,19 @@ jobs:
7885
run: |
7986
if [ -f "CHANGELOG.md" ]; then
8087
DATE=$(date +%Y-%m-%d)
81-
88+
8289
# Get the previous tag to compare commits
8390
PREVIOUS_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
84-
91+
8592
echo "Generating changelog from commits..."
8693
if [[ -n "$PREVIOUS_TAG" ]]; then
8794
echo "Changes since $PREVIOUS_TAG"
88-
89-
# Get commits since last tag, format as bullet points
90-
# Extract PR numbers and format nicely
9195
COMMITS=$(git log --oneline "$PREVIOUS_TAG"..HEAD --no-merges --pretty=format:"- %s" 2>/dev/null || echo "- Initial release")
9296
else
9397
echo "No previous tag found - this is the first release"
9498
COMMITS="- Initial release"
9599
fi
96-
100+
97101
# Create new changelog entry
98102
{
99103
head -n 8 CHANGELOG.md
@@ -107,7 +111,7 @@ jobs:
107111
tail -n +9 CHANGELOG.md
108112
} > CHANGELOG.md.tmp
109113
mv CHANGELOG.md.tmp CHANGELOG.md
110-
114+
111115
echo "✅ Updated CHANGELOG.md with commits since $PREVIOUS_TAG"
112116
else
113117
echo "No CHANGELOG.md found"
@@ -127,15 +131,31 @@ jobs:
127131
git commit -m "chore: bump version to ${{ steps.version.outputs.version }}"
128132
echo "Changes committed"
129133
fi
134+
130135
- name: Create and push tag
131136
run: |
132137
git tag -a "${{ steps.version.outputs.tag }}" -m "Release ${{ steps.version.outputs.tag }}"
133-
git push origin main
138+
git push origin "${{ env.branch }}"
134139
git push origin "${{ steps.version.outputs.tag }}"
135-
echo "Tag ${{ steps.version.outputs.tag }} created and pushed"
140+
echo "Branch ${{ env.branch }} and tag ${{ steps.version.outputs.tag }} pushed"
141+
142+
- name: Open pull request
143+
env:
144+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
145+
run: |
146+
gh pr create \
147+
--base main \
148+
--head "${{ env.branch }}" \
149+
--title "chore: bump version to ${{ steps.version.outputs.version }}" \
150+
--body "Automated version bump to ${{ steps.version.outputs.version }}.
151+
152+
This PR was created by the Release Trigger workflow. The git tag \`${{ steps.version.outputs.tag }}\` has already been pushed and the release artifacts are being built.
153+
154+
Merge this PR to record the version bump and changelog update on \`main\`."
136155
137156
- name: Summary
138157
run: |
139158
echo "✅ Version bumped to ${{ steps.version.outputs.version }}"
140159
echo "✅ Tag ${{ steps.version.outputs.tag }} created and pushed"
141-
echo "🚀 Release workflow will now build artifacts automatically"
160+
echo "✅ PR opened to merge version bump into main"
161+
echo "🚀 Release workflow is building artifacts from the tag"

0 commit comments

Comments
 (0)