Skip to content

Commit c197f16

Browse files
committed
fix: create separate branch for release preparation to avoid conflicts
- Create chore/prepare-release-vX.X.X branch for release preparation - Create chore/prepare-hotfix-vX.X.X branch for hotfix preparation - PR now goes from preparation branch to release/hotfix branch - Avoids git push conflicts when multiple people work on same release branch - Better separation of concerns and cleaner git history
1 parent 5edb93c commit c197f16

File tree

1 file changed

+25
-24
lines changed

1 file changed

+25
-24
lines changed

.github/workflows/release-automation.yml

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ jobs:
117117
VERSION="${{ steps.extract_version.outputs.version }}"
118118
BRANCH_TYPE="${{ steps.extract_version.outputs.branch_type }}"
119119
120+
# Create a new branch for the release preparation
121+
PREP_BRANCH="chore/prepare-${BRANCH_TYPE}-v${VERSION}"
122+
git checkout -b "$PREP_BRANCH"
123+
120124
# Stage changes
121125
git add -A
122126
@@ -132,11 +136,12 @@ jobs:
132136
git commit -m "fix(hotfix): prepare hotfix v$VERSION"
133137
fi
134138
135-
# Push changes
136-
git push origin "${{ github.event.ref }}"
139+
# Push the new branch
140+
git push origin "$PREP_BRANCH"
137141
138142
echo "has_changes=true" >> $GITHUB_OUTPUT
139-
echo "✅ Changes committed and pushed"
143+
echo "prep_branch=$PREP_BRANCH" >> $GITHUB_OUTPUT
144+
echo "✅ Changes committed and pushed to $PREP_BRANCH"
140145
fi
141146
142147
- name: Create Pull Request
@@ -146,24 +151,25 @@ jobs:
146151
run: |
147152
VERSION="${{ steps.extract_version.outputs.version }}"
148153
BRANCH_TYPE="${{ steps.extract_version.outputs.branch_type }}"
149-
BRANCH_NAME="${{ github.event.ref }}"
154+
PREP_BRANCH="${{ steps.commit.outputs.prep_branch }}"
155+
SOURCE_BRANCH="${{ github.event.ref }}"
156+
157+
# Determine target branch (should be the release branch)
158+
TARGET_BRANCH="$SOURCE_BRANCH"
150159
151-
# Determine target branch
152160
if [ "$BRANCH_TYPE" = "release" ]; then
153-
TARGET_BRANCH="main"
154-
PR_TITLE="chore(release): release v$VERSION"
161+
PR_TITLE="chore(release): prepare release v$VERSION"
155162
LABELS="release,auto-generated"
156163
else
157-
TARGET_BRANCH="main"
158-
PR_TITLE="fix(hotfix): hotfix v$VERSION"
164+
PR_TITLE="fix(hotfix): prepare hotfix v$VERSION"
159165
LABELS="hotfix,auto-generated,priority:high"
160166
fi
161167
162168
# Create PR body
163169
cat > pr_body.md << 'PREOF'
164-
## 🚀 ${{ steps.extract_version.outputs.branch_type == 'release' && 'Release' || 'Hotfix' }} v${{ steps.extract_version.outputs.version }}
170+
## 🚀 Prepare ${{ steps.extract_version.outputs.branch_type == 'release' && 'Release' || 'Hotfix' }} v${{ steps.extract_version.outputs.version }}
165171
166-
This PR contains the following changes for v${{ steps.extract_version.outputs.version }}:
172+
This PR prepares the following changes for v${{ steps.extract_version.outputs.version }}:
167173
168174
### 📋 Changes Included
169175
- ✅ Version bumped to v${{ steps.extract_version.outputs.version }}
@@ -173,26 +179,21 @@ jobs:
173179
174180
${{ steps.changelog.outputs.changelog }}
175181
176-
### ✔️ Checklist
177-
- [ ] All tests passing
178-
- [ ] Documentation updated (if needed)
179-
- [ ] Breaking changes documented (if any)
180-
- [ ] Ready for production
181-
182-
### 🔄 Post-Merge Actions
183-
After merging this PR:
184-
1. A tag `v${{ steps.extract_version.outputs.version }}` will be created automatically
185-
2. A GitHub release will be created with the changelog
186-
3. Changes will be backmerged to `develop` branch
182+
### ✔️ Next Steps
183+
1. Review and merge this PR into `${{ github.event.ref }}`
184+
2. Create a PR from `${{ github.event.ref }}` to `main`
185+
3. After merging to `main`, a tag `v${{ steps.extract_version.outputs.version }}` will be created
186+
4. A GitHub release will be created with the changelog
187+
5. Changes will be backmerged to `develop` branch
187188
188189
---
189190
*This PR was automatically generated when the ${{ github.event.ref }} branch was created.*
190191
PREOF
191192
192-
# Create the pull request
193+
# Create the pull request from prep branch to release/hotfix branch
193194
gh pr create \
194195
--base "$TARGET_BRANCH" \
195-
--head "$BRANCH_NAME" \
196+
--head "$PREP_BRANCH" \
196197
--title "$PR_TITLE" \
197198
--body-file pr_body.md \
198199
--label "$LABELS"

0 commit comments

Comments
 (0)