chore: add changelog generator
This commit is contained in:
parent
bdc2e92454
commit
e048560910
6 changed files with 84 additions and 0 deletions
25
tools/changelog.sh
Executable file
25
tools/changelog.sh
Executable file
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -u
|
||||
|
||||
error() {
|
||||
echo >&2 "error: $*"
|
||||
exit 1
|
||||
}
|
||||
|
||||
command -v git > /dev/null || error "git command not found!"
|
||||
command -v git-chglog > /dev/null || error "git-chglog command not found!"
|
||||
|
||||
changelog="CHANGELOG.md"
|
||||
tag="${tag:-$(git describe --abbrev=0 --tags || error "could not extract latest tag")}"
|
||||
|
||||
if grep --quiet "<a name=\"$tag\"></a>" "$changelog"; then
|
||||
error "changelog has already been generated for tag $tag!"
|
||||
fi
|
||||
|
||||
cat <(git-chglog "$tag") "$changelog" > "$changelog.tmp"
|
||||
mv "$changelog.tmp" "$changelog"
|
||||
|
||||
if command -v npx > /dev/null; then
|
||||
npx prettier --write "$changelog"
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue