|
4 | 4 | # the release date for $VERSION should be available in $RELEASE_DATE |
5 | 5 | # and the release notes for $VERSION should be available in /tmp/changelog-section.md |
6 | 6 |
|
7 | | -if [[ $VERSION =~ ^[0-9]+\.[0-9]+\.0 ]]; then |
8 | | - # this was not a patch release, so the version exists already in the CHANGELOG.md |
9 | | - |
10 | | - # update the release date |
11 | | - sed -Ei "s/## Version $VERSION .*/## Version $VERSION ($RELEASE_DATE)/" CHANGELOG.md |
12 | | - |
13 | | - # the entries are copied over from the release branch to support workflows |
14 | | - # where change log entries may be updated after preparing the release branch |
15 | | - |
16 | | - { |
17 | | - # copy the portion above the release, up to and including the heading |
18 | | - sed -n "0,/^## Version $VERSION /p" CHANGELOG.md |
19 | | - # copy the release notes for $VERSION |
20 | | - cat /tmp/changelog-section.md |
21 | | - # copy the portion below the release |
22 | | - sed -n "0,/^## Version $VERSION /d;0,/^## Version /{/^## Version/!d};p" CHANGELOG.md |
23 | | - } > /tmp/CHANGELOG.md |
24 | | - |
25 | | - # update the real CHANGELOG.md |
26 | | - cp /tmp/CHANGELOG.md CHANGELOG.md |
27 | | - |
28 | | -else |
29 | | - # this was a patch release, so the version does not exist already in the CHANGELOG.md |
30 | | - |
31 | | - { |
32 | | - # copy the portion above the top-most release, not including the heading |
33 | | - sed -n "0,/^## Version /{ /^## Version /!p }" CHANGELOG.md |
34 | | - # add the heading |
35 | | - echo "## Version $VERSION ($RELEASE_DATE)" |
36 | | - # copy the release notes for $VERSION |
37 | | - cat /tmp/changelog-section.md |
38 | | - # copy the portion starting from the top-most release |
39 | | - sed -n "/^## Version /,\$p" CHANGELOG.md |
40 | | - } > /tmp/CHANGELOG.md |
41 | | - |
42 | | - # update the real CHANGELOG.md |
43 | | - cp /tmp/CHANGELOG.md CHANGELOG.md |
44 | | -fi |
| 7 | +# NOTE: this script differs from the equivalent in other Java repos (where it |
| 8 | +# was copied from). In those repos patch releases are cut from the prior |
| 9 | +# minor's release branch, so the patch version heading is not yet present in |
| 10 | +# CHANGELOG.md on main and must be prepended here. In this repo, patch |
| 11 | +# releases also go through the prepare-release-branch workflow, which already |
| 12 | +# adds the heading to main, so we always take the "heading already exists" |
| 13 | +# path below (both for minor and patch releases). Please preserve this |
| 14 | +# difference when syncing workflow changes from other Java repos. |
| 15 | + |
| 16 | +# update the release date |
| 17 | +sed -Ei "s/## Version $VERSION .*/## Version $VERSION ($RELEASE_DATE)/" CHANGELOG.md |
| 18 | + |
| 19 | +# the entries are copied over from the release branch to support workflows |
| 20 | +# where change log entries may be updated after preparing the release branch |
| 21 | + |
| 22 | +{ |
| 23 | + # copy the portion above the release, up to and including the heading |
| 24 | + sed -n "0,/^## Version $VERSION /p" CHANGELOG.md |
| 25 | + # copy the release notes for $VERSION |
| 26 | + cat /tmp/changelog-section.md |
| 27 | + # copy the portion below the release |
| 28 | + sed -n "0,/^## Version $VERSION /d;0,/^## Version /{/^## Version/!d};p" CHANGELOG.md |
| 29 | +} > /tmp/CHANGELOG.md |
| 30 | + |
| 31 | +# update the real CHANGELOG.md |
| 32 | +cp /tmp/CHANGELOG.md CHANGELOG.md |
0 commit comments