Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add changelog generation workflow to github actions #1086

Merged
merged 4 commits into from
Nov 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 0 additions & 64 deletions .build/generate_changelog.sh

This file was deleted.

82 changes: 82 additions & 0 deletions .github/workflows/changelog.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Changelog

on:
push:
branches: [ develop ]

jobs:
generate:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Check branch for new commits
run: |
git fetch origin
BRANCH="${GITHUB_REF##*/}"
if [[ $(git rev-parse "origin/$BRANCH") != $GITHUB_SHA ]]; then
echo "BRANCH: $BRANCH"
echo "GITHUB_SHA: $GITHUB_SHA"
echo "$BRANCH has been updated since build started. Aborting changelog."
exit 1
fi
echo "BRANCH=$BRANCH" >> $GITHUB_ENV

- name: Prep environment variables
run: |
echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV
echo "FILENAME=CHANGELOG.md" >> $GITHUB_ENV
echo "gittag=$(git tag --sort=-creatordate | grep -Ev '(alpha|beta|rc)' | awk 'NR==1')" >> $GITHUB_ENV

- name: Prep changelog file (clear out old lines)
run: |
# delete the top of the changelog up to the correct tag
tagline=$(grep -n "^## \[\?$gittag\]\?" "$FILENAME" | awk '{print $1}' FS=':' | head -1)
echo "tagline: ${tagline}"
[[ ! -z $tagline ]] && sed -i "1,$(expr $tagline - 1)d" "$FILENAME"
# 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"

- name: Generate changelog
uses: heinrichreimer/action-github-changelog-generator@v2.1.1
with:
# see: https://github.com/heinrichreimer/action-github-changelog-generator
repo: jrnl-org/jrnl
token: ${{ secrets.GITHUB_TOKEN }}
base: CHANGELOG.md
addSections: '{"build":{"prefix":"**Build:**","labels":["build"]},"docs":{"prefix":"**Documentation:**","labels":["documentation"]}}'
issues: true
issuesWoLabels: false
unreleased: true
compareLink: true
includeLabels: bug,enhancement,documentation,build,deprecated
excludeLabels: stale,wontfix
excludeTagsRegex: '(alpha|beta|rc)'
sinceTag: ${{ env.gittag }}
releaseUrl: https://pypi.org/project/jrnl/%s/
verbose: false

- name: Small fixes
run: |
# Change unreleased link to correct url
sed -i 's!https://pypi.org/project/jrnl/HEAD/!https://github.com/jrnl-org/jrnl/!' "$FILENAME"

- name: Consistency check
run: |
if [[ $(grep '^# Changelog$' "$FILENAME") != 1 ]]; then
echo 'Something is wrong with the changelog.'
git diff -- "$FILENAME"
exit 1
fi

- name: Commit
run: |
git config user.email "jrnl.bot@gmail.com"
git config user.name "Jrnl Bot"
git add "$FILENAME"
git commit -m "Update changelog"
git push origin $BRANCH

12 changes: 0 additions & 12 deletions .github_changelog_generator

This file was deleted.