-
Notifications
You must be signed in to change notification settings - Fork 1
86 lines (73 loc) · 2.64 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
name: Update Plugin Changelog
on:
pull_request:
types:
- closed
jobs:
update-changelog:
if: github.event.pull_request.merged == true
runs-on: ubuntu-22.04
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Generate Formatted Changelog
run: |
# Check if CHANGELOG.md exists
if [ ! -f "CHANGELOG.md" ]; then
echo "CHANGELOG.md file not found"
exit 1
fi
# Extract the changelog content starting from '# Changelog'
START_LINE=$(grep -n "^# Changelog" CHANGELOG.md | cut -d':' -f1)
if [ -z "$START_LINE" ]; then
echo "No '# Changelog' section found in CHANGELOG.md"
exit 1
fi
# Extract the changelog entries, starting from the first '## ' section
tail -n +$((START_LINE + 1)) CHANGELOG.md > changelog_entries.txt
# Format the changelog entries into the desired format
awk '
BEGIN { print "== Changelog ==" }
/^##/ {
if (version != "") {
print formatted_changelog;
}
version = $2;
date = $4;
formatted_changelog = "= " version " - " date " =";
next;
}
/^- / {
gsub(/^- /, "");
formatted_changelog = formatted_changelog "\n" $0;
}
END {
print formatted_changelog;
}
' changelog_entries.txt > formatted_changelog.txt
echo "Generated formatted changelog:"
cat formatted_changelog.txt
- name: Update readme.txt
run: |
# Check if readme.txt exists
if [ ! -f "readme.txt" ]; then
echo "readme.txt file not found"
exit 1
fi
# Remove existing '== Changelog ==' and everything below it
sed -i '/== Changelog ==/,$d' readme.txt
# Add the new formatted changelog content
cat formatted_changelog.txt >> readme.txt
- name: Commit and Push Changes to GitHub
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "github-actions@github.com"
git add readme.txt
git commit -m "Update changelog after merging PR #${{ github.event.pull_request.number }}" || echo "No changes to commit"
git push origin development || echo "Nothing to push"
- name: Cleanup formatted changelog
run: |
# Delete the formatted_changelog.txt file
if [ -f "formatted_changelog.txt" ]; then
rm formatted_changelog.txt
fi