| 1 |
#!/usr/bin/env bash |
| 2 |
|
| 3 |
# updates changelog version indicated by release-plz |
| 4 |
|
| 5 |
set -eEuo pipefail |
| 6 |
|
| 7 |
### START HELPERS |
| 8 |
|
| 9 |
function update_release_notes() { |
| 10 |
local package_dir="$1" |
| 11 |
local version="$2" |
| 12 |
local tag="$3" |
| 13 |
|
| 14 |
local changelog_file="${package_dir}/CHANGELOG.md" |
| 15 |
|
| 16 |
echo "Updating $tag using $changelog_file" |
| 17 |
|
| 18 |
local notes="$(sed -n "/^## ${version}$/,/^## /p" "$changelog_file" | sed '1d;$d')" |
| 19 |
|
| 20 |
gh release edit "$tag" --notes="$notes" |
| 21 |
} |
| 22 |
|
| 23 |
### END HELPERS |
| 24 |
|
| 25 |
RELEASE_PLZ_RELEASES_JSON="$1" |
| 26 |
|
| 27 |
specs="$(echo "$RELEASE_PLZ_RELEASES_JSON" | jq -r '.[] | "\(.package_name):\(.version):\(.tag)"')" |
| 28 |
|
| 29 |
for spec in $specs; do |
| 30 |
name="$(echo "$spec" | cut -d: -f1)" |
| 31 |
version="$(echo "$spec" | cut -d: -f2)" |
| 32 |
tag="$(echo "$spec" | cut -d: -f3)" |
| 33 |
|
| 34 |
update_release_notes "." "$version" "$tag" |
| 35 |
done |