Skip to content

Instantly share code, notes, and snippets.

@nikoheikkila
Created June 30, 2025 19:03
Show Gist options
  • Save nikoheikkila/a7ec75ce6cd3240c0d2173ec7066e02e to your computer and use it in GitHub Desktop.
Save nikoheikkila/a7ec75ce6cd3240c0d2173ec7066e02e to your computer and use it in GitHub Desktop.
A quick and dirty changelog generator for Bash
#!/usr/bin/env bash
set -euo pipefail
SINCE="${1:-HEAD~1}"
query_log() {
local type="$1"
local pattern="^${type}\(.*\):\s"
local GH_HOST="github.com"
local owner="nikoheikkila"
local repository="nikoheikkila.fi"
local commit_url="https://${GH_HOST}/${owner}/${repository}/commit/%H"
git log --grep "${pattern}" --pretty="- %s [(\`%h\`)](${commit_url})" "${SINCE}...HEAD"
echo ""
}
{
echo "### New Features"
query_log "feat"
echo "### Bug Fixes"
query_log "fix"
echo "### Documentation"
query_log "docs"
} > CHANGELOG.md
pandoc -s -f markdown -t markdown+smart -o CHANGELOG.md --metadata title="Release Notes" CHANGELOG.md
pandoc -s -f markdown+smart -t html -o CHANGELOG.html --metadata title="Release Notes" CHANGELOG.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment