@@ -3,10 +3,11 @@ name: "Update Changelog"
3
3
on :
4
4
release :
5
5
types : [published] # Trigger on release publication
6
- workflow_dispatch : # Allows manual trigger of this workflow
6
+ workflow_dispatch : # Allows manual trigger
7
7
8
8
permissions :
9
- contents : write
9
+ contents : write # Minimum required permission for file changes and PR creation
10
+ pull-requests : write # Required for creating PRs
10
11
11
12
jobs :
12
13
update-changelog :
@@ -17,54 +18,49 @@ jobs:
17
18
- name : Checkout code
18
19
uses : actions/checkout@v4
19
20
with :
20
- fetch-depth : 0 # Fetch full history to access all tags
21
- ref : main # Ensure we're starting from main branch
21
+ fetch-depth : 0 # Fetch full history for changelog generation
22
+ ref : main # Start from main branch
22
23
23
- - name : Install git-chglog
24
+ - name : Setup git-chglog
24
25
run : |
25
- curl -o git-chglog -L https://github.com/git-chglog/git-chglog/releases/download/0.9.1/git-chglog_linux_amd64
26
+ CHGLOG_VERSION="0.9.1"
27
+ curl -o git-chglog -L "https://github.com/git-chglog/git-chglog/releases/download/${CHGLOG_VERSION}/git-chglog_linux_amd64"
26
28
chmod +x git-chglog
27
29
28
- - name : Remove Existing CHANGELOG.md
29
- run : |
30
- rm -f CHANGELOG.md # Remove the existing changelog to allow complete regeneration
31
-
32
- - name : Generate New CHANGELOG.md
30
+ - name : Generate CHANGELOG.md
31
+ id : generate
33
32
run : |
33
+ rm -f CHANGELOG.md # Remove existing changelog
34
34
./git-chglog -o CHANGELOG.md
35
- env :
36
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
37
-
38
- - name : Clean up git-chglog
39
- run : |
40
- rm git-chglog
41
35
42
- - name : Check for Changes
43
- id : check_changes
44
- run : |
36
+ # Check for changes and set output
45
37
if git diff --quiet CHANGELOG.md; then
46
- echo "No changes in CHANGELOG.md"
47
- echo "::set-output name=changes::false"
38
+ echo "changes=false" >> $GITHUB_OUTPUT
48
39
else
49
- echo "Changes detected in CHANGELOG.md"
50
- echo "::set-output name=changes::true"
40
+ echo "changes=true" >> $GITHUB_OUTPUT
51
41
fi
42
+ env :
43
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
52
44
53
- - name : Commit and Push Changes
54
- if : steps.check_changes.outputs.changes == 'true' # Only run if there are changes
55
- uses : stefanzweifel/git-auto-commit-action@v5
56
- with :
57
- commit_message : " Update CHANGELOG"
58
- file_pattern : CHANGELOG.md
59
- branch : update-changelog-${{ github.run_id }}
45
+ - name : Cleanup
46
+ run : rm git-chglog
47
+ if : always() # Ensure cleanup happens even if previous steps fail
60
48
61
49
- name : Create Pull Request
62
- if : steps.check_changes .outputs.changes == 'true' # Only run if there are changes
50
+ if : steps.generate .outputs.changes == 'true'
63
51
uses : peter-evans/create-pull-request@v4
64
52
with :
65
- commit-message : " Update CHANGELOG"
66
- title : " Update Changelog"
67
- body : " This PR updates the entire CHANGELOG to include all releases."
53
+ token : ${{ secrets.GITHUB_TOKEN }}
54
+ commit-message : " chore: update CHANGELOG.md"
55
+ title : " 📝 Update Changelog"
56
+ body : |
57
+ This PR updates the CHANGELOG.md to include all releases.
58
+
59
+ - Generated using git-chglog
60
+ - Triggered by: ${{ github.event_name }}
68
61
branch : update-changelog-${{ github.run_id }}
69
62
base : main
70
- delete-branch : true # Automatically delete branch after merge
63
+ delete-branch : true
64
+ labels : |
65
+ documentation
66
+ automated-pr
0 commit comments