From 7e5682ee7381abb91ccb281074980d4cdcaa9b0e Mon Sep 17 00:00:00 2001 From: Willie Date: Sun, 22 Feb 2026 15:09:47 +0800 Subject: [PATCH] ci: append contributors section to release notes Add post-GoReleaser step that queries GitHub Compare API for commit authors between tags, excludes bots and maintainer (runkids), and appends a ## Contributors section with @mentions to the release body. Uses RELEASE_TEMPLATE.md with envsubst (scoped to two variables) to keep the format editable outside the workflow YAML. --- .github/RELEASE_TEMPLATE.md | 5 +++++ .github/workflows/release.yaml | 31 +++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 .github/RELEASE_TEMPLATE.md diff --git a/.github/RELEASE_TEMPLATE.md b/.github/RELEASE_TEMPLATE.md new file mode 100644 index 000000000..b42587859 --- /dev/null +++ b/.github/RELEASE_TEMPLATE.md @@ -0,0 +1,5 @@ +${GORELEASER_BODY} + +## Contributors + +${CONTRIBUTORS} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index a947c7270..f4770d7c9 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -52,3 +52,34 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }} + + - name: Add contributors to release notes + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + TAG="${GITHUB_REF#refs/tags/}" + PREV_TAG=$(git tag --sort=-v:refname | grep -v "^${TAG}$" | head -1) + + if [ -z "$PREV_TAG" ]; then + echo "No previous tag found, skipping contributors" + exit 0 + fi + + # Get unique GitHub logins between tags (exclude bots and maintainer) + LOGINS=$(gh api "repos/${GITHUB_REPOSITORY}/compare/${PREV_TAG}...${TAG}" \ + --jq '[.commits[].author.login // empty] | unique | .[]' 2>/dev/null \ + | grep -v '\[bot\]$' \ + | grep -v '^runkids$' || true) + + if [ -z "$LOGINS" ]; then + echo "No external contributors found, skipping" + exit 0 + fi + + # Format as @mentions and render release notes from template + CONTRIBUTORS=$(echo "$LOGINS" | sed 's/^/@/' | paste -sd ', ' -) + GORELEASER_BODY=$(gh release view "$TAG" --json body -q .body) + export GORELEASER_BODY CONTRIBUTORS + envsubst '${GORELEASER_BODY} ${CONTRIBUTORS}' < .github/RELEASE_TEMPLATE.md > release-notes.md + gh release edit "$TAG" --notes-file release-notes.md + rm -f release-notes.md