autopub 1.0.0a15__tar.gz → 1.0.0a17__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {autopub-1.0.0a15 → autopub-1.0.0a17}/PKG-INFO +1 -1
- {autopub-1.0.0a15 → autopub-1.0.0a17}/autopub/__init__.py +11 -34
- {autopub-1.0.0a15 → autopub-1.0.0a17}/autopub/cli/__init__.py +3 -1
- {autopub-1.0.0a15 → autopub-1.0.0a17}/autopub/plugins/__init__.py +11 -18
- {autopub-1.0.0a15 → autopub-1.0.0a17}/autopub/plugins/bump_version.py +5 -8
- {autopub-1.0.0a15 → autopub-1.0.0a17}/autopub/plugins/git.py +4 -2
- {autopub-1.0.0a15 → autopub-1.0.0a17}/autopub/plugins/update_changelog.py +4 -2
- autopub-1.0.0a17/autopub/types.py +33 -0
- {autopub-1.0.0a15 → autopub-1.0.0a17}/pyproject.toml +1 -1
- autopub-1.0.0a15/autopub/types.py +0 -33
- {autopub-1.0.0a15 → autopub-1.0.0a17}/LICENSE +0 -0
- {autopub-1.0.0a15 → autopub-1.0.0a17}/README.md +0 -0
- {autopub-1.0.0a15 → autopub-1.0.0a17}/autopub/cli/plugins.py +0 -0
- {autopub-1.0.0a15 → autopub-1.0.0a17}/autopub/exceptions.py +0 -0
- {autopub-1.0.0a15 → autopub-1.0.0a17}/autopub/plugins/pdm.py +0 -0
- {autopub-1.0.0a15 → autopub-1.0.0a17}/autopub/plugins/poetry.py +0 -0
- {autopub-1.0.0a15 → autopub-1.0.0a17}/autopub/py.typed +0 -0
@@ -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:
|
@@ -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(
|
@@ -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
|
|
@@ -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
|
@@ -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")
|
@@ -0,0 +1,33 @@
|
|
1
|
+
from __future__ import annotations
|
2
|
+
|
3
|
+
import dataclasses
|
4
|
+
from typing import Any
|
5
|
+
|
6
|
+
from typing_extensions import Self
|
7
|
+
|
8
|
+
|
9
|
+
@dataclasses.dataclass(kw_only=True)
|
10
|
+
class ReleaseInfo:
|
11
|
+
"""Release information."""
|
12
|
+
|
13
|
+
release_type: str
|
14
|
+
release_notes: str
|
15
|
+
additional_info: dict[str, Any] = dataclasses.field(default_factory=dict)
|
16
|
+
additional_release_notes: list[str] = dataclasses.field(default_factory=list)
|
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"],
|
33
|
+
)
|
@@ -3,7 +3,7 @@ requires-python = ">=3.8"
|
|
3
3
|
|
4
4
|
[tool.poetry]
|
5
5
|
name = "autopub"
|
6
|
-
version = "1.0.0-alpha.
|
6
|
+
version = "1.0.0-alpha.17"
|
7
7
|
description = "Automatic package release upon pull request merge"
|
8
8
|
authors = ["Justin Mayer <entroP@gmail.com>", "Patrick Arminio <patrick.arminio@gmail.com>"]
|
9
9
|
license = "AGPL-3.0"
|
@@ -1,33 +0,0 @@
|
|
1
|
-
from __future__ import annotations
|
2
|
-
|
3
|
-
import dataclasses
|
4
|
-
|
5
|
-
|
6
|
-
@dataclasses.dataclass(kw_only=True)
|
7
|
-
class ReleaseInfo:
|
8
|
-
"""Release information."""
|
9
|
-
|
10
|
-
release_type: str
|
11
|
-
release_notes: str
|
12
|
-
additional_info: dict[str, str] = dataclasses.field(default_factory=dict)
|
13
|
-
additional_release_notes: list[str] = dataclasses.field(default_factory=list)
|
14
|
-
|
15
|
-
def with_version(
|
16
|
-
self, version: str, previous_version: str
|
17
|
-
) -> ReleaseInfoWithVersion:
|
18
|
-
"""Return a new ReleaseInfoWithVersion instance."""
|
19
|
-
return ReleaseInfoWithVersion(
|
20
|
-
release_type=self.release_type,
|
21
|
-
release_notes=self.release_notes,
|
22
|
-
additional_info=self.additional_info,
|
23
|
-
version=version,
|
24
|
-
previous_version=previous_version,
|
25
|
-
)
|
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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|