autopub 1.0.0a15__py3-none-any.whl → 1.0.0a17__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 +11 -34
- autopub/cli/__init__.py +3 -1
- autopub/plugins/__init__.py +11 -18
- autopub/plugins/bump_version.py +5 -8
- autopub/plugins/git.py +4 -2
- autopub/plugins/update_changelog.py +4 -2
- autopub/types.py +20 -20
- {autopub-1.0.0a15.dist-info → autopub-1.0.0a17.dist-info}/METADATA +1 -1
- autopub-1.0.0a17.dist-info/RECORD +17 -0
- autopub-1.0.0a15.dist-info/RECORD +0 -17
- {autopub-1.0.0a15.dist-info → autopub-1.0.0a17.dist-info}/LICENSE +0 -0
- {autopub-1.0.0a15.dist-info → autopub-1.0.0a17.dist-info}/WHEEL +0 -0
- {autopub-1.0.0a15.dist-info → autopub-1.0.0a17.dist-info}/entry_points.txt +0 -0
autopub/__init__.py
CHANGED
@@ -19,11 +19,10 @@ from autopub.exceptions import (
|
|
19
19
|
ReleaseTypeMissing,
|
20
20
|
)
|
21
21
|
from autopub.plugins import (
|
22
|
-
AutopubBumpVersionPlugin,
|
23
22
|
AutopubPackageManagerPlugin,
|
24
23
|
AutopubPlugin,
|
25
24
|
)
|
26
|
-
from autopub.types import ReleaseInfo
|
25
|
+
from autopub.types import ReleaseInfo
|
27
26
|
|
28
27
|
|
29
28
|
class Autopub:
|
@@ -58,13 +57,9 @@ class Autopub:
|
|
58
57
|
if release_info["hash"] != self.release_file_hash:
|
59
58
|
raise ArtifactHashMismatch()
|
60
59
|
|
61
|
-
return ReleaseInfo(
|
62
|
-
release_type=release_info["release_type"],
|
63
|
-
release_notes=release_info["release_notes"],
|
64
|
-
additional_info=release_info["plugin_data"],
|
65
|
-
)
|
60
|
+
return ReleaseInfo.from_dict(release_info)
|
66
61
|
|
67
|
-
def check(self) ->
|
62
|
+
def check(self) -> None:
|
68
63
|
release_file = Path(self.RELEASE_FILE_PATH)
|
69
64
|
|
70
65
|
if not release_file.exists():
|
@@ -80,25 +75,11 @@ class Autopub:
|
|
80
75
|
for plugin in self.plugins:
|
81
76
|
plugin.on_release_notes_valid(release_info)
|
82
77
|
|
83
|
-
version = None
|
84
|
-
previous_version = None
|
85
|
-
|
86
78
|
for plugin in self.plugins:
|
87
79
|
plugin.post_check(release_info)
|
88
80
|
|
89
|
-
if isinstance(plugin, AutopubBumpVersionPlugin):
|
90
|
-
version = plugin.new_version
|
91
|
-
previous_version = plugin.current_version
|
92
|
-
|
93
|
-
# TODO: raise exception if version is None
|
94
|
-
|
95
|
-
assert version is not None
|
96
|
-
assert previous_version is not None
|
97
|
-
|
98
81
|
self._write_artifact(release_info)
|
99
82
|
|
100
|
-
return release_info.with_version(version, previous_version)
|
101
|
-
|
102
83
|
def build(self) -> None:
|
103
84
|
if not any(
|
104
85
|
isinstance(plugin, AutopubPackageManagerPlugin) for plugin in self.plugins
|
@@ -110,15 +91,15 @@ class Autopub:
|
|
110
91
|
plugin.build()
|
111
92
|
|
112
93
|
def prepare(self) -> None:
|
113
|
-
|
114
|
-
plugin.prepare(self.release_info)
|
94
|
+
release_info = self.release_info
|
115
95
|
|
116
|
-
self.
|
96
|
+
for plugin in self.plugins:
|
97
|
+
plugin.prepare(release_info)
|
117
98
|
|
118
99
|
for plugin in self.plugins:
|
119
|
-
plugin.post_prepare(
|
100
|
+
plugin.post_prepare(release_info)
|
120
101
|
|
121
|
-
self._write_artifact(
|
102
|
+
self._write_artifact(release_info)
|
122
103
|
|
123
104
|
def _delete_release_file(self) -> None:
|
124
105
|
self.release_file.unlink(missing_ok=True)
|
@@ -138,14 +119,8 @@ class Autopub:
|
|
138
119
|
|
139
120
|
def _write_artifact(self, release_info: ReleaseInfo) -> None:
|
140
121
|
data = {
|
122
|
+
**release_info.dict(),
|
141
123
|
"hash": self.release_file_hash,
|
142
|
-
"release_type": release_info.release_type,
|
143
|
-
"release_notes": release_info.release_notes,
|
144
|
-
"plugin_data": {
|
145
|
-
key: value
|
146
|
-
for plugin in self.plugins
|
147
|
-
for key, value in plugin.data.items()
|
148
|
-
},
|
149
124
|
}
|
150
125
|
|
151
126
|
self.release_info_file.parent.mkdir(exist_ok=True)
|
@@ -197,6 +172,8 @@ class Autopub:
|
|
197
172
|
release_type=release_type,
|
198
173
|
release_notes=post.content,
|
199
174
|
additional_info=data,
|
175
|
+
version=None,
|
176
|
+
previous_version=None,
|
200
177
|
)
|
201
178
|
|
202
179
|
def _validate_release_notes(self, release_notes: str) -> ReleaseInfo:
|
autopub/cli/__init__.py
CHANGED
@@ -29,12 +29,14 @@ def check():
|
|
29
29
|
autopub = Autopub(plugins=find_plugins(state["plugins"]))
|
30
30
|
|
31
31
|
try:
|
32
|
-
|
32
|
+
autopub.check()
|
33
33
|
except AutopubException as e:
|
34
34
|
rich.print(Panel.fit(f"[red]{e.message}"))
|
35
35
|
|
36
36
|
raise typer.Exit(1) from e
|
37
37
|
else:
|
38
|
+
release_info = autopub.release_info
|
39
|
+
|
38
40
|
rich.print(
|
39
41
|
Padding(
|
40
42
|
Group(
|
autopub/plugins/__init__.py
CHANGED
@@ -5,7 +5,7 @@ import subprocess
|
|
5
5
|
from typing import Any, Protocol, runtime_checkable
|
6
6
|
|
7
7
|
from autopub.exceptions import AutopubException, CommandFailed
|
8
|
-
from autopub.types import ReleaseInfo
|
8
|
+
from autopub.types import ReleaseInfo
|
9
9
|
|
10
10
|
|
11
11
|
class AutopubPlugin:
|
@@ -23,32 +23,25 @@ class AutopubPlugin:
|
|
23
23
|
def prepare(self, release_info: ReleaseInfo) -> None: # pragma: no cover
|
24
24
|
...
|
25
25
|
|
26
|
-
def post_prepare(
|
27
|
-
self, release_info: ReleaseInfoWithVersion
|
28
|
-
) -> None: # pragma: no cover
|
29
|
-
...
|
30
|
-
|
31
|
-
def validate_release_notes(self, release_info: ReleaseInfo): # pragma: no cover
|
26
|
+
def post_prepare(self, release_info: ReleaseInfo) -> None: # pragma: no cover
|
32
27
|
...
|
33
28
|
|
34
|
-
def
|
29
|
+
def validate_release_notes(
|
30
|
+
self, release_info: ReleaseInfo
|
31
|
+
) -> None: # pragma: no cover
|
35
32
|
...
|
36
33
|
|
37
|
-
def
|
34
|
+
def on_release_notes_valid(
|
35
|
+
self, release_info: ReleaseInfo
|
36
|
+
) -> None: # pragma: no cover
|
38
37
|
...
|
39
38
|
|
40
|
-
def
|
41
|
-
self,
|
39
|
+
def on_release_notes_invalid(
|
40
|
+
self, exception: AutopubException
|
42
41
|
) -> None: # pragma: no cover
|
43
42
|
...
|
44
43
|
|
45
|
-
|
46
|
-
@runtime_checkable
|
47
|
-
class AutopubBumpVersionPlugin(Protocol):
|
48
|
-
new_version: str
|
49
|
-
current_version: str
|
50
|
-
|
51
|
-
def post_check(self, release_info: ReleaseInfo) -> None: # pragma: no cover
|
44
|
+
def post_publish(self, release_info: ReleaseInfo) -> None: # pragma: no cover
|
52
45
|
...
|
53
46
|
|
54
47
|
|
autopub/plugins/bump_version.py
CHANGED
@@ -5,14 +5,11 @@ import pathlib
|
|
5
5
|
import tomlkit
|
6
6
|
from dunamai import Version
|
7
7
|
|
8
|
-
from autopub.plugins import
|
8
|
+
from autopub.plugins import AutopubPlugin
|
9
9
|
from autopub.types import ReleaseInfo
|
10
10
|
|
11
11
|
|
12
|
-
class BumpVersionPlugin(
|
13
|
-
current_version: str
|
14
|
-
new_version: str
|
15
|
-
|
12
|
+
class BumpVersionPlugin(AutopubPlugin):
|
16
13
|
@property
|
17
14
|
def pyproject_config(self) -> tomlkit.TOMLDocument:
|
18
15
|
content = pathlib.Path("pyproject.toml").read_text()
|
@@ -38,9 +35,9 @@ class BumpVersionPlugin(AutopubBumpVersionPlugin, AutopubPlugin):
|
|
38
35
|
|
39
36
|
version = Version(self._get_version(config))
|
40
37
|
|
41
|
-
|
42
|
-
|
38
|
+
release_info.previous_version = str(version)
|
39
|
+
release_info.version = version.bump(bump_type).serialize()
|
43
40
|
|
44
|
-
self._update_version(config,
|
41
|
+
self._update_version(config, release_info.version)
|
45
42
|
|
46
43
|
pathlib.Path("pyproject.toml").write_text(tomlkit.dumps(config)) # type: ignore
|
autopub/plugins/git.py
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
3
|
from autopub.plugins import AutopubPlugin
|
4
|
-
from autopub.types import
|
4
|
+
from autopub.types import ReleaseInfo
|
5
5
|
|
6
6
|
|
7
7
|
class GitPlugin(AutopubPlugin):
|
8
|
-
def post_publish(self, release_info:
|
8
|
+
def post_publish(self, release_info: ReleaseInfo) -> None:
|
9
|
+
assert release_info.version is not None
|
10
|
+
|
9
11
|
tag_name = release_info.version
|
10
12
|
|
11
13
|
self.run_command(["git", "config", "--global", "user.email", "autopub@autopub"])
|
@@ -4,7 +4,7 @@ from datetime import date
|
|
4
4
|
from pathlib import Path
|
5
5
|
|
6
6
|
from autopub.plugins import AutopubPlugin
|
7
|
-
from autopub.types import
|
7
|
+
from autopub.types import ReleaseInfo
|
8
8
|
|
9
9
|
# TODO: from config
|
10
10
|
CHANGELOG_HEADER = "========="
|
@@ -16,7 +16,7 @@ class UpdateChangelogPlugin(AutopubPlugin):
|
|
16
16
|
def changelog_file(self) -> Path:
|
17
17
|
return Path("CHANGELOG.md")
|
18
18
|
|
19
|
-
def post_prepare(self, release_info:
|
19
|
+
def post_prepare(self, release_info: ReleaseInfo) -> None:
|
20
20
|
if not self.changelog_file.exists():
|
21
21
|
self.changelog_file.write_text(f"CHANGELOG\n{CHANGELOG_HEADER}\n\n")
|
22
22
|
|
@@ -37,6 +37,8 @@ class UpdateChangelogPlugin(AutopubPlugin):
|
|
37
37
|
|
38
38
|
new_version = release_info.version
|
39
39
|
|
40
|
+
assert new_version is not None
|
41
|
+
|
40
42
|
with self.changelog_file.open("w") as f:
|
41
43
|
f.write("\n".join(header))
|
42
44
|
f.write("\n")
|
autopub/types.py
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
3
|
import dataclasses
|
4
|
+
from typing import Any
|
5
|
+
|
6
|
+
from typing_extensions import Self
|
4
7
|
|
5
8
|
|
6
9
|
@dataclasses.dataclass(kw_only=True)
|
@@ -9,25 +12,22 @@ class ReleaseInfo:
|
|
9
12
|
|
10
13
|
release_type: str
|
11
14
|
release_notes: str
|
12
|
-
additional_info: dict[str,
|
15
|
+
additional_info: dict[str, Any] = dataclasses.field(default_factory=dict)
|
13
16
|
additional_release_notes: list[str] = dataclasses.field(default_factory=list)
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
) ->
|
18
|
-
"""Return a
|
19
|
-
return
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
17
|
+
version: str | None = None
|
18
|
+
previous_version: str | None = None
|
19
|
+
|
20
|
+
def dict(self) -> dict[str, Any]:
|
21
|
+
"""Return a dictionary representation of the release info."""
|
22
|
+
return dataclasses.asdict(self)
|
23
|
+
|
24
|
+
@classmethod
|
25
|
+
def from_dict(cls, data: dict[str, Any]) -> Self:
|
26
|
+
return cls(
|
27
|
+
release_type=data["release_type"],
|
28
|
+
release_notes=data["release_notes"],
|
29
|
+
additional_info=data["additional_info"],
|
30
|
+
additional_release_notes=data["additional_release_notes"],
|
31
|
+
version=data["version"],
|
32
|
+
previous_version=data["previous_version"],
|
25
33
|
)
|
26
|
-
|
27
|
-
|
28
|
-
@dataclasses.dataclass(kw_only=True)
|
29
|
-
class ReleaseInfoWithVersion(ReleaseInfo):
|
30
|
-
"""Release information with version."""
|
31
|
-
|
32
|
-
version: str
|
33
|
-
previous_version: str
|
@@ -0,0 +1,17 @@
|
|
1
|
+
autopub/__init__.py,sha256=slOk0FvFlnZaE9ggQfyyK_6t4e28OEhKI-aa-YB6aTg,5592
|
2
|
+
autopub/cli/__init__.py,sha256=3Adr2M3t0F95LxdtlX8HPILrOj2AGrrT4WJ5T120D_Q,3098
|
3
|
+
autopub/cli/plugins.py,sha256=0wzL1ipSrNWh2hi2fp0k0HL15GPncSqKgt15tHRM_pw,1117
|
4
|
+
autopub/exceptions.py,sha256=JYn8sIYWCedhtO3XfftZ0M5M_rAPxiGQ4MGbWUaTYwE,1243
|
5
|
+
autopub/plugins/__init__.py,sha256=5_VB5QszWfdNPA04gZKKGh3TXQEGoE5JSMyh-8XvnnE,1538
|
6
|
+
autopub/plugins/bump_version.py,sha256=Z6UKEJKdZVn6kACN4nQTJ3253kwAnSm1HpOxq1zHWpw,1413
|
7
|
+
autopub/plugins/git.py,sha256=GeXcvlDEDOVb0cerebkfz8YruK7JYK6IyV872hBIqis,856
|
8
|
+
autopub/plugins/pdm.py,sha256=Pczye06fKg8_HMJDkEfMXQyvao9rZ7sqzTHFd6lLEpU,532
|
9
|
+
autopub/plugins/poetry.py,sha256=d2LvW9RI7ZB3reBOXbcp1mqWmzQ06Uyg_T-MxTvlSBg,517
|
10
|
+
autopub/plugins/update_changelog.py,sha256=g_6flOP5wocZbjOaYSayWxobL3ld8f0wT78nFtAIkFc,1586
|
11
|
+
autopub/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
12
|
+
autopub/types.py,sha256=gY1WR93XZVFS7vf5JMSmL_h5z7zO51-rtmZ6MYsh3so,1043
|
13
|
+
autopub-1.0.0a17.dist-info/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
|
14
|
+
autopub-1.0.0a17.dist-info/METADATA,sha256=0HzSIGl_P3DzVBcjbhRKegCNDuSd9hV-XZG73cDNjxw,3758
|
15
|
+
autopub-1.0.0a17.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
|
16
|
+
autopub-1.0.0a17.dist-info/entry_points.txt,sha256=oeTav5NgCxif6mcZ_HeVGgGv5LzS4DwdI01nr4bO1IM,43
|
17
|
+
autopub-1.0.0a17.dist-info/RECORD,,
|
@@ -1,17 +0,0 @@
|
|
1
|
-
autopub/__init__.py,sha256=Jwkj_BFvC2QzkS7zdyrlj1HpeNN7Ns7UYoxbpw4iXvw,6448
|
2
|
-
autopub/cli/__init__.py,sha256=2tpSa8AVa2dnE62GSG5R8fnalAqybcCK-aV2flQItjQ,3068
|
3
|
-
autopub/cli/plugins.py,sha256=0wzL1ipSrNWh2hi2fp0k0HL15GPncSqKgt15tHRM_pw,1117
|
4
|
-
autopub/exceptions.py,sha256=JYn8sIYWCedhtO3XfftZ0M5M_rAPxiGQ4MGbWUaTYwE,1243
|
5
|
-
autopub/plugins/__init__.py,sha256=AJZvnfuTp6l5XXHxTd-cBZy90cxC4T4GodiTtN78K2Q,1749
|
6
|
-
autopub/plugins/bump_version.py,sha256=qF9qp0KDDQQSaRTb0-gHZqcmKkB_gWNjaLp0TDYl6jI,1496
|
7
|
-
autopub/plugins/git.py,sha256=MeU7sMTsUGrzCJtMY0McoMDqkMaUsrjHD79J6fH3Tvs,829
|
8
|
-
autopub/plugins/pdm.py,sha256=Pczye06fKg8_HMJDkEfMXQyvao9rZ7sqzTHFd6lLEpU,532
|
9
|
-
autopub/plugins/poetry.py,sha256=d2LvW9RI7ZB3reBOXbcp1mqWmzQ06Uyg_T-MxTvlSBg,517
|
10
|
-
autopub/plugins/update_changelog.py,sha256=_a1jlt7mXGIbL7UjPTkTXkiiQFkFiPy_qid2tvyRvq4,1568
|
11
|
-
autopub/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
12
|
-
autopub/types.py,sha256=f51rse4-ZZAByWq7HohivhZYR8_s69jZHtisw7WBUfk,951
|
13
|
-
autopub-1.0.0a15.dist-info/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
|
14
|
-
autopub-1.0.0a15.dist-info/METADATA,sha256=kBzXdo11ItEslIZFMiG1-hOCI1QezbmJXJ1HnIbJpO8,3758
|
15
|
-
autopub-1.0.0a15.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
|
16
|
-
autopub-1.0.0a15.dist-info/entry_points.txt,sha256=oeTav5NgCxif6mcZ_HeVGgGv5LzS4DwdI01nr4bO1IM,43
|
17
|
-
autopub-1.0.0a15.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|