name: Changelog Generation
on:
push:
branches:
- develop
- main
pull_request:
branches:
- develop
- main
concurrency:
group: changelog-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
pull-requests: write
jobs:
changelog:
name: Generate/Update Changelog
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Install git-cliff
run: cargo install git-cliff --locked
- name: Generate changelog preview
id: preview
run: |
CHANGELOG=$(git-cliff --config .cliff.toml 2>&1 || true)
FEATURES=$(echo -e $CHANGELOG | grep -c feat || echo 0)
FIXES=$(echo -e $CHANGELOG | grep -c fix || echo 0)
echo features=$FEATURES >> $GITHUB_OUTPUT
echo fixes=$FIXES >> $GITHUB_OUTPUT
echo $CHANGELOG > changelog_preview.txt
- name: Preview changelog
run: |
echo === Changelog Preview ===
head -50 changelog_preview.txt
echo Changes detected: ${{ steps.preview.outputs.features }} features, ${{ steps.preview.outputs.fixes }} fixes
- name: Create changelog PR from develop
if: github.ref == 'refs/heads/develop' && github.event_name == 'push'
env:
GH_TOKEN: ${{ github.token }}
continue-on-error: true
run: |
git-cliff --config .cliff.toml --output CHANGELOG.md || true
if ! git diff --quiet CHANGELOG.md; then
echo Changelog updated, creating PR...
git config user.name github-actions[bot]
git config user.email github-actions[bot]@users.noreply.github.com
BRANCH_NAME=chore/update-changelog-${{ github.run_number }}
git checkout -b $BRANCH_NAME
git add CHANGELOG.md
git commit -m 'docs(changelog): update CHANGELOG.md' -m 'Auto-generated by changelog workflow'
git push origin $BRANCH_NAME
head -100 changelog_preview.txt > pr_body.txt
gh pr create --base develop --head $BRANCH_NAME --title 'docs(changelog): update CHANGELOG.md' --body-file pr_body.txt
echo Changelog PR created
else
echo No changelog changes needed
fi
- name: Report status
run: |
echo === Changelog Workflow Status ===
echo Branch: ${{ github.ref }}
echo Event: ${{ github.event_name }}
echo Features: ${{ steps.preview.outputs.features }}
echo Fixes: ${{ steps.preview.outputs.fixes }}