summaryrefslogtreecommitdiffstats
path: root/docs/release_summary.py
blob: 39ec876ca6f071e749eea89294177c40e1fe6217 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import requests
import os

def get_merged_prs(repo, milestone, token):
    url = f'https://api.github.com/repos/{repo}/pulls'
    params = {
        'state': 'closed',
        'per_page': 100,  # Number of items per page, adjust as needed
    }
    headers = {'Authorization': f'token {token}'}

    all_prs = []
    page = 1

    while True:
        params['page'] = page
        response = requests.get(url, params=params, headers=headers)
        response.raise_for_status()

        prs = response.json()

        if not prs:
            break  # No more pages

        all_prs.extend([pr for pr in prs if pr['merged_at'] and (pr['milestone'] or {}).get('title', '') == milestone])
        page += 1

    return all_prs

def categorize_prs(prs):
    categorized_prs = {'addition': [], 'change': [], 'fix': []}

    for pr in prs:
        labels = [label['name'] for label in pr['labels']]
        if 'addition' in labels or 'feature' in labels:
            categorized_prs['addition'].append(pr)
        elif 'fix' in labels or 'bug' in labels:
            categorized_prs['fix'].append(pr)
        elif 'change' in labels or 'improvement' in labels:
            categorized_prs['change'].append(pr)

    return categorized_prs

def get_authors(prs):
    authors = set()
    for pr in prs:
        authors.add(pr['user']['login'])
    return sorted(authors, key=str.casefold)

def main():
    repo = 'iced-rs/iced'
    milestone = '0.12'
    token = os.environ['GITHUB_TOKEN']

    prs = get_merged_prs(repo, milestone, token)
    categorized_prs = categorize_prs(prs)

    for category, items in categorized_prs.items():
        print(f"### {category.capitalize()}")

        for pr in items:
            print(f"- {pr['title']}. [#{pr['number']}](https://github.com/{repo}/pull/{pr['number']})")

        print("")

    print("")

    authors = get_authors(prs)

    print("Many thanks to...")
    for author in authors:
        print(f"- @{author}")

if __name__ == "__main__":
    main()