diff --git a/CITATION.cff b/CITATION.cff index 88711b7..2eec411 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -10,8 +10,8 @@ authors: email: "nikolina.sarcevic@gmail.com" orcid: "https://orcid.org/0000-0001-7301-6415" -version: "0.2.0" -date-released: 2026-05-15 +version: "0.5.1.dev0+g8dbb26ee5.d20260615" +date-released: 2026-06-15 repository-code: "https://github.com/cosmo-hub/lfkit" url: "https://github.com/cosmo-hub/lfkit" diff --git a/README.md b/README.md index bc6a30f..aa9e74f 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ If you use **LFKit** in your research, please cite it. title = {LFKit: Luminosity functions and photometric corrections toolkit}, author = {Šarčević, Nikolina}, year = {2026}, - version = {0.1.4}, + version = {0.5.1.dev0+g8dbb26ee5.d20260615}, url = {https://github.com/cosmology-kit/lfkit} } ``` diff --git a/pyproject.toml b/pyproject.toml index 74af1e1..6f48ecf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -194,3 +194,11 @@ commands = [ "{tox_root}/docs/_build/html/index.html", ], ] + +[tool.tox.env.sync-release-metadata] +description = "Sync CITATION.cff and README.md release metadata" +skip_install = true +deps = ["setuptools-scm>=8"] +commands = [ + ["python", "tools/sync_release_metadata.py"], +] diff --git a/tools/sync_release_metadata.py b/tools/sync_release_metadata.py new file mode 100644 index 0000000..52fa524 --- /dev/null +++ b/tools/sync_release_metadata.py @@ -0,0 +1,66 @@ +"""Sync release metadata into CITATION.cff and README.md.""" + +from __future__ import annotations + +import argparse +import re +import subprocess +from datetime import date +from pathlib import Path + + +ROOT = Path(__file__).resolve().parents[1] +CITATION = ROOT / "CITATION.cff" +README = ROOT / "README.md" + + +def get_version() -> str: + """Return version from setuptools-scm.""" + result = subprocess.run( + ["python", "-m", "setuptools_scm"], + cwd=ROOT, + check=True, + text=True, + capture_output=True, + ) + return result.stdout.strip().removeprefix("v") + + +def main() -> None: + """Sync release metadata files.""" + parser = argparse.ArgumentParser() + parser.add_argument("--version", default=get_version()) + parser.add_argument("--date", default=date.today().isoformat()) + args = parser.parse_args() + + version = args.version.removeprefix("v") + + citation_text = CITATION.read_text() + citation_text = re.sub( + r'^version:\s*".*"$', + f'version: "{version}"', + citation_text, + flags=re.MULTILINE, + ) + citation_text = re.sub( + r"^date-released:\s*.*$", + f"date-released: {args.date}", + citation_text, + flags=re.MULTILINE, + ) + CITATION.write_text(citation_text) + + readme_text = README.read_text() + readme_text = re.sub( + r"(version\s*=\s*\{)[^}]+(\})", + rf"\g<1>{version}\2", + readme_text, + count=1, + ) + README.write_text(readme_text) + + print(f"Synced CITATION.cff and README.md to {version} dated {args.date}") + + +if __name__ == "__main__": + main()