Skip to content

Commit

Permalink
chore(release): don't completely recreate changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkw committed Sep 29, 2023
1 parent 454b950 commit 43e2b48
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bin/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ push() {

update_changelog() {
# shellcheck source=update-changelog
. "$bindir"/update-changelog.sh
. "$bindir"/update-changelog.sh --prepend --unreleased
changelog_status="$?"

if [[ $changelog_status -ne 0 ]]; then
Expand Down
18 changes: 16 additions & 2 deletions bin/update-changelog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ FLAGS:
-v, --verbose Enable verbose output.
-u, --unreleased Only add unreleased changes to changelog
--changelog-path <FILE_PATH> Write the changelog to this path.
default: <CRATE_PATH>/CHANGELOG.md"
default: <CRATE_PATH>/CHANGELOG.md
-p, --prepend Prepend the changelog to the existing file.
default: regenerate the entire file."

set -euo pipefail

Expand All @@ -24,6 +26,7 @@ cd "$rootdir"
verbose=''
unreleased=''
changelog_path=''
prepend=''

while [[ $# -gt 0 ]]
do
Expand All @@ -40,6 +43,9 @@ do
-u|--unreleased)
unreleased="--unreleased"
;;
-p|--prepend)
prepend="--prepend"
;;
--changelog-path)
changelog_path="$1"
shift
Expand Down Expand Up @@ -97,16 +103,24 @@ status "Updating" "$changelog_path for tag $tag"
git_cliff=(
git-cliff
--include-path "${path}/**"
--output "$changelog_path"
--config cliff.toml
--tag "$tag"
)
if [[ "$verbose" ]]; then
git_cliff+=("$verbose")
fi

if [[ "$unreleased" ]]; then
git_cliff+=("$unreleased")
fi

if [[ "$prepend" ]]; then
git_cliff+=("--prepend")
else
git_cliff+=("--output")
fi

git_cliff+=("$changelog_path")

export GIT_CLIFF__GIT__TAG_PATTERN="${path}-v[0-9]*"
"${git_cliff[@]}"

0 comments on commit 43e2b48

Please sign in to comment.