From a776a5d6ebad8797f11bbd6ed8cf0436364ab718 Mon Sep 17 00:00:00 2001 From: Steve Mendes Reis <6802086+M4n0x@users.noreply.github.com> Date: Wed, 2 Dec 2026 21:36:36 +0100 Subject: [PATCH 01/14] docs: show every contributor's avatar in the README Adds MaHofseth, cassiozen and khatami10, and marks the block for the README contributors workflow. alexandrebucci is a second account of albucci, so it shares his avatar. --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 5bf493ed..699138c3 100644 --- a/README.md +++ b/README.md @@ -126,14 +126,19 @@ Change content, appearance and behavior in Settings, with undo and redo. Or edit ## Contributing +
+ Built by [Sebastien Graf](https://github.com/Seb-GRAF) and [Steve Mendes Reis](https://github.com/M4n0x), with help from [everyone who has contributed](https://github.com/stablebox/StableBar/graphs/contributors). From 6a02de13280cedc4b780c26f847fe8c1a30171d5 Mon Sep 17 00:00:00 2001 From: Steve Mendes Reis <6802086+M4n0x@users.noreply.github.com> Date: Wed, 2 Dec 2026 21:36:36 +0100 Subject: [PATCH 02/14] ci: propose the README's contributors from GitHub's list Every Monday, a workflow compares the avatars in the README with GitHub's contributors list and, when it changed, opens a pull request from the readme-contributors branch. The release app opens it, so its required checks run. --- .github/scripts/readme-contributors.mjs | 62 +++++++++++ .github/scripts/readme-contributors.test.mjs | 81 ++++++++++++++ .github/workflows/readme-contributors.yml | 106 +++++++++++++++++++ CONTRIBUTING.md | 2 + DECISIONS.md | 1 + 5 files changed, 252 insertions(+) create mode 100644 .github/scripts/readme-contributors.mjs create mode 100644 .github/scripts/readme-contributors.test.mjs create mode 100644 .github/workflows/readme-contributors.yml diff --git a/.github/scripts/readme-contributors.mjs b/.github/scripts/readme-contributors.mjs new file mode 100644 index 00000000..75993d80 --- /dev/null +++ b/.github/scripts/readme-contributors.mjs @@ -0,0 +1,62 @@ +// Keeps the contributors' avatars in README.md in step with GitHub's contributors list. +// .github/workflows/readme-contributors.yml runs the default branch's copy of this module. +import { readFileSync, writeFileSync } from "node:fs"; + +export const START = ""; +export const END = ""; + +/** Automation that GitHub lists as a user rather than a bot. */ +export const EXCLUDED = new Set(["semantic-release-bot"]); + +/** A second account of someone already listed, counted under their first. Keys are lowercase. */ +export const ALIASES = new Map([["alexandrebucci", "albucci"]]); + +const LOGIN = /^[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?$/; + +/** Logins to show, most contributions first; ties keep GitHub's order. */ +export function pickContributors(contributors) { + const people = new Map(); + for (const contributor of contributors ?? []) { + const login = contributor?.login; + if (contributor?.type !== "User" || typeof login !== "string" || !LOGIN.test(login)) continue; + const lower = login.toLowerCase(); + if (EXCLUDED.has(lower)) continue; + const key = ALIASES.get(lower) ?? lower; + const person = people.get(key) ?? { login: ALIASES.has(lower) ? ALIASES.get(lower) : login, contributions: 0 }; + if (lower === key) person.login = login; + person.contributions += Number(contributor.contributions) || 0; + people.set(key, person); + } + return [...people.values()].sort((a, b) => b.contributions - a.contributions).map((person) => person.login); +} + +export function renderAvatars(logins) { + const links = logins.map( + (login) => + `", ...links, "
"].join("\n"); +} + +/** The README with the avatars between the markers replaced. */ +export function replaceAvatars(readme, logins) { + const start = readme.indexOf(START); + const end = readme.indexOf(END); + if (start === -1 || end < start) throw new Error(`README.md needs ${START} and ${END} around the avatars.`); + // An empty list means GitHub's answer went wrong, not that everyone left. + if (logins.length === 0) throw new Error("GitHub listed no contributors; leaving README.md as it is."); + return `${readme.slice(0, start + START.length)}\n${renderAvatars(logins)}\n${readme.slice(end)}`; +} + +/** Rewrites README.md from GitHub's list and returns whether it changed. */ +export async function updateReadme({ github, context, core, path = "README.md" }) { + const { owner, repo } = context.repo; + const contributors = await github.paginate(github.rest.repos.listContributors, { owner, repo, per_page: 100 }); + const logins = pickContributors(contributors); + const before = readFileSync(path, "utf8"); + const after = replaceAvatars(before, logins); + const changed = after !== before; + if (changed) writeFileSync(path, after); + core.info(`${logins.length} contributors: ${logins.join(", ")}. README.md ${changed ? "updated" : "unchanged"}.`); + return changed; +} diff --git a/.github/scripts/readme-contributors.test.mjs b/.github/scripts/readme-contributors.test.mjs new file mode 100644 index 00000000..e3240dac --- /dev/null +++ b/.github/scripts/readme-contributors.test.mjs @@ -0,0 +1,81 @@ +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { mkdtempSync, readFileSync, writeFileSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +import { END, START, pickContributors, renderAvatars, replaceAvatars, updateReadme } from "./readme-contributors.mjs"; + +const user = (login, contributions) => ({ login, type: "User", contributions }); + +test("orders people by contributions and keeps GitHub's order for ties", () => { + const logins = pickContributors([user("a", 5), user("b", 1), user("c", 9), user("d", 1)]); + assert.deepEqual(logins, ["c", "a", "b", "d"]); +}); + +test("leaves out bots, release automation and malformed logins", () => { + const logins = pickContributors([ + user("M4n0x", 10), + { login: "dependabot[bot]", type: "Bot", contributions: 4 }, + user("semantic-release-bot", 20), + user('x">