autopub 1.0.0a33__py3-none-any.whl → 1.0.0a35__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 +75 -35
- {autopub-1.0.0a33.dist-info → autopub-1.0.0a35.dist-info}/METADATA +1 -1
- {autopub-1.0.0a33.dist-info → autopub-1.0.0a35.dist-info}/RECORD +7 -7
- {autopub-1.0.0a33.dist-info → autopub-1.0.0a35.dist-info}/LICENSE +0 -0
- {autopub-1.0.0a33.dist-info → autopub-1.0.0a35.dist-info}/WHEEL +0 -0
- {autopub-1.0.0a33.dist-info → autopub-1.0.0a35.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,64 @@ 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
|
+
)
|
49
|
+
|
50
|
+
comment_template_missing_release: str = textwrap.dedent("""
|
51
|
+
Hi, thanks for contributing to this project!
|
52
|
+
|
53
|
+
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!
|
54
|
+
|
55
|
+
So as soon as this PR is merged, a release will be made 🚀.
|
56
|
+
|
57
|
+
Here's an example of `RELEASE.md`:
|
58
|
+
|
59
|
+
```markdown
|
60
|
+
---
|
61
|
+
release type: patch
|
62
|
+
---
|
63
|
+
|
64
|
+
Description of the changes, ideally with some examples, if adding a new feature.
|
65
|
+
|
66
|
+
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 :)
|
67
|
+
```
|
68
|
+
""")
|
69
|
+
|
70
|
+
|
28
71
|
class GithubPlugin(AutopubPlugin):
|
29
|
-
|
72
|
+
id = "github"
|
73
|
+
Config = GithubConfig
|
74
|
+
|
30
75
|
def __init__(self) -> None:
|
31
76
|
super().__init__()
|
32
|
-
|
77
|
+
|
33
78
|
self.github_token = os.environ.get("GITHUB_TOKEN")
|
34
|
-
|
79
|
+
|
35
80
|
if not self.github_token:
|
36
81
|
raise AutopubException("GITHUB_TOKEN environment variable is required")
|
37
82
|
|
38
83
|
self.repository_name = os.environ.get("GITHUB_REPOSITORY")
|
39
|
-
|
40
|
-
|
84
|
+
self.discussion_category_name = os.environ.get(
|
85
|
+
"DISCUSSION_CATEGORY_NAME", "Announcements"
|
86
|
+
)
|
41
87
|
|
42
88
|
@cached_property
|
43
89
|
def _github(self) -> Github:
|
@@ -57,9 +103,9 @@ class GithubPlugin(AutopubPlugin):
|
|
57
103
|
return self._github.get_repo(self.repository_name)
|
58
104
|
|
59
105
|
@cached_property
|
60
|
-
def pull_request(self) -> Optional[PullRequest]:
|
106
|
+
def pull_request(self) -> Optional[PullRequest]:
|
61
107
|
pr_number = self._get_pr_number()
|
62
|
-
|
108
|
+
|
63
109
|
if pr_number is None:
|
64
110
|
return None
|
65
111
|
|
@@ -95,7 +141,9 @@ class GithubPlugin(AutopubPlugin):
|
|
95
141
|
self, text: str, marker: str = "<!-- autopub-comment -->"
|
96
142
|
) -> None:
|
97
143
|
"""Update or create a comment on the current PR with the given text."""
|
98
|
-
print(
|
144
|
+
print(
|
145
|
+
f"Updating or creating comment on PR {self.pull_request} in {self.repository}"
|
146
|
+
)
|
99
147
|
|
100
148
|
# Look for existing autopub comment
|
101
149
|
comment_body = f"{marker}\n{text}"
|
@@ -162,6 +210,7 @@ class GithubPlugin(AutopubPlugin):
|
|
162
210
|
"""
|
163
211
|
|
164
212
|
# TODO: there might be some permission issues in some cases
|
213
|
+
# TODO: this needs a PAT (check security implications)
|
165
214
|
if self.repository.organization:
|
166
215
|
_, response = self._github.requester.graphql_query(
|
167
216
|
query_organisation, {"organization": self.repository.organization.login}
|
@@ -190,7 +239,6 @@ class GithubPlugin(AutopubPlugin):
|
|
190
239
|
)
|
191
240
|
|
192
241
|
def _get_discussion_category_id(self) -> str:
|
193
|
-
|
194
242
|
query = """
|
195
243
|
query GetDiscussionCategoryId($owner: String!, $repositoryName: String!) {
|
196
244
|
repository(owner: $owner, name: $repositoryName) {
|
@@ -216,7 +264,9 @@ class GithubPlugin(AutopubPlugin):
|
|
216
264
|
if node["name"] == self.discussion_category_name:
|
217
265
|
return node["id"]
|
218
266
|
|
219
|
-
raise AutopubException(
|
267
|
+
raise AutopubException(
|
268
|
+
f"Discussion category {self.discussion_category_name} not found"
|
269
|
+
)
|
220
270
|
|
221
271
|
def _create_discussion(self, release_info: ReleaseInfo) -> None:
|
222
272
|
mutation = """
|
@@ -268,36 +318,21 @@ class GithubPlugin(AutopubPlugin):
|
|
268
318
|
|
269
319
|
return pr_contributors
|
270
320
|
|
271
|
-
def on_release_notes_valid(
|
272
|
-
self, release_info: ReleaseInfo
|
273
|
-
) -> None: # pragma: no cover
|
321
|
+
def on_release_notes_valid(self, release_info: ReleaseInfo) -> None:
|
274
322
|
assert self.pull_request is not None
|
275
323
|
|
276
|
-
|
277
|
-
sponsors = self._get_sponsors()
|
278
|
-
discussion_category_id = self._get_discussion_category_id()
|
324
|
+
changelog = self._get_release_message(release_info)
|
279
325
|
|
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
|
-
"""
|
326
|
+
message = self.configuration.comment_template_success.format(
|
327
|
+
changelog=changelog
|
292
328
|
)
|
293
329
|
|
294
330
|
self._update_or_create_comment(message)
|
295
331
|
|
296
|
-
def on_release_notes_invalid(
|
297
|
-
self
|
298
|
-
|
299
|
-
|
300
|
-
self._update_or_create_comment(str(exception))
|
332
|
+
def on_release_notes_invalid(self, exception: AutopubException) -> None:
|
333
|
+
message = self.configuration.comment_template_error.format(error=str(exception))
|
334
|
+
|
335
|
+
self._update_or_create_comment(message)
|
301
336
|
|
302
337
|
def _get_release_message(self, release_info: ReleaseInfo) -> str:
|
303
338
|
assert self.pull_request is not None
|
@@ -316,8 +351,13 @@ class GithubPlugin(AutopubPlugin):
|
|
316
351
|
)
|
317
352
|
|
318
353
|
if contributors["additional_contributors"]:
|
319
|
-
additional_contributors = [
|
320
|
-
|
354
|
+
additional_contributors = [
|
355
|
+
f"@{contributor}"
|
356
|
+
for contributor in contributors["additional_contributors"]
|
357
|
+
]
|
358
|
+
message += (
|
359
|
+
f"\n\nAdditional contributors: {', '.join(additional_contributors)}"
|
360
|
+
)
|
321
361
|
|
322
362
|
if contributors["reviewers"]:
|
323
363
|
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=x4gmlQLW4xCYHVYy2FT8_2rE8tjNVzd-x786sAqMG_M,12818
|
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.0a35.dist-info/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
|
16
|
+
autopub-1.0.0a35.dist-info/METADATA,sha256=YKyGyeZKk2rc--uOj6IYXtRV1KR-1ugIgqivgaoiUHg,992
|
17
|
+
autopub-1.0.0a35.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
18
|
+
autopub-1.0.0a35.dist-info/entry_points.txt,sha256=oeTav5NgCxif6mcZ_HeVGgGv5LzS4DwdI01nr4bO1IM,43
|
19
|
+
autopub-1.0.0a35.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|