Skip to content

Commit f5ea6a6

Browse files
committed
fix logic for merging CHANGELOG for patch releases
1 parent a530ba0 commit f5ea6a6

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

.github/workflows/post-release-version-bump.yml

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,15 @@ jobs:
115115
sed -i "s|\(/aws-observability/adot-autoinstrumentation-node:\)v[0-9]\+\.[0-9]\+\.[0-9]\+|\1v${{github.event.inputs.version}}|g" .github/workflows/daily-scan.yml
116116
117117
# for patch releases, avoid merge conflict by manually resolving CHANGELOG with main
118-
if [[ "${{ github.event.inputs.is_patch }}" == "true" ]]; then
118+
if [[ "${{ github.event.inputs.is_patch }}" == "true" ]]; then
119+
# Copy the patch release entries
120+
sed -n "/^## v${VERSION}/,/^## v[0-9]/p" CHANGELOG.md | sed '$d' > /tmp/patch_release_section.txt
119121
git fetch origin main
120-
git show origin/main:CHANGELOG.md | sed -n '/## Unreleased/,/^## v[0-9]/p' | sed '$d' | tail -n +2 | sed '/^$/d' > /tmp/unreleased_content.txt
121-
122-
# Insert the content right after the existing "## Unreleased" header
123-
sed -i '/## Unreleased/r /tmp/unreleased_content.txt' CHANGELOG.md
122+
git show origin/main:CHANGELOG.md > CHANGELOG.md
123+
# Insert the patch release entries after Unreleased
124+
awk -i inplace '/^## v[0-9]/ && !inserted { system("cat /tmp/patch_release_section.txt"); inserted=1 } {print}' CHANGELOG.md
124125
fi
125-
126+
126127
git add .
127128
git status
128129
git commit -m "Prepare main for next development cycle: Update version to $DEV_VERSION"
@@ -140,4 +141,14 @@ jobs:
140141
141142
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice." \
142143
--head prepare-main-for-next-dev-cycle-${VERSION} \
143-
--base main
144+
--base main
145+
146+
- name: Force our CHANGELOG to override merge conflicts
147+
run: |
148+
git merge origin/main || true
149+
git checkout --ours CHANGELOG.md
150+
git add CHANGELOG.md
151+
if ! git diff --quiet --cached; then
152+
git commit -m "Force our CHANGELOG to override merge conflicts"
153+
git push origin "post-release-${VERSION}"
154+
fi

0 commit comments

Comments
 (0)