autopub 1.0.0a33__py3-none-any.whl → 1.0.0a34__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- autopub/plugin_loader.py +1 -2
- autopub/plugins/github.py +76 -35
- {autopub-1.0.0a33.dist-info → autopub-1.0.0a34.dist-info}/METADATA +1 -1
- {autopub-1.0.0a33.dist-info → autopub-1.0.0a34.dist-info}/RECORD +7 -7
- {autopub-1.0.0a33.dist-info → autopub-1.0.0a34.dist-info}/LICENSE +0 -0
- {autopub-1.0.0a33.dist-info → autopub-1.0.0a34.dist-info}/WHEEL +0 -0
- {autopub-1.0.0a33.dist-info → autopub-1.0.0a34.dist-info}/entry_points.txt +0 -0
autopub/plugin_loader.py
CHANGED
autopub/plugins/github.py
CHANGED
@@ -8,6 +8,7 @@ from typing import Optional, TypedDict
|
|
8
8
|
from github import Github
|
9
9
|
from github.PullRequest import PullRequest
|
10
10
|
from github.Repository import Repository
|
11
|
+
from pydantic import BaseModel
|
11
12
|
|
12
13
|
from autopub.exceptions import AutopubException
|
13
14
|
from autopub.plugins import AutopubPlugin
|
@@ -25,19 +26,65 @@ class Sponsors(TypedDict):
|
|
25
26
|
private_sponsors: int
|
26
27
|
|
27
28
|
|
29
|
+
class GithubConfig(BaseModel):
|
30
|
+
comment_template_success: str = textwrap.dedent(
|
31
|
+
"""
|
32
|
+
Thanks for adding the `RELEASE.md` file!
|
33
|
+
|
34
|
+
Here's a preview of the changelog:
|
35
|
+
|
36
|
+
{changelog}
|
37
|
+
""",
|
38
|
+
)
|
39
|
+
|
40
|
+
comment_template_error: str = textwrap.dedent(
|
41
|
+
"""
|
42
|
+
Something went wrong while checking the release file.
|
43
|
+
|
44
|
+
Here's the error:
|
45
|
+
|
46
|
+
{error}
|
47
|
+
""",
|
48
|
+
description="Template for release note validation errors",
|
49
|
+
)
|
50
|
+
|
51
|
+
comment_template_missing_release: str = textwrap.dedent("""
|
52
|
+
Hi, thanks for contributing to this project!
|
53
|
+
|
54
|
+
We noticed that this PR is missing a `RELEASE.md` file. We use that to automatically do releases here on GitHub and, most importantly, to PyPI!
|
55
|
+
|
56
|
+
So as soon as this PR is merged, a release will be made 🚀.
|
57
|
+
|
58
|
+
Here's an example of `RELEASE.md`:
|
59
|
+
|
60
|
+
```markdown
|
61
|
+
---
|
62
|
+
release type: patch
|
63
|
+
---
|
64
|
+
|
65
|
+
Description of the changes, ideally with some examples, if adding a new feature.
|
66
|
+
|
67
|
+
Release type can be one of patch, minor or major. We use [semver](https://semver.org/), so make sure to pick the appropriate type. If in doubt feel free to ask :)
|
68
|
+
```
|
69
|
+
""")
|
70
|
+
|
71
|
+
|
28
72
|
class GithubPlugin(AutopubPlugin):
|
29
|
-
|
73
|
+
id = "github"
|
74
|
+
Config = GithubConfig
|
75
|
+
|
30
76
|
def __init__(self) -> None:
|
31
77
|
super().__init__()
|
32
|
-
|
78
|
+
|
33
79
|
self.github_token = os.environ.get("GITHUB_TOKEN")
|
34
|
-
|
80
|
+
|
35
81
|
if not self.github_token:
|
36
82
|
raise AutopubException("GITHUB_TOKEN environment variable is required")
|
37
83
|
|
38
84
|
self.repository_name = os.environ.get("GITHUB_REPOSITORY")
|
39
|
-
|
40
|
-
|
85
|
+
self.discussion_category_name = os.environ.get(
|
86
|
+
"DISCUSSION_CATEGORY_NAME", "Announcements"
|
87
|
+
)
|
41
88
|
|
42
89
|
@cached_property
|
43
90
|
def _github(self) -> Github:
|
@@ -57,9 +104,9 @@ class GithubPlugin(AutopubPlugin):
|
|
57
104
|
return self._github.get_repo(self.repository_name)
|
58
105
|
|
59
106
|
@cached_property
|
60
|
-
def pull_request(self) -> Optional[PullRequest]:
|
107
|
+
def pull_request(self) -> Optional[PullRequest]:
|
61
108
|
pr_number = self._get_pr_number()
|
62
|
-
|
109
|
+
|
63
110
|
if pr_number is None:
|
64
111
|
return None
|
65
112
|
|
@@ -95,7 +142,9 @@ class GithubPlugin(AutopubPlugin):
|
|
95
142
|
self, text: str, marker: str = "<!-- autopub-comment -->"
|
96
143
|
) -> None:
|
97
144
|
"""Update or create a comment on the current PR with the given text."""
|
98
|
-
print(
|
145
|
+
print(
|
146
|
+
f"Updating or creating comment on PR {self.pull_request} in {self.repository}"
|
147
|
+
)
|
99
148
|
|
100
149
|
# Look for existing autopub comment
|
101
150
|
comment_body = f"{marker}\n{text}"
|
@@ -162,6 +211,7 @@ class GithubPlugin(AutopubPlugin):
|
|
162
211
|
"""
|
163
212
|
|
164
213
|
# TODO: there might be some permission issues in some cases
|
214
|
+
# TODO: this needs a PAT (check security implications)
|
165
215
|
if self.repository.organization:
|
166
216
|
_, response = self._github.requester.graphql_query(
|
167
217
|
query_organisation, {"organization": self.repository.organization.login}
|
@@ -190,7 +240,6 @@ class GithubPlugin(AutopubPlugin):
|
|
190
240
|
)
|
191
241
|
|
192
242
|
def _get_discussion_category_id(self) -> str:
|
193
|
-
|
194
243
|
query = """
|
195
244
|
query GetDiscussionCategoryId($owner: String!, $repositoryName: String!) {
|
196
245
|
repository(owner: $owner, name: $repositoryName) {
|
@@ -216,7 +265,9 @@ class GithubPlugin(AutopubPlugin):
|
|
216
265
|
if node["name"] == self.discussion_category_name:
|
217
266
|
return node["id"]
|
218
267
|
|
219
|
-
raise AutopubException(
|
268
|
+
raise AutopubException(
|
269
|
+
f"Discussion category {self.discussion_category_name} not found"
|
270
|
+
)
|
220
271
|
|
221
272
|
def _create_discussion(self, release_info: ReleaseInfo) -> None:
|
222
273
|
mutation = """
|
@@ -268,36 +319,21 @@ class GithubPlugin(AutopubPlugin):
|
|
268
319
|
|
269
320
|
return pr_contributors
|
270
321
|
|
271
|
-
def on_release_notes_valid(
|
272
|
-
self, release_info: ReleaseInfo
|
273
|
-
) -> None: # pragma: no cover
|
322
|
+
def on_release_notes_valid(self, release_info: ReleaseInfo) -> None:
|
274
323
|
assert self.pull_request is not None
|
275
324
|
|
276
|
-
|
277
|
-
sponsors = self._get_sponsors()
|
278
|
-
discussion_category_id = self._get_discussion_category_id()
|
325
|
+
changelog = self._get_release_message(release_info)
|
279
326
|
|
280
|
-
message =
|
281
|
-
|
282
|
-
## {release_info.version}
|
283
|
-
|
284
|
-
{release_info.release_notes}
|
285
|
-
|
286
|
-
This release was contributed by {contributors} in #{self.pull_request.number}
|
287
|
-
|
288
|
-
Sponsors: {sponsors}
|
289
|
-
|
290
|
-
Discussion: {discussion_category_id}
|
291
|
-
"""
|
327
|
+
message = self.configuration.comment_template_success.format(
|
328
|
+
changelog=changelog
|
292
329
|
)
|
293
330
|
|
294
331
|
self._update_or_create_comment(message)
|
295
332
|
|
296
|
-
def on_release_notes_invalid(
|
297
|
-
self
|
298
|
-
|
299
|
-
|
300
|
-
self._update_or_create_comment(str(exception))
|
333
|
+
def on_release_notes_invalid(self, exception: AutopubException) -> None:
|
334
|
+
message = self.configuration.comment_template_error.format(error=str(exception))
|
335
|
+
|
336
|
+
self._update_or_create_comment(message)
|
301
337
|
|
302
338
|
def _get_release_message(self, release_info: ReleaseInfo) -> str:
|
303
339
|
assert self.pull_request is not None
|
@@ -316,8 +352,13 @@ class GithubPlugin(AutopubPlugin):
|
|
316
352
|
)
|
317
353
|
|
318
354
|
if contributors["additional_contributors"]:
|
319
|
-
additional_contributors = [
|
320
|
-
|
355
|
+
additional_contributors = [
|
356
|
+
f"@{contributor}"
|
357
|
+
for contributor in contributors["additional_contributors"]
|
358
|
+
]
|
359
|
+
message += (
|
360
|
+
f"\n\nAdditional contributors: {', '.join(additional_contributors)}"
|
361
|
+
)
|
321
362
|
|
322
363
|
if contributors["reviewers"]:
|
323
364
|
reviewers = [f"@{reviewer}" for reviewer in contributors["reviewers"]]
|
@@ -1,19 +1,19 @@
|
|
1
1
|
autopub/__init__.py,sha256=mJ7Ai6ygc43IuiaKbVBcLGj8oHMuZmJ3Bxq3rPgKmf8,7130
|
2
2
|
autopub/cli/__init__.py,sha256=77rx1yYi8adLUZAW7Rs48CNVyYe4HgSMZ7pZyIxD1iQ,3894
|
3
3
|
autopub/exceptions.py,sha256=gNUbiG3_fVmNjhk2kyueQHPSifNgQf0Bl6IDNvkVhxQ,1534
|
4
|
-
autopub/plugin_loader.py,sha256=
|
4
|
+
autopub/plugin_loader.py,sha256=2ysITgpHGUmcb1mP1Qvs-iBX2wZxmfP9obnebThwUMA,1809
|
5
5
|
autopub/plugins/__init__.py,sha256=57ewn1lhZYKKuVL49l3cgqAN9LQfCRzdsgSZimIAkls,2030
|
6
6
|
autopub/plugins/bump_version.py,sha256=-tTGQR0v8K3Bto1Y8UcmkEs4WnExeF1QyHKHPUKgll8,1565
|
7
7
|
autopub/plugins/git.py,sha256=d0SMLc6hwuk0eymj8aHyu3_cEd-7x4fhkwu35wPPV4k,1054
|
8
|
-
autopub/plugins/github.py,sha256=
|
8
|
+
autopub/plugins/github.py,sha256=LKO6bS7gw3BqJOEj3qryKd5AFCZDzJ32018f7CGuVys,12873
|
9
9
|
autopub/plugins/pdm.py,sha256=Pczye06fKg8_HMJDkEfMXQyvao9rZ7sqzTHFd6lLEpU,532
|
10
10
|
autopub/plugins/poetry.py,sha256=d2LvW9RI7ZB3reBOXbcp1mqWmzQ06Uyg_T-MxTvlSBg,517
|
11
11
|
autopub/plugins/update_changelog.py,sha256=g_6flOP5wocZbjOaYSayWxobL3ld8f0wT78nFtAIkFc,1586
|
12
12
|
autopub/plugins/uv.py,sha256=goo8QxaD3FVJ1c3xOSmN1hikZTCUXN8jWNac1S5uDDY,1089
|
13
13
|
autopub/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
14
14
|
autopub/types.py,sha256=gY1WR93XZVFS7vf5JMSmL_h5z7zO51-rtmZ6MYsh3so,1043
|
15
|
-
autopub-1.0.
|
16
|
-
autopub-1.0.
|
17
|
-
autopub-1.0.
|
18
|
-
autopub-1.0.
|
19
|
-
autopub-1.0.
|
15
|
+
autopub-1.0.0a34.dist-info/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
|
16
|
+
autopub-1.0.0a34.dist-info/METADATA,sha256=gdk2lNOdyVIs-i7jTckdrmgg85TVYR291pQrbSXiVLc,992
|
17
|
+
autopub-1.0.0a34.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
18
|
+
autopub-1.0.0a34.dist-info/entry_points.txt,sha256=oeTav5NgCxif6mcZ_HeVGgGv5LzS4DwdI01nr4bO1IM,43
|
19
|
+
autopub-1.0.0a34.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|