Skip to content

Commit 1a4f728

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 1a4f728

4 files changed

Lines changed: 118 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,16 @@ name: CI
33
on:
44
push:
55
branches: [main]
6+
paths:
7+
- 'src/**'
8+
- '*.sln'
9+
- '.github/workflows/ci.yml'
610
pull_request:
711
branches: [main]
12+
paths:
13+
- 'src/**'
14+
- '*.sln'
15+
- '.github/workflows/ci.yml'
816

917
jobs:
1018
build:

.github/workflows/contributors.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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 closed issues and check if they were closed by a PR
24+
issue_authors=""
25+
closed_issues=$(gh api repos/${{ github.repository }}/issues --paginate -q '.[] | select(.state == "closed") | select(.pull_request == null) | {number, login: .user.login}')
26+
27+
for row in $(echo "$closed_issues" | jq -c '.'); do
28+
issue_num=$(echo "$row" | jq -r '.number')
29+
login=$(echo "$row" | jq -r '.login')
30+
31+
# Check timeline for closed event with commit (meaning closed by PR)
32+
closed_by_pr=$(gh api repos/${{ github.repository }}/issues/$issue_num/timeline --paginate -q '.[] | select(.event == "closed") | select(.commit_id != null) | .commit_id' | head -1)
33+
34+
if [[ -n "$closed_by_pr" ]]; then
35+
issue_authors="$issue_authors$login"$'\n'
36+
fi
37+
done
38+
issue_authors=$(echo "$issue_authors" | sort -u)
39+
40+
# Combine and deduplicate
41+
all_contributors=$(echo -e "$code_contributors\n$issue_authors" | sort -u | grep -v '^$')
42+
43+
# Build markdown for each contributor
44+
contributor_md=""
45+
for login in $all_contributors; do
46+
# Skip bots
47+
if [[ "$login" == *"[bot]" ]]; then
48+
continue
49+
fi
50+
51+
# Get user info
52+
user_info=$(gh api users/$login --jq '{avatar_url, html_url}')
53+
avatar=$(echo "$user_info" | jq -r '.avatar_url')
54+
url=$(echo "$user_info" | jq -r '.html_url')
55+
56+
contributor_md="$contributor_md[![$login](${avatar}&s=64)]($url) "
57+
done
58+
59+
# Build the contributors section
60+
contrib_section="<!-- readme: contributors -start -->
61+
$contributor_md
62+
<!-- readme: contributors -end -->"
63+
64+
# Update README between the markers
65+
awk -v contrib="$contrib_section" '
66+
/<!-- readme: contributors -start -->/{found=1; print contrib; next}
67+
/<!-- readme: contributors -end -->/{found=0; next}
68+
!found{print}
69+
' README.md > README.tmp && mv README.tmp README.md
70+
71+
- name: Commit and push
72+
run: |
73+
git config user.name "github-actions[bot]"
74+
git config user.email "github-actions[bot]@users.noreply.github.com"
75+
git add README.md
76+
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)