@@ -15,38 +15,41 @@ jobs:
1515 runs-on : ubuntu-22.04
1616 permissions :
1717 contents : write
18+ pull-requests : write
1819 outputs :
19- release_body : ${{ steps.git-cliff.outputs.content }}
20+ release_body : ${{ steps.git-cliff-latest .outputs.content }}
2021 steps :
2122 - name : Checkout
2223 uses : actions/checkout@v4
2324 with :
2425 fetch-depth : 0
2526
26- - name : Generate a changelog
27- uses : orhun/git-cliff-action@main
28- id : git-cliff
27+ - name : Generate latest changelog for release
28+ uses : orhun/git-cliff-action@v4
29+ id : git-cliff-latest
2930 with :
3031 config : pyproject.toml
3132 args : -vv --latest --strip header
33+ env :
34+ GITHUB_REPO : ${{ github.repository }}
3235
3336 - name : Fetch latest main
3437 run : git fetch origin main
3538
3639 - name : Create worktree for changelog
3740 run : git worktree add worktree-changelog origin/main
3841
39- - name : Install git-cliff
40- uses : taiki-e/install-action@v2
42+ - name : Generate full changelog in worktree
43+ working-directory : worktree-changelog
44+ uses : orhun/git-cliff-action@v4
4145 with :
42- tool : git-cliff
43-
44- - name : Generate changelog in worktree
45- run : |
46- cd worktree-changelog
47- git-cliff --config ../pyproject.toml -vv --latest --strip header --output docs/changelog.rst
46+ config : pyproject.toml
47+ args : -vv
48+ env :
49+ OUTPUT : docs/changelog.rst
50+ GITHUB_REPO : ${{ github.repository }}
4851
49- - name : Commit and push changelog
52+ - name : Create PR with changelog updates
5053 working-directory : worktree-changelog
5154 run : |
5255 git config user.name 'github-actions[bot]'
5558 if git diff --staged --quiet; then
5659 echo "No changes to commit"
5760 else
58- git commit -m "docs: update changelog [skip ci]"
59- git push origin HEAD:main
61+ # Create unique branch name (includes run ID to avoid collisions on reruns)
62+ BRANCH_NAME="changelog/update-$(git rev-parse --short HEAD)-${{ github.run_id }}"
63+ git checkout -b "$BRANCH_NAME"
64+
65+ git commit -m "docs: update changelog"
66+
67+ # Push and create PR
68+ git push origin "$BRANCH_NAME"
69+ gh pr create \
70+ --base main \
71+ --head "$BRANCH_NAME" \
72+ --title "docs: update changelog" \
73+ --body "Automated changelog update generated by git-cliff.
74+
75+ This PR updates the changelog with the latest commits.
76+
77+ --label "documentation" \
78+ --label "automated"
6079 fi
80+ env :
81+ GH_TOKEN : ${{ github.token }}
82+
83+ - name : Update GitHub release body
84+ if : github.event_name == 'release'
85+ run : |
86+ # Update release body with latest changelog
87+ gh release edit "${{ github.event.release.tag_name }}" \
88+ --notes "${{ steps.git-cliff-latest.outputs.content }}" \
89+ --repo ${{ github.repository }}
90+ env :
91+ GH_TOKEN : ${{ github.token }}
6192
6293 - name : Cleanup worktree
6394 if : always()
0 commit comments