Skip to content

Commit 027b2ad

Browse files
Setting up version collection for Github actions
1 parent 7846691 commit 027b2ad

2 files changed

Lines changed: 7 additions & 13 deletions

File tree

src/rsmetacheck/__init__.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,4 @@
1-
import importlib.metadata
2-
3-
try:
4-
__version__ = importlib.metadata.version("rsmetacheck")
5-
except importlib.metadata.PackageNotFoundError:
6-
try:
7-
import tomllib
8-
from pathlib import Path
9-
_pyproject_path = Path(__file__).parent.parent.parent / "pyproject.toml"
10-
with open(_pyproject_path, "rb") as _f:
11-
__version__ = tomllib.load(_f)["tool"]["poetry"]["version"]
12-
except Exception:
13-
__version__ = "unknown"
1+
__version__ = "0.3.1"
142

153
from .detect_pitfalls_main import main
164
from .cli import cli

update_version.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ def update_version(toml_path, version_file):
2121
content = f.read()
2222

2323
new_version = get_version(version_file)
24+
if not new_version or new_version == "unknown":
25+
raise ValueError(
26+
f"Could not read a valid version from '{version_file}'. "
27+
"Ensure it contains a line like: __version__ = \"x.y.z\""
28+
)
29+
2430
new_content = content.replace("{version-file}", new_version)
2531

2632
with open(toml_path, 'w') as f:

0 commit comments

Comments
 (0)