Skip to content

Commit bc80313

Browse files
ekropotinclaude
andauthored
chore: introduce comprehensive changelog generation system (#138)
Adds automated changelog generation with git-cliff integration across all workflows. Updates version bump workflow to include changelog generation step. Enhances release workflows with proper changelog integration. Introduces generate-changelogs.sh script for automated changelog management. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude <noreply@anthropic.com>
1 parent c53c617 commit bc80313

5 files changed

Lines changed: 88 additions & 37 deletions

File tree

.github/workflows/crates-version-bump.yml

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,22 @@ jobs:
3232
- name: Setup Rust
3333
uses: dtolnay/rust-toolchain@stable
3434

35-
- name: Cache cargo-workspaces
35+
- name: Cache cargo tools
3636
uses: actions/cache@v3
37-
id: cache-cargo-workspaces
37+
id: cache-cargo-tools
3838
with:
39-
path: ~/.cargo/bin/cargo-workspaces
40-
key: cargo-workspaces-${{ runner.os }}-v1
39+
path: |
40+
~/.cargo/bin/cargo-workspaces
41+
~/.cargo/bin/git-cliff
42+
key: cargo-tools-${{ runner.os }}-v1
4143
restore-keys: |
42-
cargo-workspaces-${{ runner.os }}-
44+
cargo-tools-${{ runner.os }}-
4345
44-
- name: Install cargo-workspaces
45-
if: steps.cache-cargo-workspaces.outputs.cache-hit != 'true'
46-
run: cargo install cargo-workspaces
46+
- name: Install cargo tools
47+
if: steps.cache-cargo-tools.outputs.cache-hit != 'true'
48+
run: |
49+
cargo install cargo-workspaces
50+
cargo install git-cliff
4751
4852
- name: Setup Git
4953
run: |
@@ -66,15 +70,41 @@ jobs:
6670
FORCE_FLAG="--force '*'"
6771
fi
6872
73+
CHANGED_CRATES=$(cargo workspaces changed)
74+
75+
if [[ -z "$CHANGED_CRATES" ]]; then
76+
echo "No crates changed since last tag. Nothing to do."
77+
exit 0
78+
fi
79+
6980
case "$BRANCH" in
7081
main)
71-
cargo workspaces version --allow-branch "$BRANCH" --no-global-tag --yes $FORCE_FLAG
82+
cargo workspaces version --allow-branch "$BRANCH" --no-global-tag --yes $FORCE_FLAG --no-git-push
7283
;;
7384
development)
74-
cargo workspaces version --allow-branch "$BRANCH" --no-global-tag prerelease --pre-id "$PRE_ID" --yes $FORCE_FLAG
85+
cargo workspaces version --allow-branch "$BRANCH" --no-global-tag prerelease --pre-id "$PRE_ID" --yes $FORCE_FLAG --no-git-push
7586
;;
7687
*)
7788
echo "❌ This workflow can only be run on 'main' or 'development'."
7889
exit 1
7990
;;
8091
esac
92+
93+
NEW_TAGS=$(git tag --points-at HEAD)
94+
echo "Tags created locally:"
95+
echo "$NEW_TAGS"
96+
97+
../../scripts/generate-changelogs.sh "$CHANGED_CRATES"
98+
99+
echo "Amending commit to include changelogs..."
100+
git commit --amend --no-edit
101+
102+
for tag in $NEW_TAGS; do
103+
echo "Re-applying tag $tag on amended commit..."
104+
git tag -f "$tag"
105+
done
106+
107+
git push origin "$BRANCH"
108+
git push origin --tags
109+
110+
echo "✅ Version bump and changelogs pushed successfully!"

.github/workflows/release-cli.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,17 @@ jobs:
3333
run: cargo publish -p quickmark-cli --token ${{ secrets.CRATES_IO_TOKEN }}
3434

3535
- name: Generate changelog
36+
id: changelog
3637
uses: orhun/git-cliff-action@v4
3738
with:
3839
config: cliff.toml
39-
args: --include-path "crates/quickmark-cli/**" --tag-pattern "quickmark-cli@*"
40-
env:
41-
OUTPUT: CHANGELOG.md
40+
args: --include-path "crates/quickmark-cli/**" --tag-pattern "quickmark-cli@*" --latest
4241

