diff --git a/.github/scripts/generate-changelog.mjs b/.github/scripts/generate-changelog.mjs index 6f9181c..0edf16b 100644 --- a/.github/scripts/generate-changelog.mjs +++ b/.github/scripts/generate-changelog.mjs @@ -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: diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 6f5390e..bfa5d63 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -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 @@ -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) @@ -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 { @@ -68,6 +80,12 @@ jobs: echo "DIFFSTAT_EOF" } >> "$GITHUB_ENV" + { + echo "PR_DETAILS<> "$GITHUB_ENV" + - name: Determine version bump and generate changelog id: ai env: