@@ -125,6 +125,57 @@ jobs:
125125 needs : build_assets
126126 runs-on : ubuntu-latest
127127 steps :
128+ - name : Check out repo for changelog generation
129+ uses : actions/checkout@v4
130+ with :
131+ fetch-tags : true
132+ fetch-depth : 0
133+ # Ensure we checkout the repo where the workflow runs, not a fork
134+ repository : ${{ github.repository }}
135+ # Use the token with write permissions
136+ token : ${{ secrets.GITHUB_TOKEN }}
137+
138+ - name : Generate and Commit Changelog
139+ run : |
140+ echo "Installing git-chglog..."
141+ mkdir chglog_tmp
142+ wget https://github.com/git-chglog/git-chglog/releases/download/v0.15.4/git-chglog_0.15.4_linux_amd64.tar.gz
143+ tar -xvzf git-chglog_0.15.4_linux_amd64.tar.gz -C chglog_tmp
144+
145+ echo "Generating changelog..."
146+ ./chglog_tmp/git-chglog -o ./CHANGELOG.md
147+
148+ echo "Cleaning up git-chglog files..."
149+ rm git-chglog_0.15.4_linux_amd64.tar.gz
150+ rm -rf chglog_tmp
151+
152+ echo "Configuring git user..."
153+ git config user.name "github-actions[bot]"
154+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
155+
156+ echo "Fetching main branch..."
157+ # Fetch the latest main branch from origin
158+ git fetch origin refs/heads/main
159+
160+ echo "Creating temporary branch based on origin/main..."
161+ # Create a new branch based on the fetched origin/main
162+ git checkout -b changelog-update origin/main
163+
164+ echo "Adding and committing CHANGELOG.md..."
165+ git add ./CHANGELOG.md
166+ # Check if there are changes to commit to avoid empty commit error if file exists and is unchanged
167+ if ! git diff --staged --quiet; then
168+ git commit -m "chore(docs): update CHANGELOG for release ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.version || github.ref_name }} [skip ci]"
169+ else
170+ echo "No changes to CHANGELOG.md to commit."
171+ fi
172+
173+ echo "Pushing changelog commit to remote main branch..."
174+ # Push the new local branch specifically to the remote *branch* main
175+ git push origin changelog-update:refs/heads/main
176+ env :
177+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
178+
128179 - name : Download all artifacts
129180 uses : actions/download-artifact@v4
130181 with :
0 commit comments