-
-
Notifications
You must be signed in to change notification settings - Fork 518
82 lines (71 loc) · 2.92 KB
/
changelog.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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 -c '^# 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