mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 08:38:32 +02:00
add script to generate changelog
This commit is contained in:
parent
f92c789efe
commit
e6a9a0e3cd
2 changed files with 48 additions and 0 deletions
40
.build/generate_changelog.sh
Executable file
40
.build/generate_changelog.sh
Executable file
|
@ -0,0 +1,40 @@
|
||||||
|
#!/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
|
||||||
|
|
|
@ -114,6 +114,14 @@ jobs:
|
||||||
env:
|
env:
|
||||||
- TZ=America/Edmonton
|
- TZ=America/Edmonton
|
||||||
|
|
||||||
|
# Changelog for Unreleased changes
|
||||||
|
- stage: Update Changelog
|
||||||
|
if: (tag IS present) OR (branch = develop AND type NOT IN (pull_request))
|
||||||
|
install:
|
||||||
|
- echo 'Skipping install'
|
||||||
|
script:
|
||||||
|
- ./.build/generate_changelog.sh
|
||||||
|
|
||||||
- stage: Deploy
|
- stage: Deploy
|
||||||
before_deploy:
|
before_deploy:
|
||||||
- poetry config pypi-token.pypi "$PYPI_TOKEN"
|
- poetry config pypi-token.pypi "$PYPI_TOKEN"
|
||||||
|
|
Loading…
Add table
Reference in a new issue