mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 08:38:32 +02:00
40 lines
1.2 KiB
Bash
Executable file
40 lines
1.2 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
FILENAME='CHANGELOG.md'
|
|
|
|
# get the latest git tags
|
|
gittags="$(git tag --sort=-creatordate | grep -Ev '(alpha|beta|rc)')"
|
|
gittag_latest=$(printf '%s' "$gittags" | awk 'NR==1')
|
|
gittag_secondlatest=$(printf '%s' "$gittags" | awk 'NR==2')
|
|
|
|
echo "gittag_latest: ${gittag_latest}"
|
|
echo "gittag_secondlatest: ${gittag_secondlatest}"
|
|
|
|
# delete generated line (or it will be added multiple times)
|
|
sed -i '/This Changelog was automatically generated by/d' "$FILENAME"
|
|
|
|
# delete trailing empty lines
|
|
sed -i -e :a -e '/^\n*$/{$d;N;};/\n$/ba' "$FILENAME"
|
|
|
|
# determine correct tag to go back to
|
|
# @TODO
|
|
if [[ ! -z $TRAVIS_TAG ]]; then
|
|
echo "release build"
|
|
gittag=${gittag_secondlatest}
|
|
else
|
|
echo "merge into master or develop"
|
|
gittag=${gittag_latest}
|
|
fi
|
|
echo "gittag: ${gittag}"
|
|
|
|
# find the line the tag starts on, and subtract 1
|
|
tagline=$(grep -n "^## \[\?$gittag\]\?" CHANGELOG.md | awk '{print $1}' FS=':' | head -1)
|
|
echo "tagline: ${tagline}"
|
|
[[ ! -z $tagline ]] && sed -i "1,$(expr $tagline - 1)d" "$FILENAME"
|
|
|
|
# generate the changelog
|
|
docker run -it --rm -v "$(pwd)":/usr/local/src/your-app ferrarimarco/github-changelog-generator -t $CHANGELOG_GITHUB_TOKEN --since-tag $gittag
|
|
|
|
# @TODO commit changes, etc
|
|
git diff
|
|
|