ci(contributors): use the login name of GitHub

This commit is contained in:
dragonish 2026-02-19 21:21:43 +08:00
parent 7edb5a78ad
commit b678ded311
No known key found for this signature in database
GPG key ID: 6F42FA9E807A5177

View file

@ -3,7 +3,7 @@ name: Release
on: on:
push: push:
tags: tags:
- '*' - "*"
jobs: jobs:
build: build:
@ -22,7 +22,7 @@ jobs:
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: 22 node-version: 22
cache: 'pnpm' cache: "pnpm"
- name: Build package - name: Build package
run: | run: |
pnpm install pnpm install
@ -42,11 +42,21 @@ jobs:
id: contributors id: contributors
run: | run: |
previous_tag=$(git describe --abbrev=0 --tags HEAD^ 2>/dev/null || echo "") previous_tag=$(git describe --abbrev=0 --tags HEAD^ 2>/dev/null || echo "")
if [ -z "$previous_tag" ]; then if [ -z "$previous_tag" ]; then
contributors=$(git log --format='%an' HEAD | sort | uniq -c | sort -rn | head -10 | awk '{print "- @" $2}') commits=$(git log --format='%H' HEAD)
else else
contributors=$(git log ${previous_tag}..HEAD --format='%an' | sort | uniq -c | sort -rn | head -10 | awk '{print "- @" $2}') commits=$(git log ${previous_tag}..HEAD --format='%H')
fi fi
for sha in $commits; do
author=$(gh api repos/${{ github.repository }}/commits/$sha --jq '.author.login' 2>/dev/null)
if [ -n "$author" ]; then
echo "$author"
fi
done | sort | uniq -c | sort -rn | head -10 | awk '{print "- @" $2}' > contributors.txt
contributors=$(cat contributors.txt)
echo "contributors<<EOF" >> $GITHUB_OUTPUT echo "contributors<<EOF" >> $GITHUB_OUTPUT
echo "$contributors" >> $GITHUB_OUTPUT echo "$contributors" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT