Verification Steps
Description
Feature request
Could stable release notes use GitHub usernames for contributor attribution, or avoid generating incorrect GitHub mentions?
At the moment, stable release notes appear to be generated by .github/genReleaseNote.sh with:
git log --pretty=format:"* %h %s by @%an"
%an is the git author name, not a GitHub username. Because of that, stable release notes may contain invalid or incorrect mentions.
For example, in v1.19.28:
* cbd11db chore: converter map hysteria2 port hopping and realm URI (#2947) by @peter Solomon
But PR #2947 was authored by @Medium1992.
Another example from the same release:
This seems to come from the author name as well, while it is not necessarily the correct GitHub login.
Prerelease notes seem to avoid this issue because Upload-Prerelease uses GitHub-generated release notes:
generate_release_notes: true
Why this matters
Incorrect @mentions may point to the wrong user, or to a non-existing account, and real contributors may not be mentioned correctly in the stable/latest release notes.
Possible improvement
Instead of using @%an, stable release note generation could resolve the GitHub login via GitHub API and fallback to the plain git author name only when no login is available.
For example:
- If the commit subject contains a PR number like
#2947, resolve the PR author:
gh api "repos/${GITHUB_REPOSITORY}/pulls/2947" --jq '.user.login // empty'
- Otherwise, resolve the GitHub-associated commit author:
gh api "repos/${GITHUB_REPOSITORY}/commits/${sha}" --jq '.author.login // empty'
- If no login is found, fallback to
%an without adding @.
A possible helper could look like this:
resolve_login() {
sha="$1"
subject="$2"
pr_number="$(printf '%s\n' "$subject" | sed -n 's/.*#\([0-9][0-9]*\).*/\1/p')"
if [ -n "$pr_number" ]; then
login="$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${pr_number}" --jq '.user.login // empty' 2>/dev/null || true)"
if [ -n "$login" ]; then
printf '%s\n' "$login"
return
fi
fi
gh api "repos/${GITHUB_REPOSITORY}/commits/${sha}" --jq '.author.login // empty' 2>/dev/null || true
}
append_changes() {
grep_expr="$1"
git log --format='%H' --grep="$grep_expr" -i "$version_range" |
while read -r sha; do
short_sha="$(git show -s --format='%h' "$sha")"
subject="$(git show -s --format='%s' "$sha")"
author_name="$(git show -s --format='%an' "$sha")"
login="$(resolve_login "$sha" "$subject")"
if [ -n "$login" ]; then
printf '* %s %s by @%s\n' "$short_sha" "$subject" "$login"
else
printf '* %s %s by %s\n' "$short_sha" "$subject" "$author_name"
fi
done | sort -f | uniq >> release.md
}
Then the current git log --pretty=format:"* %h %s by @%an" calls could be replaced with:
append_changes "^feat"
append_changes "^fix"
append_changes "^chore\|^docs\|^refactor"
If gh api is used during the workflow, the release note generation step may need GITHUB_TOKEN in the environment:
- name: Generate release notes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cp ./.github/genReleaseNote.sh ./
bash ./genReleaseNote.sh -v ${PREVERSION}...${CURRENTVERSION}
rm ./genReleaseNote.sh
A simpler alternative would be to use GitHub-generated release notes for stable releases too, similar to prereleases, if keeping the custom sections is not required.
Also, if possible, please consider manually correcting the current v1.19.28 release notes, because the current mentions attribute at least a couple of entries incorrectly.
Verification Steps
Description
Feature request
Could stable release notes use GitHub usernames for contributor attribution, or avoid generating incorrect GitHub mentions?
At the moment, stable release notes appear to be generated by
.github/genReleaseNote.shwith:git log --pretty=format:"* %h %s by @%an"%anis the git author name, not a GitHub username. Because of that, stable release notes may contain invalid or incorrect mentions.For example, in
v1.19.28:But PR
#2947was authored by@Medium1992.Another example from the same release:
by @aaron ChenThis seems to come from the author name as well, while it is not necessarily the correct GitHub login.
Prerelease notes seem to avoid this issue because
Upload-Prereleaseuses GitHub-generated release notes:Why this matters
Incorrect
@mentionsmay point to the wrong user, or to a non-existing account, and real contributors may not be mentioned correctly in the stable/latest release notes.Possible improvement
Instead of using
@%an, stable release note generation could resolve the GitHub login via GitHub API and fallback to the plain git author name only when no login is available.For example:
#2947, resolve the PR author:%anwithout adding@.A possible helper could look like this:
Then the current
git log --pretty=format:"* %h %s by @%an"calls could be replaced with:If
gh apiis used during the workflow, the release note generation step may needGITHUB_TOKENin the environment:A simpler alternative would be to use GitHub-generated release notes for stable releases too, similar to prereleases, if keeping the custom sections is not required.
Also, if possible, please consider manually correcting the current
v1.19.28release notes, because the current mentions attribute at least a couple of entries incorrectly.