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 49291c0 commit bf7ddf7
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 10 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": "9098eed1a7c4e44e568f990cb111e9ccb6bf78ca",
"commit": "7390ecadb2c65075b6c6c9216c894cc6c4533b3e",
"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'
)
18 changes: 12 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[project]
name = "django-business-metrics"
version = "1.0.2"
requires-python = ">=3.9"
description = "Django Prometheus business metrics"
keywords = []
Expand All @@ -12,13 +11,17 @@ authors = [
]
classifiers = [
"Framework :: Django",
"Framework :: Django :: 4.2",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
dynamic = [
"version",
]
dependencies = [
"Django>=3",
"prometheus-client>=0.13.0",
Expand All @@ -32,14 +35,12 @@ dependencies = [
requires = ["pdm-backend"]
build-backend = "pdm.backend"

[tool.pytest.ini_options]
pythonpath = ["."] # allow for `import tests` in test files
target_package_name = "django_business_metrics" # required by pytest-apiver
DJANGO_SETTINGS_MODULE="tests.settings"

[tool.pdm]
distribution = true

[tool.pdm.version]
source = "scm"

[tool.pdm.dev-dependencies]
test = [
"freezegun",
Expand All @@ -62,6 +63,11 @@ release = [
"towncrier",
]

[tool.pytest.ini_options]
pythonpath = ["."] # allow for `import tests` in test files
target_package_name = "django_business_metrics" # required by pytest-apiver
DJANGO_SETTINGS_MODULE="tests.settings"

[tool.ruff]
line-length = 120

Expand Down
4 changes: 3 additions & 1 deletion tests/unit/internal/test_setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""
Basic test environment setup test.
Test setup tests.
This test file is here always to indicate that everything was installed and the CI was able to run tests.
It should always pass as long as all dependencies are properly installed.
"""

Expand Down

0 comments on commit bf7ddf7

Please sign in to comment.