mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-20 13:08:31 +02:00
Merge pull request #806 from wren/auto-changelog-724
Automagically update the changelog you see before your very eyes!
This commit is contained in:
commit
c68cbaa0b7
3 changed files with 79 additions and 2 deletions
54
.build/generate_changelog.sh
Executable file
54
.build/generate_changelog.sh
Executable file
|
@ -0,0 +1,54 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
FILENAME='CHANGELOG.md'
|
||||||
|
|
||||||
|
# get the latest git tags
|
||||||
|
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 "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"
|
||||||
|
|
||||||
|
# delete trailing empty lines
|
||||||
|
sed -i -e :a -e '/^\n*$/{$d;N;};/\n$/ba' "$FILENAME"
|
||||||
|
|
||||||
|
# determine correct tag to go back to
|
||||||
|
if [[ $TRAVIS_TAG == $release_latest ]]; then
|
||||||
|
echo "release build"
|
||||||
|
gittag=${release_secondlatest}
|
||||||
|
elif [[ ! -z $TRAVIS_TAG ]]; then
|
||||||
|
echo "beta elease"
|
||||||
|
gittag=${release_latest}
|
||||||
|
else
|
||||||
|
echo "merge into master or develop"
|
||||||
|
gittag=${release_latest}
|
||||||
|
fi
|
||||||
|
echo "gittag: ${gittag}"
|
||||||
|
|
||||||
|
# find the line the tag starts on, and subtract 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 $GITHUB_TOKEN --since-tag $gittag
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
11
.github_changelog_generator
Normal file
11
.github_changelog_generator
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
project=jrnl
|
||||||
|
user=jrnl-org
|
||||||
|
base=CHANGELOG.md
|
||||||
|
issues=false
|
||||||
|
issues-wo-labels=false
|
||||||
|
include-labels=bug,enhancement,documentation,build,deprecated
|
||||||
|
release-url=https://pypi.org/project/jrnl/%s/
|
||||||
|
add-sections={ "build": { "prefix": "**Build:**", "labels": ["build"]}, "docs": { "prefix": "**Updated documentation:**", "labels": ["documentation"]}}
|
||||||
|
exclude-tags-regex=(alpha|beta|rc)
|
||||||
|
verbose=false
|
||||||
|
|
16
.travis.yml
16
.travis.yml
|
@ -114,16 +114,28 @@ 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
|
||||||
if: branch = master AND tag IS present
|
if: tag IS present
|
||||||
before_deploy:
|
before_deploy:
|
||||||
- poetry config http-basic.pypi "$PYPI_USER" "$PYPI_PASS"
|
- poetry config pypi-token.pypi "$PYPI_TOKEN"
|
||||||
- poetry version "$TRAVIS_TAG"
|
- poetry version "$TRAVIS_TAG"
|
||||||
- echo __version__ = \"$TRAVIS_TAG\" > jrnl/__version__.py
|
- echo __version__ = \"$TRAVIS_TAG\" > jrnl/__version__.py
|
||||||
- poetry build
|
- poetry build
|
||||||
deploy:
|
deploy:
|
||||||
- provider: script
|
- provider: script
|
||||||
script: poetry publish
|
script: poetry publish
|
||||||
|
skip_cleanup: true
|
||||||
|
on:
|
||||||
|
branch: master
|
||||||
|
tags: true
|
||||||
after_deploy:
|
after_deploy:
|
||||||
- git config --global user.email "jrnl.bot@gmail.com"
|
- git config --global user.email "jrnl.bot@gmail.com"
|
||||||
- git config --global user.name "Jrnl Bot"
|
- git config --global user.name "Jrnl Bot"
|
||||||
|
|
Loading…
Add table
Reference in a new issue