I'm trying to generate changelog to a project (repo in bitbucket.org), but I can't find an easy solution. We are using this pattern
(<type>(<scope>): <subject>)
to fill the commit messages, and tags to version (0.1, 0.2, 0.3).
Is there anything out-of-the-box (some script, npm package, etc...) or the best thing I can do is write some custom script using git log and parse the data (commit messages, etc...)?
I know there is an github-changelog-creator, but I can't use as long as this repo is in a bitbucket repo.
Auto-Generate ChangelogFollow the Conventional Commits Specification in your repository. We will use @commitlint/config-conventional to enforce this via Git hooks. Use standard-version, a utility for versioning using SemVer and changelog generation powered by Conventional Commits.
conventional-changelog: a set of tools for parsing Conventional Commits messages from git histories. parse-commit-message: Extensible utilities for parsing, stringify and validating Conventional Commit messages.
We are using this simple shell script to generate hierarchical change log sorted by tags with the latest tag on top.
#!/usr/bin/env bash
previous_tag=0
for current_tag in $(git tag --sort=-creatordate)
do
if [ "$previous_tag" != 0 ];then
tag_date=$(git log -1 --pretty=format:'%ad' --date=short ${previous_tag})
printf "## ${previous_tag} (${tag_date})\n\n"
git log ${current_tag}...${previous_tag} --pretty=format:'* %s [View](https://bitbucket.org/projects/test/repos/my-project/commits/%H)' --reverse | grep -v Merge
printf "\n\n"
fi
previous_tag=${current_tag}
done
And you can put it in the project root as some shel file and run it (depending upon your platform you might need to make it executable) as below
sh change-log-builder.sh > changelog.md
And the resulting changelog.md looks like this
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With