mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 08:38:32 +02:00
update changelog script to handle different scenarios (#724)
This commit is contained in:
parent
e6a9a0e3cd
commit
3fc3233a44
1 changed files with 27 additions and 13 deletions
|
@ -3,12 +3,12 @@
|
|||
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')
|
||||
releases="$(git tag --sort=-creatordate | grep -Ev '(alpha|beta|rc)')"
|
||||
release_latest=$(printf '%s' "$releases" | awk 'NR==1')
|
||||
release_secondlatest=$(printf '%s' "$releases" | awk 'NR==2')
|
||||
|
||||
echo "gittag_latest: ${gittag_latest}"
|
||||
echo "gittag_secondlatest: ${gittag_secondlatest}"
|
||||
echo "release_latest: ${release_latest}"
|
||||
echo "release_secondlatest: ${release_secondlatest}"
|
||||
|
||||
# delete generated line (or it will be added multiple times)
|
||||
sed -i '/This Changelog was automatically generated by/d' "$FILENAME"
|
||||
|
@ -17,24 +17,38 @@ sed -i '/This Changelog was automatically generated by/d' "$FILENAME"
|
|||
sed -i -e :a -e '/^\n*$/{$d;N;};/\n$/ba' "$FILENAME"
|
||||
|
||||
# determine correct tag to go back to
|
||||
# @TODO
|
||||
if [[ ! -z $TRAVIS_TAG ]]; then
|
||||
if [[ $TRAVIS_TAG == $release_latest ]]; then
|
||||
echo "release build"
|
||||
gittag=${gittag_secondlatest}
|
||||
gittag=${release_secondlatest}
|
||||
elif [[ ! -z $TRAVIS_TAG ]]; then
|
||||
echo "beta elease"
|
||||
gittag=${release_latest}
|
||||
else
|
||||
echo "merge into master or develop"
|
||||
gittag=${gittag_latest}
|
||||
gittag=${release_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)
|
||||
tagline=$(grep -n "^## \[\?$gittag\]\?" "$FILENAME" | 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
|
||||
docker run -it --rm -v "$(pwd)":/usr/local/src/your-app ferrarimarco/github-changelog-generator -t $GITHUB_TOKEN --since-tag $gittag
|
||||
|
||||
# @TODO commit changes, etc
|
||||
git diff
|
||||
# Put back our link (instead of the broken one)
|
||||
sed -i 's!https://pypi.org/project/jrnl/HEAD/!https://github.com/jrnl-org/jrnl/!' "$FILENAME"
|
||||
|
||||
BRANCH=$TRAVIS_BRANCH
|
||||
if [[ $TRAVIS_BRANCH == $TRAVIS_TAG ]]; then
|
||||
BRANCH='master'
|
||||
fi
|
||||
|
||||
git config --global user.email "jrnl.bot@gmail.com"
|
||||
git config --global user.name "Jrnl Bot"
|
||||
git checkout $BRANCH
|
||||
git add "$FILENAME"
|
||||
git commit -m "Updating changelog [ci skip]"
|
||||
git push https://${GITHUB_TOKEN}@github.com/jrnl-org/jrnl.git $BRANCH
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue