-
-
Notifications
You must be signed in to change notification settings - Fork 3
115 lines (113 loc) · 3.7 KB
/
changelog.yml
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
---
name: Changelog
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 4
if: "!contains(github.event.head_commit.message, 'update changelog')"
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1.0
- name: Install `github_changelog_generator`
run: |
command gem install github_changelog_generator
- name: Install `markdownlint`
run: |
command npm install markdownlint
command npm install markdownlint-cli
- name: Create local changes
run: |
command github_changelog_generator \
--user "$(
command git config --get-regexp -- 'remote.*url' |
command sed -E \
-e 's/(git@|https:\/\/)//' \
-e 's/:/\//' \
-e 's/\.git$//' |
command awk -F '/' '{print $2}' |
command head -n 1
)" \
--project "$(
command git remote get-url "$(
{
command git config --get --worktree checkout.defaultRemote ||
command git config --get --local checkout.defaultRemote ||
command git config --get --system checkout.defaultRemote ||
command git config --get --global checkout.defaultRemote
} 2>/dev/null ||
printf 'origin'
)" |
command tr -d '[:space:]' |
command xargs basename |
command sed -e 's/\.git$//'
)" \
--token ${{ secrets.GITHUB_TOKEN || secrets.PAT }} \
--exclude-labels 'duplicate,question,invalid,wontfix,nodoc' \
--output "$(
command find -- . \
-maxdepth 1 \
-type f \
-name '*.m*d*' \
'(' \
-name 'change*log*' -o \
-name 'CHANGE*LOG*' \
')' |
command sed -e 's/^.\///'
)"
- name: Repair changelog credit
run: |
command find -- . \
-maxdepth 1 \
-type f \
-name '*.m*d*' \
'(' \
-name 'change*log*' -o \
-name 'CHANGE*LOG*' \
')' \
-print \
-exec sed -i \
-e 's/This Changelog/This changelog/' \
-e 's/automatically generated/\[automatically generated\]()/' \
-e 's/\]()/\](.\/.github\/workflows\/changelog.yml)/' \
-e 's/generator)\*/generator).\*/' '{}' '+'
- name: Lint changelog
run: |
command find -- . \
-maxdepth 1 \
-type f \
-name '*.m*d*' \
'(' \
-name 'change*log*' -o \
-name 'CHANGE*LOG*' \
')' \
-print \
-exec npm exec -- markdownlint --fix -- '{}' ';'
- name: Commit files
run: |
command git config -- user.email '[email protected]'
command git config -- user.name 'GitHub'
command find -- . \
-maxdepth 1 \
-type f \
-name '*.m*d*' \
'(' \
-name 'change*log*' -o \
-name 'CHANGE*LOG*' \
')' \
-print \
-exec git add --verbose -- '{}' ';'
command git commit --verbose \
--message='update changelog' ||
exit 0
- name: Push changes
uses: ad-m/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN || secrets.PAT }}
branch: ${{ github.ref }}