Skip to content

Commit 64a5e6d

Browse files
committed
workspace-grouped changelog, no more git-cliff!
1 parent d985621 commit 64a5e6d

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
@@ -111,10 +111,6 @@ jobs:
111111
with:
112112
fetch-depth: 0
113113
- uses: dtolnay/rust-toolchain@stable
114-
- name: Install git-cliff
115-
uses: taiki-e/install-action@v2
116-
with:
117-
tool: git-cliff
118114
- name: Determine next version from conventional commits
119115
id: next_version
120116
working-directory: ./rust/main
@@ -179,17 +175,16 @@ jobs:
179175
echo "Next version: $NEW_VERSION ($BUMP_TYPE bump from $CURRENT_VERSION)"
180176
- name: Generate changelog
181177
id: changelog
182-
working-directory: ./rust/main
183178
env:
184179
NEW_VERSION: ${{ steps.next_version.outputs.new_version }}
185180
run: |
186-
# Generate changelog for commits since last release
181+
# Generate workspace-grouped changelog using custom script
187182
LATEST_TAG=$(git tag -l "agents-v*" --sort=-version:refname | grep -E "^agents-v[0-9]+\.[0-9]+\.[0-9]+$" | head -1)
188183
189184
if [ -z "$LATEST_TAG" ]; then
190-
CHANGELOG=$(git-cliff --config cliff.toml --unreleased --strip all)
185+
CHANGELOG=$(./rust/scripts/generate-workspace-changelog.sh)
191186
else
192-
CHANGELOG=$(git-cliff --config cliff.toml "${LATEST_TAG}..HEAD" --strip all)
187+
CHANGELOG=$(./rust/scripts/generate-workspace-changelog.sh "${LATEST_TAG}..HEAD")
193188
fi
194189
195190
# Save changelog to file for PR body
@@ -277,11 +272,11 @@ jobs:
277272
git push -f origin "$BRANCH_NAME"
278273
279274
# Create or update PR
280-
PR_BODY="## Release agents v${NEW_VERSION}
275+
PR_BODY="# Release agents v${NEW_VERSION}
281276
282277
This PR prepares the release of Hyperlane agents version **${NEW_VERSION}** (${BUMP_TYPE} bump).
283278
284-
### What's Changed
279+
## What's Changed
285280
286281
${CHANGELOG}
287282
@@ -336,12 +331,7 @@ jobs:
336331
- uses: actions/checkout@v4
337332
with:
338333
fetch-depth: 0
339-
- name: Install git-cliff
340-
uses: taiki-e/install-action@v2
341-
with:
342-
tool: git-cliff
343334
- name: Determine version and create release
344-
working-directory: ./rust/main
345335
env:
346336
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
347337
IS_PRERELEASE: ${{ github.event_name == 'workflow_dispatch' && inputs.prerelease }}
@@ -381,12 +371,21 @@ jobs:
381371
TAG_NAME="agents-v${VERSION}"
382372
echo "Creating $RELEASE_TYPE: $TAG_NAME"
383373
384-
# Generate changelog
374+
# Generate workspace-grouped changelog
385375
PREV_TAG=$(git describe --tags --abbrev=0 --match "agents-v*" 2>/dev/null || echo "")
376+
377+
# For stable releases (push to main), use HEAD~1 to exclude the version bump commit
378+
# For prereleases (workflow_dispatch), use HEAD since there's no version bump commit
379+
if [ "$IS_PRERELEASE" = "true" ]; then
380+
COMMIT_RANGE_END="HEAD"
381+
else
382+
COMMIT_RANGE_END="HEAD~1"
383+
fi
384+
386385
if [ -z "$PREV_TAG" ]; then
387-
CHANGELOG=$(git-cliff --config cliff.toml --unreleased --strip all)
386+
CHANGELOG=$(./rust/scripts/generate-workspace-changelog.sh)
388387
else
389-
CHANGELOG=$(git-cliff --config cliff.toml --latest --strip all)
388+
CHANGELOG=$(./rust/scripts/generate-workspace-changelog.sh "${PREV_TAG}..${COMMIT_RANGE_END}")
390389
fi
391390
392391
# 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)