Skip to content

Commit

Permalink
Add changelog generator script
Browse files Browse the repository at this point in the history
  • Loading branch information
ericyd committed Jan 15, 2024
1 parent a6c1c75 commit 586b5fe
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ npm run check:all
```shell
npm version minor
git push --tags && git push
./scripts/changelog
npm login --registry https://registry.npmjs.org --scope=@salamivg
npm publish --access public
```
Expand Down
33 changes: 33 additions & 0 deletions scripts/changelog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/sh

from=$1
to=$2

if [ "$from" == "" ]; then
from=$(git describe --abbrev=0 $(git describe --abbrev=0)^)
echo "No 'from' positional arg provided. Defaulting to '$from'"
fi

if [ "$to" == "" ]; then
to=$(git describe --abbrev=0)
echo "No 'to' positional arg provided. Defaulting to '$to'"
fi

echo "\nChangelog from $from to $to\n"

# Some formatting explanations:
# %h: short sha
# %ad: author date, using --date option for format
# %s: "subject" (probably the first line of the commit message, but haven't tested extensively)
# %an: author name
# %d: ref name; prints stuff like "(HEAD -> main, tag: v0.4.0, origin/main, origin/HEAD)"
git log \
--abbrev-commit \
--decorate \
--date=short \
--format=format:'* %s (%ad, [%h](https://github.com/ericyd/salamivg/commit/%H))' \
--all \
"$from"..."$to"

# a nice one-liner that shows most of the useful info
# git log --abbrev-commit --decorate --date=short --format=format:'%h, %aI - %s %d' --all "$from"..."$to"

0 comments on commit 586b5fe

Please sign in to comment.