autopub 1.0.0a38__py3-none-any.whl → 1.0.0a40__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/plugins/github.py +38 -20
- {autopub-1.0.0a38.dist-info → autopub-1.0.0a40.dist-info}/METADATA +1 -1
- {autopub-1.0.0a38.dist-info → autopub-1.0.0a40.dist-info}/RECORD +6 -6
- {autopub-1.0.0a38.dist-info → autopub-1.0.0a40.dist-info}/LICENSE +0 -0
- {autopub-1.0.0a38.dist-info → autopub-1.0.0a40.dist-info}/WHEEL +0 -0
- {autopub-1.0.0a38.dist-info → autopub-1.0.0a40.dist-info}/entry_points.txt +0 -0
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"
|
@@ -81,9 +85,6 @@ class GithubPlugin(AutopubPlugin):
|
|
81
85
|
raise AutopubException("GITHUB_TOKEN environment variable is required")
|
82
86
|
|
83
87
|
self.repository_name = os.environ.get("GITHUB_REPOSITORY")
|
84
|
-
self.discussion_category_name = os.environ.get(
|
85
|
-
"DISCUSSION_CATEGORY_NAME", "Announcements"
|
86
|
-
)
|
87
88
|
|
88
89
|
@cached_property
|
89
90
|
def _github(self) -> Github:
|
@@ -261,25 +262,26 @@ class GithubPlugin(AutopubPlugin):
|
|
261
262
|
)
|
262
263
|
|
263
264
|
for node in response["data"]["repository"]["discussionCategories"]["nodes"]:
|
264
|
-
if node["name"] == self.
|
265
|
+
if node["name"] == self.configuration.discussion_category:
|
265
266
|
return node["id"]
|
266
267
|
|
267
268
|
raise AutopubException(
|
268
|
-
f"Discussion category {self.
|
269
|
+
f"Discussion category {self.configuration.discussion_category} not found"
|
269
270
|
)
|
270
271
|
|
271
|
-
def _create_discussion(self, release_info: ReleaseInfo) ->
|
272
|
+
def _create_discussion(self, release_info: ReleaseInfo) -> str:
|
272
273
|
mutation = """
|
273
274
|
mutation CreateDiscussion($repositoryId: ID!, $categoryId: ID!, $body: String!, $title: String!) {
|
274
275
|
createDiscussion(input: {repositoryId: $repositoryId, categoryId: $categoryId, body: $body, title: $title}) {
|
275
276
|
discussion {
|
276
277
|
id
|
278
|
+
url
|
277
279
|
}
|
278
280
|
}
|
279
281
|
}
|
280
282
|
"""
|
281
283
|
|
282
|
-
self._github.requester.graphql_query(
|
284
|
+
_, response = self._github.requester.graphql_query(
|
283
285
|
mutation,
|
284
286
|
{
|
285
287
|
# TODO: repo.node_id is not yet been published to pypi
|
@@ -290,6 +292,8 @@ class GithubPlugin(AutopubPlugin):
|
|
290
292
|
},
|
291
293
|
)
|
292
294
|
|
295
|
+
return response["data"]["createDiscussion"]["discussion"]["url"]
|
296
|
+
|
293
297
|
def _get_pr_contributors(self) -> PRContributors:
|
294
298
|
pr: PullRequest = self.pull_request
|
295
299
|
|
@@ -340,13 +344,14 @@ class GithubPlugin(AutopubPlugin):
|
|
340
344
|
self._update_or_create_comment(message)
|
341
345
|
|
342
346
|
def _get_release_message(
|
343
|
-
self,
|
347
|
+
self,
|
348
|
+
release_info: ReleaseInfo,
|
349
|
+
include_release_info: bool = False,
|
350
|
+
discussion_url: Optional[str] = None,
|
344
351
|
) -> str:
|
345
352
|
assert self.pull_request is not None
|
346
353
|
|
347
354
|
contributors = self._get_pr_contributors()
|
348
|
-
sponsors = self._get_sponsors()
|
349
|
-
|
350
355
|
message = textwrap.dedent(
|
351
356
|
f"""
|
352
357
|
## {release_info.version}
|
@@ -373,19 +378,28 @@ class GithubPlugin(AutopubPlugin):
|
|
373
378
|
reviewers = [f"@{reviewer}" for reviewer in contributors["reviewers"]]
|
374
379
|
message += f"\n\nReviewers: {', '.join(reviewers)}"
|
375
380
|
|
376
|
-
if
|
377
|
-
|
378
|
-
|
381
|
+
if self.configuration.include_sponsors:
|
382
|
+
sponsors = self._get_sponsors()
|
383
|
+
if sponsors["sponsors"]:
|
384
|
+
public_sponsors = [f"@{sponsor}" for sponsor in sponsors["sponsors"]]
|
385
|
+
message += f"\n\nThanks to {', '.join(public_sponsors)}"
|
379
386
|
|
380
|
-
|
381
|
-
|
387
|
+
if sponsors["private_sponsors"]:
|
388
|
+
message += (
|
389
|
+
f" and the {sponsors['private_sponsors']} private sponsor(s)"
|
390
|
+
)
|
382
391
|
|
383
|
-
|
392
|
+
message += " for making this release possible ✨"
|
393
|
+
|
394
|
+
if discussion_url:
|
395
|
+
message += f"\n\nJoin the discussion: {discussion_url}"
|
384
396
|
|
385
397
|
return message
|
386
398
|
|
387
|
-
def _create_release(
|
388
|
-
|
399
|
+
def _create_release(
|
400
|
+
self, release_info: ReleaseInfo, discussion_url: Optional[str] = None
|
401
|
+
) -> None:
|
402
|
+
message = self._get_release_message(release_info, discussion_url=discussion_url)
|
389
403
|
|
390
404
|
release = self.repository.create_git_release(
|
391
405
|
tag=release_info.version,
|
@@ -405,5 +419,9 @@ class GithubPlugin(AutopubPlugin):
|
|
405
419
|
text, marker="<!-- autopub-comment-published -->"
|
406
420
|
)
|
407
421
|
|
408
|
-
|
409
|
-
|
422
|
+
discussion_url = None
|
423
|
+
|
424
|
+
if self.configuration.create_discussions:
|
425
|
+
discussion_url = self._create_discussion(release_info)
|
426
|
+
|
427
|
+
self._create_release(release_info, discussion_url)
|
@@ -5,15 +5,15 @@ autopub/plugin_loader.py,sha256=2ysITgpHGUmcb1mP1Qvs-iBX2wZxmfP9obnebThwUMA,1809
|
|
5
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=zxjHHvYZIaSGUvdlMRiNL2GSPoF2j7gvrwSe5BDERJk,13736
|
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.0a40.dist-info/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
|
16
|
+
autopub-1.0.0a40.dist-info/METADATA,sha256=bQdt07vWa2v7xSQQFQWdPEs7Zvfk-i44diUs3kxS-x8,992
|
17
|
+
autopub-1.0.0a40.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
18
|
+
autopub-1.0.0a40.dist-info/entry_points.txt,sha256=oeTav5NgCxif6mcZ_HeVGgGv5LzS4DwdI01nr4bO1IM,43
|
19
|
+
autopub-1.0.0a40.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|