From 738a8709c4fbdcf96dc0bd3a4610c3aff64b6acb Mon Sep 17 00:00:00 2001 From: neon <18559658+neonsolstice@users.noreply.github.com> Date: Sat, 23 May 2026 02:37:22 +0000 Subject: [PATCH] ci: fetch github usernames via API for release notes The previous hardcoded AUTHOR_MAP was incomplete and caused missing authors in the generated release notes. The config now attempts to fetch actual GitHub usernames associated with commit SHAs using the GitHub API, falling back to local git log author names if the API request fails. --- release.config.js | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/release.config.js b/release.config.js index 122c2b944..2d4ec8854 100644 --- a/release.config.js +++ b/release.config.js @@ -4,11 +4,6 @@ const { spawnSync } = require("child_process"); const DOCKER_IMAGE = "ghcr.io/bookorbit/bookorbit"; -// Maps local git author names to GitHub usernames for @-mentions in release notes. -const AUTHOR_MAP = { - neon: "neonsolstice", -}; - const TYPES = [ { type: "feat", section: "Features" }, { type: "fix", section: "Bug Fixes" }, @@ -94,19 +89,50 @@ const mainTemplate = [ // for the commitPartial. function finalizeContext(ctx) { try { + const shaToGithubUser = new Map(); + + try { + const ghToken = process.env.GITHUB_TOKEN || process.env.GH_TOKEN; + if (ghToken && ctx.owner && ctx.repository) { + const curlResult = spawnSync( + "curl", + [ + "-s", + "-H", `Authorization: Bearer ${ghToken}`, + "-H", "X-GitHub-Api-Version: 2022-11-28", + `https://api.github.com/repos/${ctx.owner}/${ctx.repository}/commits?per_page=100` + ], + { encoding: "utf8" } + ); + if (curlResult.status === 0) { + const apiCommits = JSON.parse(curlResult.stdout); + if (Array.isArray(apiCommits)) { + for (const c of apiCommits) { + if (c.sha && c.author && c.author.login) { + shaToGithubUser.set(c.sha, c.author.login); + } + } + } + } + } + } catch (e) { + // Ignore API errors, fall back to local git log + } + const result = spawnSync("git", ["log", "--format=%H %aN", "--max-count=500"], { encoding: "utf8", cwd: process.cwd(), }); - const shaToGithubUser = new Map(); if (result.status === 0) { for (const line of result.stdout.split("\n").filter(Boolean)) { const spaceIdx = line.indexOf(" "); const hash = line.substring(0, spaceIdx); const authorName = line.substring(spaceIdx + 1).trim(); if (!authorName || /\[bot\]/i.test(authorName)) continue; - shaToGithubUser.set(hash, AUTHOR_MAP[authorName] ?? authorName); + if (!shaToGithubUser.has(hash)) { + shaToGithubUser.set(hash, authorName); + } } }