Skip to content

Commit

Permalink
ci: automate CONTRIBUTORS.md
Browse files Browse the repository at this point in the history
  • Loading branch information
tombh committed Jul 7, 2023
1 parent 60dc316 commit c3ee4f8
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 25 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Release Pygls to PyPI

on:
release:
types: [published]

jobs:
relase:
name: "🚀 Release 🚢"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Use Python "3.10"
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Generate the latest changelog
uses: orhun/git-cliff-action@v2
id: git-cliff
with:
args: --verbose --latest
- name: Update the changelog
run: |
cat "${{ steps.git-cliff.outputs.contents }} | "sed -i "3r /dev/stdin" CHANGELOG.md
git config --global user.name 'Github Action'
git config --global user.email 'github.action@users.noreply.github.com'
git commit -am "chore: update changelog"
git push
- name: Update CONTRIBUTORS.md
run: |
poetry run poe generate_contributors_md
if [[ $(git diff --stat CONTRIBUTORS.md) != '' ]]; then
git commit -am "chore: update CONTRIBUTORS.md"
git push
fi
- name: Release
run: |
poetry build
poetry publish --username "__token__" --password ${{ secrets.PYPI_API_TOKEN }}
54 changes: 31 additions & 23 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
# Contributors (alphabetical)

- [@augb](https://github.com/augb)
- [Alex Carney](https://github.com/alcarney)
- [Brett Cannon](https://github.com/brettcannon/)
- [Daniel Elero](https://github.com/danixeee)
- [Daniel Miller](https://github.com/millerdev)
- [DeathAxe](https://github.com/deathaxe)
- [Denis Loginov](https://github.com/dinvlad)
- [Dillan Mills](https://github.com/DillanCMills)
- [Felicián Németh](https://github.com/nemethf)
- [Felix Yan](https://github.com/felixonmars)
- [Jelle van der Waa](https://github.com/jelly)
- [Jérome Perrin](https://github.com/perrinjerome)
- [Karthik Nadig](https://github.com/karthiknadig)
- [Laurence Warne](https://github.com/LaurenceWarne)
- [Matej Kašťák](https://github.com/MatejKastak)
- [Max O'Cull](https://github.com/Maxattax97)
- [Samuel Roeca](https://github.com/pappasam)
- [Tom BH](https://github.com/tombh)
- [Tomoya Tanjo](https://github.com/tom-tan)
- [bollwyvl](https://github.com/bollwyvl)
- [yorodm](https://github.com/yorodm)
# Contributors (contributions)
* [alcarney](https://github.com/alcarney) (57)
* [anu-ka](https://github.com/anu-ka) (1)
* [augb](https://github.com/augb) (35)
* [berquist](https://github.com/berquist) (1)
* [brettcannon](https://github.com/brettcannon) (2)
* [D4N](https://github.com/D4N) (1)
* [danixeee](https://github.com/danixeee) (321)
* [deathaxe](https://github.com/deathaxe) (24)
* [dependabot[bot]](https://github.com/apps/dependabot) (5)
* [dgreisen](https://github.com/dgreisen) (4)
* [DillanCMills](https://github.com/DillanCMills) (1)
* [dimbleby](https://github.com/dimbleby) (9)
* [dinvlad](https://github.com/dinvlad) (9)
* [eirikpre](https://github.com/eirikpre) (1)
* [felixonmars](https://github.com/felixonmars) (1)
* [HankBO](https://github.com/HankBO) (1)
* [jelly](https://github.com/jelly) (1)
* [karthiknadig](https://github.com/karthiknadig) (1)
* [KOLANICH](https://github.com/KOLANICH) (3)
* [LaurenceWarne](https://github.com/LaurenceWarne) (2)
* [MatejKastak](https://github.com/MatejKastak) (3)
* [muffinmad](https://github.com/muffinmad) (2)
* [nemethf](https://github.com/nemethf) (1)
* [otreblan](https://github.com/otreblan) (1)
* [pappasam](https://github.com/pappasam) (7)
* [perimosocordiae](https://github.com/perimosocordiae) (1)
* [perrinjerome](https://github.com/perrinjerome) (24)
* [renatav](https://github.com/renatav) (2)
* [tombh](https://github.com/tombh) (29)
* [tsugumi-sys](https://github.com/tsugumi-sys) (1)
2 changes: 0 additions & 2 deletions PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,5 @@ _Please replace this description with a concise description of this Pull Request
- [ ] Tests have been included and/or updated, as appropriate
- [ ] Docstrings have been included and/or updated, as appropriate
- [ ] Standalone docs have been updated accordingly
- [ ] [CONTRIBUTORS.md][contributors] was updated, as appropriate

[commit messages]: https://chris.beams.io/posts/git-commit/
[contributors]: https://github.com/openlawlibrary/pygls/blob/master/CONTRIBUTORS.md
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ lint = [
"check_commit_style"
]
generate_client = "python scripts/generate_client.py --output pygls/lsp/client.py"
generate_contributors_md = "python scripts/generate_contributors_md.py"

[tool.ruff]
line-length = 120
Expand Down
46 changes: 46 additions & 0 deletions scripts/generate_contributors_md.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"""
Example JSON object:
{
"login": "danixeee",
"id": 16227576,
"node_id": "MDQ6VXNlcjE2MjI3NTc2",
"avatar_url": "https://avatars.githubusercontent.com/u/16227576?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/danixeee",
"html_url": "https://github.com/danixeee",
"followers_url": "https://api.github.com/users/danixeee/followers",
"following_url": "https://api.github.com/users/danixeee/following{/other_user}",
"gists_url": "https://api.github.com/users/danixeee/gists{/gist_id}",
"starred_url": "https://api.github.com/users/danixeee/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/danixeee/subscriptions",
"organizations_url": "https://api.github.com/users/danixeee/orgs",
"repos_url": "https://api.github.com/users/danixeee/repos",
"events_url": "https://api.github.com/users/danixeee/events{/privacy}",
"received_events_url": "https://api.github.com/users/danixeee/received_events",
"type": "User",
"site_admin": false,
"contributions": 321
}
"""

import requests

PYGLS_CONTRIBUTORS_JSON_URL = "https://api.github.com/repos/openlawlibrary/pygls/contributors"
CONTRIBUTORS_FILE = "CONTRIBUTORS.md"

response = requests.get(PYGLS_CONTRIBUTORS_JSON_URL)
contributors = sorted(response.json(), key=lambda d: d["login"].lower())

contents = "# Contributors (contributions)\n"

for contributor in contributors:
name = contributor["login"]
contributions = contributor["contributions"]
url = contributor["html_url"]
contents += f'* [{name}]({url}) ({contributions})\n'

file = open(CONTRIBUTORS_FILE, "w")
n = file.write(contents)
file.close()

print("✅ CONTRIBUTORS.md updated")

0 comments on commit c3ee4f8

Please sign in to comment.