Skip to content

Commit

Permalink
cruft update (fix release process)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjurbanski-reef committed Jun 21, 2024
1 parent 136efc3 commit c6bb457
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .cruft.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"template": "https://github.com/reef-technologies/cookiecutter-rt-pkg",
"commit": "d0e68147cd24c0c69d7a8afaeb32c52258b1d487",
"commit": "3e6c8fc564e070428e32a8e90d8e2b0de116eddd",
"checkout": null,
"context": {
"cookiecutter": {
Expand Down
27 changes: 25 additions & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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"
)
19 changes: 13 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 = []
Expand All @@ -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"
Expand All @@ -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",
Expand All @@ -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

Expand Down

0 comments on commit c6bb457

Please sign in to comment.