2023-03-26 05:25:15 +03:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2023-03-26 05:59:33 +03:00
|
|
|
set -e
|
|
|
|
|
2023-03-26 05:25:15 +03:00
|
|
|
# This script the per-release changelog file for goreleaser to use
|
2023-03-26 05:47:29 +03:00
|
|
|
# to publish to GitHub releases. It produces markdown output.
|
|
|
|
|
|
|
|
# First we get the current and previous git tags.
|
2023-03-26 05:25:15 +03:00
|
|
|
curTag=$(git tag --sort=-creatordate | head -n 1)
|
|
|
|
prevTag=$(git tag --sort=-creatordate | head -n 2 | tail -n 1)
|
2023-03-26 05:47:29 +03:00
|
|
|
|
|
|
|
# Then we run git diff on CHANGELOG.md;
|
|
|
|
# and grep for only the added lines;
|
|
|
|
# and stripping out the '+++ CHANGELOG.md' header line;
|
|
|
|
# and stripping the leading '+' from each line
|
|
|
|
# and getting rid of a superfluous starting newline.
|
2023-03-26 05:25:15 +03:00
|
|
|
git diff "$prevTag" "$curTag" --no-ext-diff --unified=0 --exit-code -a --no-prefix -- ./CHANGELOG.md \
|
2023-03-26 05:47:29 +03:00
|
|
|
| grep -E "^\+" \
|
|
|
|
| grep -vF '## [v' \
|
|
|
|
| grep -vF '+++ CHANGELOG.md' \
|
|
|
|
| cut -c 2- \
|
|
|
|
| tail -n +2
|
|
|
|
|
|
|
|
# Then we add a section for the commits.
|
|
|
|
printf "\n### Commits\n\n"
|
2023-03-26 05:25:15 +03:00
|
|
|
|
|
|
|
echo '```text'
|
|
|
|
git log --pretty=format:'%h %s%n' "$prevTag".."$curTag"
|
|
|
|
echo '```'
|