@@ -21,21 +21,39 @@ jobs:
21
21
id : package-version
22
22
uses : martinbeentjes/npm-get-version-action@v1.3.1
23
23
24
- - name : Read CHANGELOG.md
24
+ - name : Update CHANGELOG.md and get changes
25
25
id : changelog
26
- uses : juliangruber/read-file-action@v1
27
- with :
28
- path : ./CHANGELOG.md
26
+ run : |
27
+ VERSION=${{ steps.package-version.outputs.current-version }}
28
+ TODAY=$(date +%Y-%m-%d)
29
+
30
+ # Update the date in CHANGELOG.md
31
+ sed -i "s/\[$VERSION\] - [0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}/[$VERSION] - $TODAY/" CHANGELOG.md
32
+
33
+ # Extract changes for this version
34
+ CHANGES=$(sed -n "/## \[$VERSION\]/,/## \[/p" CHANGELOG.md | sed '$d')
35
+
36
+ echo "changes<<EOF" >> $GITHUB_OUTPUT
37
+ echo "$CHANGES" >> $GITHUB_OUTPUT
38
+ echo "EOF" >> $GITHUB_OUTPUT
39
+
40
+ - name : Commit CHANGELOG.md changes
41
+ run : |
42
+ git config --local user.email "action@github.com"
43
+ git config --local user.name "GitHub Action"
44
+ git add CHANGELOG.md
45
+ git commit -m "Update CHANGELOG.md with today's date" || echo "No changes to commit"
46
+ git push
29
47
30
48
- name : Create Release
31
49
id : create_release
32
50
uses : actions/create-release@v1
33
51
env :
34
52
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
35
53
with :
36
- tag_name : v${{ steps.package-version.outputs.current-version}}
54
+ tag_name : v${{ steps.package-version.outputs.current-version }}
37
55
release_name : Release ${{ steps.package-version.outputs.current-version }}
38
- body : ${{ steps.changelog.outputs.content }}
56
+ body : ${{ steps.changelog.outputs.changes }}
39
57
draft : false
40
58
prerelease : false
41
59
0 commit comments