4342
- name: Create GitHub release
4443
uses: softprops/action-gh-release@v2
4544
with:
46-
body_path: CHANGELOG.md
45+
body: ${{ steps.changelog.outputs.content }}
4746
draft: false
4847
prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }}
4948
env:
50-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release-core.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,13 @@ jobs:
3636
uses: orhun/git-cliff-action@v4
3737
with:
3838
config: cliff.toml
39-
args: --include-path "crates/quickmark-core/**" --tag-pattern "quickmark-core@*"
40-
env:
41-
OUTPUT: CHANGELOG.md
39+
args: --include-path "crates/quickmark-core/**" --tag-pattern "quickmark-core@*" --latest
4240

4341
- name: Create GitHub release
4442
uses: softprops/action-gh-release@v2
4543
with:
46-
body_path: CHANGELOG.md
44+
body: ${{ steps.changelog.outputs.content }}
4745
draft: false
4846
prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }}
4947
env:
50-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release-server.yml

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Release QuickMark Server
1+
name: Release QuickMark Server
22

33
on:
44
push:
@@ -64,7 +64,7 @@ jobs:
6464
run: |
6565
ARCHIVE_NAME="quickmark-server-${{ matrix.target }}.tar.gz"
6666
echo "archive_name=$ARCHIVE_NAME" >> $GITHUB_OUTPUT
67-
67+
6868
# Create archive with the binary renamed to quickmark-server
6969
mkdir -p archive-temp
7070
cp "target/${{ matrix.target }}/release/quickmark-server${{ matrix.suffix }}" archive-temp/quickmark-server${{ matrix.suffix }}
@@ -104,20 +104,6 @@ jobs:
104104
- name: Publish quickmark-server to crates.io
105105
run: cargo publish -p quickmark-server --token ${{ secrets.CRATES_IO_TOKEN }}
106106

107-
- name: Generate changelog
108-
uses: orhun/git-cliff-action@v4
109-
with:
110-
config: cliff.toml
111-
args: --include-path "crates/quickmark-server/**" --tag-pattern "quickmark-server@*"
112-
env:
113-
OUTPUT: CHANGELOG.md
114-
115-
- name: Upload changelog
116-
uses: actions/upload-artifact@v4
117-
with:
118-
name: changelog
119-
path: CHANGELOG.md
120-
121107
release:
122108
name: Create Release
123109
needs: [build, publish]
@@ -149,11 +135,18 @@ jobs:
149135
ls -la release-archives/
150136
if [ -f CHANGELOG.md ]; then ls -la CHANGELOG.md; fi
151137
138+
- name: Generate changelog
139+
id: changelog
140+
uses: orhun/git-cliff-action@v4
141+
with:
142+
config: cliff.toml
143+
args: --include-path "crates/quickmark-server/**" --tag-pattern "quickmark-server@*" --latest
144+
152145
- name: Create release
153146
uses: softprops/action-gh-release@v2
154147
with:
155148
files: release-archives/*
156-
body_path: CHANGELOG.md
149+
body: ${{ steps.changelog.outputs.content }}
157150
draft: false
158151
prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }}
159152
env:

scripts/generate-changelogs.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
if [[ $# -eq 0 ]]; then
5+
echo "Usage: $0 <crate1> [<crate2> ...]"
6+
exit 1
7+
fi
8+
9+
REPO_ROOT=$(git rev-parse --show-toplevel)
10+
cd "$REPO_ROOT"
11+
12+
for crate in "$@"; do
13+
echo "Processing crate: $crate"
14+
15+
# Get crate manifest path from cargo metadata
16+
CRATE_DIR=$(cargo metadata --format-version 1 --no-deps \
17+
| jq -r --arg NAME "$crate" '.packages[] | select(.name==$NAME) | .manifest_path' \
18+
| xargs dirname)
19+
20+
REL_CRATE_DIR=$(realpath --relative-to="$REPO_ROOT" "$CRATE_DIR")
21+
22+
echo "Generating changelog for $crate in $REL_CRATE_DIR..."
23+
git cliff \
24+
--tag-pattern "$crate@*" \
25+
--include-path "$REL_CRATE_DIR/**" \
26+
--output "$REL_CRATE_DIR/CHANGELOG.md"
27+
28+
git add "$REL_CRATE_DIR/CHANGELOG.md"
29+
done
30+
31+
echo "✅ Changelogs staged for crates: $*"

0 commit comments

Comments
 (0)