autopub 1.0.0a37__py3-none-any.whl → 1.0.0a39__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/__init__.py +8 -4
- autopub/plugins/__init__.py +3 -0
- autopub/plugins/github.py +42 -16
- {autopub-1.0.0a37.dist-info → autopub-1.0.0a39.dist-info}/METADATA +1 -1
- {autopub-1.0.0a37.dist-info → autopub-1.0.0a39.dist-info}/RECORD +8 -8
- {autopub-1.0.0a37.dist-info → autopub-1.0.0a39.dist-info}/LICENSE +0 -0
- {autopub-1.0.0a37.dist-info → autopub-1.0.0a39.dist-info}/WHEEL +0 -0
- {autopub-1.0.0a37.dist-info → autopub-1.0.0a39.dist-info}/entry_points.txt +0 -0
autopub/__init__.py
CHANGED
@@ -2,9 +2,10 @@ from __future__ import annotations
|
|
2
2
|
|
3
3
|
import hashlib
|
4
4
|
import json
|
5
|
+
from collections.abc import Mapping
|
5
6
|
from functools import cached_property
|
6
7
|
from pathlib import Path
|
7
|
-
from typing import
|
8
|
+
from typing import TypeAlias
|
8
9
|
|
9
10
|
import frontmatter
|
10
11
|
import tomlkit
|
@@ -101,6 +102,9 @@ class Autopub:
|
|
101
102
|
release_file = Path(self.RELEASE_FILE_PATH)
|
102
103
|
|
103
104
|
if not release_file.exists():
|
105
|
+
for plugin in self.plugins:
|
106
|
+
plugin.on_release_file_not_found()
|
107
|
+
|
104
108
|
raise ReleaseFileNotFound()
|
105
109
|
|
106
110
|
try:
|
@@ -110,11 +114,11 @@ class Autopub:
|
|
110
114
|
plugin.on_release_notes_invalid(e)
|
111
115
|
raise
|
112
116
|
|
113
|
-
for plugin in self.plugins:
|
114
|
-
plugin.on_release_notes_valid(release_info)
|
115
|
-
|
116
117
|
for plugin in self.plugins:
|
117
118
|
plugin.post_check(release_info)
|
119
|
+
|
120
|
+
for plugin in self.plugins:
|
121
|
+
plugin.on_release_notes_valid(release_info)
|
118
122
|
|
119
123
|
self._write_artifact(release_info)
|
120
124
|
|
autopub/plugins/__init__.py
CHANGED
autopub/plugins/github.py
CHANGED
@@ -67,6 +67,10 @@ class GithubConfig(BaseModel):
|
|
67
67
|
```
|
68
68
|
""")
|
69
69
|
|
70
|
+
include_sponsors: bool = True
|
71
|
+
create_discussions: bool = True
|
72
|
+
discussion_category: str = "Announcements"
|
73
|
+
|
70
74
|
|
71
75
|
class GithubPlugin(AutopubPlugin):
|
72
76
|
id = "github"
|
@@ -82,7 +86,7 @@ class GithubPlugin(AutopubPlugin):
|
|
82
86
|
|
83
87
|
self.repository_name = os.environ.get("GITHUB_REPOSITORY")
|
84
88
|
self.discussion_category_name = os.environ.get(
|
85
|
-
"DISCUSSION_CATEGORY_NAME",
|
89
|
+
"DISCUSSION_CATEGORY_NAME", self.configuration.discussion_category
|
86
90
|
)
|
87
91
|
|
88
92
|
@cached_property
|
@@ -268,18 +272,19 @@ class GithubPlugin(AutopubPlugin):
|
|
268
272
|
f"Discussion category {self.discussion_category_name} not found"
|
269
273
|
)
|
270
274
|
|
271
|
-
def _create_discussion(self, release_info: ReleaseInfo) ->
|
275
|
+
def _create_discussion(self, release_info: ReleaseInfo) -> str:
|
272
276
|
mutation = """
|
273
277
|
mutation CreateDiscussion($repositoryId: ID!, $categoryId: ID!, $body: String!, $title: String!) {
|
274
278
|
createDiscussion(input: {repositoryId: $repositoryId, categoryId: $categoryId, body: $body, title: $title}) {
|
275
279
|
discussion {
|
276
280
|
id
|
281
|
+
url
|
277
282
|
}
|
278
283
|
}
|
279
284
|
}
|
280
285
|
"""
|
281
286
|
|
282
|
-
self._github.requester.graphql_query(
|
287
|
+
_, response = self._github.requester.graphql_query(
|
283
288
|
mutation,
|
284
289
|
{
|
285
290
|
# TODO: repo.node_id is not yet been published to pypi
|
@@ -290,6 +295,8 @@ class GithubPlugin(AutopubPlugin):
|
|
290
295
|
},
|
291
296
|
)
|
292
297
|
|
298
|
+
return response["data"]["createDiscussion"]["discussion"]["url"]
|
299
|
+
|
293
300
|
def _get_pr_contributors(self) -> PRContributors:
|
294
301
|
pr: PullRequest = self.pull_request
|
295
302
|
|
@@ -329,19 +336,25 @@ class GithubPlugin(AutopubPlugin):
|
|
329
336
|
|
330
337
|
self._update_or_create_comment(message)
|
331
338
|
|
339
|
+
def on_release_file_not_found(self) -> None:
|
340
|
+
message = self.configuration.comment_template_missing_release
|
341
|
+
|
342
|
+
self._update_or_create_comment(message)
|
343
|
+
|
332
344
|
def on_release_notes_invalid(self, exception: AutopubException) -> None:
|
333
345
|
message = self.configuration.comment_template_error.format(error=str(exception))
|
334
346
|
|
335
347
|
self._update_or_create_comment(message)
|
336
348
|
|
337
349
|
def _get_release_message(
|
338
|
-
self,
|
350
|
+
self,
|
351
|
+
release_info: ReleaseInfo,
|
352
|
+
include_release_info: bool = False,
|
353
|
+
discussion_url: Optional[str] = None,
|
339
354
|
) -> str:
|
340
355
|
assert self.pull_request is not None
|
341
356
|
|
342
357
|
contributors = self._get_pr_contributors()
|
343
|
-
sponsors = self._get_sponsors()
|
344
|
-
|
345
358
|
message = textwrap.dedent(
|
346
359
|
f"""
|
347
360
|
## {release_info.version}
|
@@ -368,19 +381,28 @@ class GithubPlugin(AutopubPlugin):
|
|
368
381
|
reviewers = [f"@{reviewer}" for reviewer in contributors["reviewers"]]
|
369
382
|
message += f"\n\nReviewers: {', '.join(reviewers)}"
|
370
383
|
|
371
|
-
if
|
372
|
-
|
373
|
-
|
384
|
+
if self.configuration.include_sponsors:
|
385
|
+
sponsors = self._get_sponsors()
|
386
|
+
if sponsors["sponsors"]:
|
387
|
+
public_sponsors = [f"@{sponsor}" for sponsor in sponsors["sponsors"]]
|
388
|
+
message += f"\n\nThanks to {', '.join(public_sponsors)}"
|
389
|
+
|
390
|
+
if sponsors["private_sponsors"]:
|
391
|
+
message += (
|
392
|
+
f" and the {sponsors['private_sponsors']} private sponsor(s)"
|
393
|
+
)
|
374
394
|
|
375
|
-
|
376
|
-
message += f" and the {sponsors['private_sponsors']} private sponsor(s)"
|
395
|
+
message += " for making this release possible ✨"
|
377
396
|
|
378
|
-
|
397
|
+
if discussion_url:
|
398
|
+
message += f"\n\nJoin the discussion: {discussion_url}"
|
379
399
|
|
380
400
|
return message
|
381
401
|
|
382
|
-
def _create_release(
|
383
|
-
|
402
|
+
def _create_release(
|
403
|
+
self, release_info: ReleaseInfo, discussion_url: Optional[str] = None
|
404
|
+
) -> None:
|
405
|
+
message = self._get_release_message(release_info, discussion_url=discussion_url)
|
384
406
|
|
385
407
|
release = self.repository.create_git_release(
|
386
408
|
tag=release_info.version,
|
@@ -400,5 +422,9 @@ class GithubPlugin(AutopubPlugin):
|
|
400
422
|
text, marker="<!-- autopub-comment-published -->"
|
401
423
|
)
|
402
424
|
|
403
|
-
|
404
|
-
|
425
|
+
discussion_url = None
|
426
|
+
|
427
|
+
if self.configuration.create_discussions:
|
428
|
+
discussion_url = self._create_discussion(release_info)
|
429
|
+
|
430
|
+
self._create_release(release_info, discussion_url)
|
@@ -1,19 +1,19 @@
|
|
1
|
-
autopub/__init__.py,sha256=
|
1
|
+
autopub/__init__.py,sha256=JOFsdJMarqnRydwUibnWL8JlmijG66I340q4zdcRENs,7263
|
2
2
|
autopub/cli/__init__.py,sha256=77rx1yYi8adLUZAW7Rs48CNVyYe4HgSMZ7pZyIxD1iQ,3894
|
3
3
|
autopub/exceptions.py,sha256=gNUbiG3_fVmNjhk2kyueQHPSifNgQf0Bl6IDNvkVhxQ,1534
|
4
4
|
autopub/plugin_loader.py,sha256=2ysITgpHGUmcb1mP1Qvs-iBX2wZxmfP9obnebThwUMA,1809
|
5
|
-
autopub/plugins/__init__.py,sha256=
|
5
|
+
autopub/plugins/__init__.py,sha256=h0VkuF4SgcISLv45KG_v8DeovDbjAjS_gt3EZPU-HMo,2112
|
6
6
|
autopub/plugins/bump_version.py,sha256=yOXhKHAGFb1DcmeBdh5RfwkOpEYeTqMlE69HgIyUB58,1628
|
7
7
|
autopub/plugins/git.py,sha256=d0SMLc6hwuk0eymj8aHyu3_cEd-7x4fhkwu35wPPV4k,1054
|
8
|
-
autopub/plugins/github.py,sha256=
|
8
|
+
autopub/plugins/github.py,sha256=JLrCqf4tENeuzEJUEeGDwq9Tm7s_Fu6bmWNMsoZ0U04,13863
|
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.0a39.dist-info/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
|
16
|
+
autopub-1.0.0a39.dist-info/METADATA,sha256=Enpp1YaydZYYq3SKogBITibpeACjk0Pqj54A9i7WM3M,992
|
17
|
+
autopub-1.0.0a39.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
18
|
+
autopub-1.0.0a39.dist-info/entry_points.txt,sha256=oeTav5NgCxif6mcZ_HeVGgGv5LzS4DwdI01nr4bO1IM,43
|
19
|
+
autopub-1.0.0a39.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|