Skip to content

Commit f8bbbd6

Browse files
committed
workspace-grouped changelog, no more git-cliff!
1 parent 0532e3e commit f8bbbd6

File tree

3 files changed

+98
-71
lines changed

3 files changed

+98
-71
lines changed

.github/workflows/rust-release.yml

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,6 @@ jobs:
110110
with:
111111
fetch-depth: 0
112112
- uses: dtolnay/rust-toolchain@stable
113-
- name: Install git-cliff
114-
uses: taiki-e/install-action@v2
115-
with:
116-
tool: git-cliff
117113
- name: Determine next version from conventional commits
118114
id: next_version
119115
working-directory: ./rust/main
@@ -178,17 +174,16 @@ jobs:
178174
echo "Next version: $NEW_VERSION ($BUMP_TYPE bump from $CURRENT_VERSION)"
179175
- name: Generate changelog
180176
id: changelog
181-
working-directory: ./rust/main
182177
env:
183178
NEW_VERSION: ${{ steps.next_version.outputs.new_version }}
184179
run: |
185-
# Generate changelog for commits since last release
180+
# Generate workspace-grouped changelog using custom script
186181
LATEST_TAG=$(git tag -l "agents-v*" --sort=-version:refname | grep -E "^agents-v[0-9]+\.[0-9]+\.[0-9]+$" | head -1)
187182
188183
if [ -z "$LATEST_TAG" ]; then
189-
CHANGELOG=$(git-cliff --config cliff.toml --unreleased --strip all)
184+
CHANGELOG=$(./rust/scripts/generate-workspace-changelog.sh)
190185
else
191-
CHANGELOG=$(git-cliff --config cliff.toml "${LATEST_TAG}..HEAD" --strip all)
186+
CHANGELOG=$(./rust/scripts/generate-workspace-changelog.sh "${LATEST_TAG}..HEAD")
192187
fi
193188
194189
# Save changelog to file for PR body
@@ -276,11 +271,11 @@ jobs:
276271
git push -f origin "$BRANCH_NAME"
277272
278273
# Create or update PR
279-
PR_BODY="## Release agents v${NEW_VERSION}
274+
PR_BODY="# Release agents v${NEW_VERSION}
280275
281276
This PR prepares the release of Hyperlane agents version **${NEW_VERSION}** (${BUMP_TYPE} bump).
282277
283-
### What's Changed
278+
## What's Changed
284279
285280
${CHANGELOG}
286281
@@ -335,12 +330,7 @@ jobs:
335330
- uses: actions/checkout@v4
336331
with:
337332
fetch-depth: 0
338-
- name: Install git-cliff
339-
uses: taiki-e/install-action@v2
340-
with:
341-
tool: git-cliff
342333
- name: Determine version and create release
343-
working-directory: ./rust/main
344334
env:
345335
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
346336
IS_PRERELEASE: ${{ github.event_name == 'workflow_dispatch' && inputs.prerelease }}
@@ -380,12 +370,21 @@ jobs:
380370
TAG_NAME="agents-v${VERSION}"
381371
echo "Creating $RELEASE_TYPE: $TAG_NAME"
382372
383-
# Generate changelog
373+
# Generate workspace-grouped changelog
384374
PREV_TAG=$(git describe --tags --abbrev=0 --match "agents-v*" 2>/dev/null || echo "")
375+
376+
# For stable releases (push to main), use HEAD~1 to exclude the version bump commit
377+
# For prereleases (workflow_dispatch), use HEAD since there's no version bump commit
378+
if [ "$IS_PRERELEASE" = "true" ]; then
379+
COMMIT_RANGE_END="HEAD"
380+
else
381+
COMMIT_RANGE_END="HEAD~1"
382+
fi
383+
385384
if [ -z "$PREV_TAG" ]; then
386-
CHANGELOG=$(git-cliff --config cliff.toml --unreleased --strip all)
385+
CHANGELOG=$(./rust/scripts/generate-workspace-changelog.sh)
387386
else
388-
CHANGELOG=$(git-cliff --config cliff.toml --latest --strip all)
387+
CHANGELOG=$(./rust/scripts/generate-workspace-changelog.sh "${PREV_TAG}..${COMMIT_RANGE_END}")
389388
fi
390389
391390
# Add warning for pre-releases

