Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .github/scripts/generate-changelog.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,22 @@ if (!apiKey) {
const oldVersion = process.env.OLD_VERSION || "0.0.0";
const commits = process.env.COMMITS || "";
const diffstat = process.env.DIFFSTAT || "";
const prDetails = process.env.PR_DETAILS || "";
const today = new Date().toISOString().split("T")[0];

const prompt = `You are generating a release changelog for @lightsparkdev/origin, a React component library and design system.

Current version: ${oldVersion}
Diff stat: ${diffstat}

Commits since last release:
Merge commits since last release:
${commits}
${prDetails ? `\nPR descriptions (written by the authors — use these as your primary source):\n${prDetails}` : ""}
Files changed (diff stat):
${diffstat}

Tasks:
1. Determine if this is a "minor" or "patch" release. Use minor if there are new components, new features, or new public API surface. Use patch for bug fixes, docs, internal refactors, CI changes, and dependency updates. Never use major.
2. Write a concise changelog entry that summarizes ONLY changes that impact consumers of the package (new components, API changes, bug fixes, style changes). Omit CI, docs, internal tooling, and repo maintenance.
2. Write a concise changelog entry that summarizes ONLY changes that impact consumers of the package (new components, API changes, bug fixes, style changes). Omit CI, docs, internal tooling, and repo maintenance. Use the PR descriptions as your primary source of truth for what changed — they contain the most accurate and detailed information.

Respond in EXACTLY this format with no other text:

Expand Down
24 changes: 21 additions & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ jobs:

- name: Collect changes since last release
id: changes
env:
GH_TOKEN: ${{ github.token }}
run: |
# Ensure tags are fetched from the upstream repo
git fetch origin --tags
Expand All @@ -42,7 +44,7 @@ jobs:
echo "Current version: $OLD_VERSION"
echo "Tag exists: $(git tag -l v${OLD_VERSION})"
echo "Commits since tag:"
git log v${OLD_VERSION}..HEAD --oneline | head -10 || echo "(none)"
git log v${OLD_VERSION}..HEAD --oneline | head -20 || echo "(none)"

# Collect PR merge commit messages since last tag
MERGES=$(git log v${OLD_VERSION}..HEAD --merges --pretty=format:"%s" || true)
Expand All @@ -52,8 +54,18 @@ jobs:
MERGES=$(git log v${OLD_VERSION}..HEAD --pretty=format:"%s" --no-merges | head -30)
fi

# Also collect the diff stat for context
DIFFSTAT=$(git diff v${OLD_VERSION}..HEAD --stat | tail -1)
# Extract PR numbers from merge commit messages (e.g. "(#117)")
# and fetch their bodies for richer context
PR_DETAILS=""
for pr_num in $(echo "$MERGES" | grep -o '#[0-9]\+' | tr -d '#' | sort -un); do
pr_body=$(gh pr view "$pr_num" --json title,body --jq '"### PR #" + (.title | tostring) + "\n" + .body' 2>/dev/null || true)
if [ -n "$pr_body" ]; then
PR_DETAILS="${PR_DETAILS}${pr_body}\n\n"
fi
done

# Collect per-file diff stat for context
DIFFSTAT=$(git diff v${OLD_VERSION}..HEAD --stat)

# Write to env files for the next step
{
Expand All @@ -68,6 +80,12 @@ jobs:
echo "DIFFSTAT_EOF"
} >> "$GITHUB_ENV"

{
echo "PR_DETAILS<<PR_DETAILS_EOF"
echo -e "$PR_DETAILS"
echo "PR_DETAILS_EOF"
} >> "$GITHUB_ENV"

- name: Determine version bump and generate changelog
id: ai
env:
Expand Down