From c6bb4570ac2068040e6a6fc97abbbf2ef18a1831 Mon Sep 17 00:00:00 2001 From: Maciej Urbanski Date: Fri, 21 Jun 2024 21:57:08 +0200 Subject: [PATCH] cruft update (fix release process) --- .cruft.json | 2 +- noxfile.py | 27 +++++++++++++++++++++++++-- pyproject.toml | 19 +++++++++++++------ 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/.cruft.json b/.cruft.json index 3f4e1c6..a868ba4 100644 --- a/.cruft.json +++ b/.cruft.json @@ -1,6 +1,6 @@ { "template": "https://github.com/reef-technologies/cookiecutter-rt-pkg", - "commit": "d0e68147cd24c0c69d7a8afaeb32c52258b1d487", + "commit": "3e6c8fc564e070428e32a8e90d8e2b0de116eddd", "checkout": null, "context": { "cookiecutter": { diff --git a/noxfile.py b/noxfile.py index 09904a1..f5f15f2 100644 --- a/noxfile.py +++ b/noxfile.py @@ -162,6 +162,7 @@ def test(session, django: str): @nox.session(python=PYTHON_DEFAULT_VERSION) def make_release(session): + install(session, "release", no_self=True, no_default=True) parser = argparse.ArgumentParser() def version(value): @@ -174,14 +175,36 @@ def version(value): help="Release version in semver format (e.g. 1.2.3)", type=version, ) + parser.add_argument( + "--draft", + action="store_true", + help="Create a draft release", + ) parsed_args = parser.parse_args(session.posargs) local_changes = subprocess.check_output(["git", "diff", "--stat"]) if local_changes: session.error("Uncommitted changes detected") - current_branch = subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"], text=True) + current_branch = subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"], text=True).strip() if current_branch != MAIN_BRANCH_NAME: - session.error(f"WARNING: releasing from a branch different than {MAIN_BRANCH_NAME!r}") + session.warn(f"Releasing from a branch {current_branch!r}, while main branch is {MAIN_BRANCH_NAME!r}") + if not parsed_args.draft: + session.error("Only draft releases are allowed from non-main branch") session.run("towncrier", "build", "--yes", "--version", parsed_args.release_version) + + if parsed_args.draft: + tag = f"draft/v{parsed_args.release_version}" + message = f"Draft release {tag}" + else: + tag = f"v{parsed_args.release_version}" + message = f"release {tag}" + + session.log( + f"CHANGELOG updated, please review changes, and execute when ready:\n" + f" git commit -m {message!r}\n" + f" git push origin {current_branch}\n" + f" git tag {tag}\n" + f" git push origin {tag}\n" + ) diff --git a/pyproject.toml b/pyproject.toml index edd5547..2bcacaf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,5 @@ [project] name = "django-fingerprint-rt" -version = "0.0.2" requires-python = ">=3.9" description = "Users fingerprinting for your django app" keywords = [] @@ -25,6 +24,11 @@ classifiers = [ "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", ] +dynamic = [ + "version", +] +dependencies = [ +] [project.urls] "Source" = "https://github.com/reef-technologies/django-fingerprint-rt" @@ -34,14 +38,12 @@ classifiers = [ requires = ["pdm-backend"] build-backend = "pdm.backend" -[tool.pytest.ini_options] -pythonpath = [".", "demo"] # allow for `import tests` in test files -target_package_name = "fingerprint" # required by pytest-apiver -DJANGO_SETTINGS_MODULE="demo.settings" - [tool.pdm] distribution = true +[tool.pdm.version] +source = "scm" + [tool.pdm.dev-dependencies] test = [ "freezegun", @@ -65,6 +67,11 @@ release = [ "towncrier", ] +[tool.pytest.ini_options] +pythonpath = [".", "demo"] # allow for `import tests` in test files +target_package_name = "fingerprint" # required by pytest-apiver +DJANGO_SETTINGS_MODULE="demo.settings" + [tool.ruff] line-length = 120