rust/main/cliff.toml

Lines changed: 0 additions & 53 deletions
This file was deleted.
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/usr/bin/env bash
2+
# Script to generate workspace-grouped changelog for rust agents
3+
set -euo pipefail
4+
5+
# Determine script directory and repo structure
6+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7+
RUST_MAIN_DIR="$SCRIPT_DIR/../main"
8+
9+
# Get the commit range
10+
if [ $# -eq 0 ]; then
11+
# No arguments - use unreleased commits
12+
LATEST_TAG=$(git tag -l "agents-v*" --sort=-version:refname | grep -E "^agents-v[0-9]+\.[0-9]+\.[0-9]+$" | head -1 || echo "")
13+
if [ -z "$LATEST_TAG" ]; then
14+
COMMIT_RANGE="HEAD"
15+
else
16+
COMMIT_RANGE="${LATEST_TAG}..HEAD"
17+
fi
18+
else
19+
COMMIT_RANGE="$1"
20+
fi
21+
22+
# Temporary directory for categorization
23+
TEMP_DIR=$(mktemp -d)
24+
trap "rm -rf $TEMP_DIR" EXIT
25+
26+
# Extract workspace members from rust/main/Cargo.toml
27+
WORKSPACE_MEMBERS=$(grep -A 100 '^\[workspace\]' "$RUST_MAIN_DIR/Cargo.toml" | sed -n '/^members = \[/,/^\]/p' | grep '"' | sed 's/[", ]//g')
28+
29+
# Get all commits in the range (filter to rust/main directory)
30+
git log --no-merges --format="%H" $COMMIT_RANGE -- rust/main | while read -r commit_hash; do
31+
# Get commit message
32+
commit_msg=$(git log -1 --format="%s" "$commit_hash")
33+
short_hash=$(echo "$commit_hash" | cut -c1-7)
34+
35+
# Get files changed in this commit (within rust/main)
36+
files=$(git diff-tree --no-commit-id --name-only -r "$commit_hash" -- rust/main)
37+
38+
# Categorize based on workspace membership
39+
workspace=""
40+
for file in $files; do
41+
# Strip rust/main/ prefix if present
42+
file=$(echo "$file" | sed 's|^rust/main/||')
43+
44+
# Check which workspace this file belongs to
45+
for member in $WORKSPACE_MEMBERS; do
46+
if [[ "$file" =~ ^"$member"(/|$) ]]; then
47+
workspace="$member"
48+
break 2 # Break both loops
49+
fi
50+
done
51+
done
52+
53+
# Default to "Other" if no workspace found
54+
if [ -z "$workspace" ]; then
55+
workspace="Other"
56+
fi
57+
58+
# Sanitize workspace name for file system (replace / with __)
59+
workspace_file=$(echo "$workspace" | tr '/' '_')
60+
61+
# Store commit in workspace category file
62+
echo "$workspace|$commit_msg|$short_hash" >> "$TEMP_DIR/$workspace_file"
63+
done
64+
65+
# Process workspace members in the order they appear in Cargo.toml, then "Other"
66+
for workspace in $WORKSPACE_MEMBERS "Other"; do
67+
workspace_file=$(echo "$workspace" | tr '/' '_')
68+
69+
if [ -f "$TEMP_DIR/$workspace_file" ]; then
70+
echo "### $workspace"
71+
echo ""
72+
73+
# Sort and deduplicate commits (extract workspace name, msg, hash)
74+
sort -u "$TEMP_DIR/$workspace_file" | while IFS='|' read -r ws msg hash; do
75+
echo "* $msg (#$hash)"
76+
done
77+
echo ""
78+
fi
79+
done
80+
81+
echo "<!-- generated by workspace changelog script -->"

0 commit comments

Comments
 (0)