Skip to content

Commit e4faf0e

Browse files
committed
ci: add preview changelog and contributors workflows
- Add preview-changelog workflow for manual changelog preview - Add nightly contributors workflow to update README - Include both code contributors and issue authors - Add contributors section to README with markers
1 parent ed04b58 commit e4faf0e

File tree

3 files changed

+96
-0
lines changed

3 files changed

+96
-0
lines changed

.github/workflows/contributors.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Update Contributors
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * *' # Run daily at midnight UTC
6+
workflow_dispatch: # Allow manual trigger
7+
8+
jobs:
9+
contributors:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
with:
14+
token: ${{ secrets.CONTRIBUTORS_TOKEN }}
15+
16+
- name: Update contributors
17+
env:
18+
GH_TOKEN: ${{ secrets.CONTRIBUTORS_TOKEN }}
19+
run: |
20+
# Fetch code contributors (exclude bots)
21+
code_contributors=$(gh api repos/${{ github.repository }}/contributors --paginate --jq '.[] | select(.type != "Bot") | select(.login | test("\\[bot\\]$") | not) | .login')
22+
23+
# Fetch authors of closed issues (issues closed via PR)
24+
issue_authors=$(gh api repos/${{ github.repository }}/issues --paginate -q '.[] | select(.state == "closed") | select(.pull_request == null) | .user.login' | sort -u)
25+
26+
# Combine and deduplicate
27+
all_contributors=$(echo -e "$code_contributors\n$issue_authors" | sort -u | grep -v '^$')
28+
29+
# Build markdown for each contributor
30+
contributor_md=""
31+
for login in $all_contributors; do
32+
# Skip bots
33+
if [[ "$login" == *"[bot]" ]]; then
34+
continue
35+
fi
36+
37+
# Get user info
38+
user_info=$(gh api users/$login --jq '{avatar_url, html_url}')
39+
avatar=$(echo "$user_info" | jq -r '.avatar_url')
40+
url=$(echo "$user_info" | jq -r '.html_url')
41+
42+
contributor_md="$contributor_md[![$login](${avatar}&s=64)]($url) "
43+
done
44+
45+
# Build the contributors section
46+
contrib_section="<!-- readme: contributors -start -->
47+
$contributor_md
48+
<!-- readme: contributors -end -->"
49+
50+
# Update README between the markers
51+
awk -v contrib="$contrib_section" '
52+
/<!-- readme: contributors -start -->/{found=1; print contrib; next}
53+
/<!-- readme: contributors -end -->/{found=0; next}
54+
!found{print}
55+
' README.md > README.tmp && mv README.tmp README.md
56+
57+
- name: Commit and push
58+
run: |
59+
git config user.name "github-actions[bot]"
60+
git config user.email "github-actions[bot]@users.noreply.github.com"
61+
git add README.md
62+
git diff --staged --quiet || (git commit -m "docs: update contributors [skip ci]" && git push)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Preview Changelog
2+
3+
run-name: Preview release notes for next release
4+
5+
on:
6+
workflow_dispatch:
7+
8+
jobs:
9+
generate:
10+
name: Generate
11+
uses: CodingWithCalvin/.github/.github/workflows/generate-changelog.yml@main
12+
secrets: inherit
13+
14+
preview:
15+
name: Display Preview
16+
runs-on: ubuntu-latest
17+
needs: generate
18+
19+
steps:
20+
- name: Display changelog preview
21+
run: |
22+
echo "=========================================="
23+
echo "CHANGELOG PREVIEW"
24+
echo "=========================================="
25+
echo ""
26+
echo "## What's New in v<VERSION>"
27+
echo ""
28+
echo "${{ needs.generate.outputs.changelog }}"
29+
shell: bash

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ Contributions are welcome! Feel free to:
132132
4. 📤 Push to the branch (`git push origin feature/amazing-feature`)
133133
5. 🎉 Open a Pull Request
134134

135+
## 👥 Contributors
136+
137+
<!-- readme: contributors -start -->
138+
<!-- readme: contributors -end -->
139+
135140
---
136141

137142
## 📄 License

0 commit comments

Comments
 (0)