mirror of
https://github.com/joshuadavidthomas/django-language-server.git
synced 2025-08-03 17:48:20 +00:00
add release and supporting commands to nox (#103)
This commit is contained in:
parent
a3e559c217
commit
31b69aab14
3 changed files with 185 additions and 2 deletions
135
noxfile.py
135
noxfile.py
|
@ -2,6 +2,7 @@
|
|||
# /// script
|
||||
# requires-python = ">=3.13"
|
||||
# dependencies = [
|
||||
# "bumpver",
|
||||
# "nox",
|
||||
# ]
|
||||
# ///
|
||||
|
@ -10,9 +11,11 @@ from __future__ import annotations
|
|||
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
import nox
|
||||
from bumpver.version import to_pep440
|
||||
|
||||
nox.options.default_venv_backend = "uv|virtualenv"
|
||||
nox.options.reuse_existing_virtualenvs = True
|
||||
|
@ -150,5 +153,137 @@ def gha_matrix(session):
|
|||
print(matrix)
|
||||
|
||||
|
||||
@nox.session
|
||||
def cog(session):
|
||||
COG_FILES = [
|
||||
"CONTRIBUTING.md",
|
||||
"README.md",
|
||||
"pyproject.toml",
|
||||
]
|
||||
session.run(
|
||||
"uv",
|
||||
"run",
|
||||
"--with",
|
||||
"bumpver",
|
||||
"--with",
|
||||
"cogapp",
|
||||
"--with",
|
||||
"nox",
|
||||
"cog",
|
||||
"-r",
|
||||
*COG_FILES,
|
||||
)
|
||||
git_status = session.run("git", "status", "--porcelain", external=True, silent=True)
|
||||
if not any(cog_file in git_status for cog_file in COG_FILES):
|
||||
session.log("No changes to documentation files, skipping commit")
|
||||
return
|
||||
session.run("git", "add", *COG_FILES, external=True)
|
||||
session.run(
|
||||
"git",
|
||||
"commit",
|
||||
"-m",
|
||||
"auto-regenerate docs using cog",
|
||||
external=True,
|
||||
silent=True,
|
||||
)
|
||||
|
||||
|
||||
@nox.session
|
||||
def process_docs(session):
|
||||
session.run("uv", "run", "docs/processor.py")
|
||||
session.run("git", "add", "docs/", external=True)
|
||||
session.run(
|
||||
"git",
|
||||
"commit",
|
||||
"-m",
|
||||
"process docs from GHFM to mkdocs-style",
|
||||
external=True,
|
||||
silent=True,
|
||||
)
|
||||
|
||||
|
||||
@nox.session
|
||||
def update_changelog(session):
|
||||
version = get_version(session)
|
||||
|
||||
with open("CHANGELOG.md", "r") as f:
|
||||
changelog = f.read()
|
||||
|
||||
changelog = changelog.replace("## [Unreleased]", f"## [{version}]", 1)
|
||||
changelog = changelog.replace(
|
||||
f"## [{version}]", f"## [Unreleased]\n\n## [{version}]"
|
||||
)
|
||||
|
||||
repo_url = session.run("git", "remote", "get-url", "origin", silent=True).strip()
|
||||
repo_url = repo_url.replace(".git", "")
|
||||
|
||||
changelog += f"\n[{version}]: {repo_url}/releases/tag/v{version}"
|
||||
changelog = re.sub(
|
||||
r"\[unreleased\]: .+",
|
||||
f"[unreleased]: {repo_url}/compare/v{version}...HEAD",
|
||||
changelog,
|
||||
)
|
||||
|
||||
with open("CHANGELOG.md", "w") as f:
|
||||
f.write(changelog)
|
||||
|
||||
session.run("git", "add", "CHANGELOG.md", external=True)
|
||||
session.run(
|
||||
"git",
|
||||
"commit",
|
||||
"-m",
|
||||
f"update CHANGELOG for version {version}",
|
||||
external=True,
|
||||
silent=True,
|
||||
)
|
||||
|
||||
|
||||
@nox.session
|
||||
def update_uvlock(session):
|
||||
version = get_version(session)
|
||||
|
||||
session.run("uv", "lock")
|
||||
|
||||
git_status = session.run("git", "status", "--porcelain", external=True, silent=True)
|
||||
if "uv.lock" not in git_status:
|
||||
session.log("No changes to uv.lock, skipping commit")
|
||||
return
|
||||
|
||||
session.run("git", "add", "uv.lock", external=True)
|
||||
session.run(
|
||||
"git",
|
||||
"commit",
|
||||
"-m",
|
||||
f"update uv.lock for version {version}",
|
||||
external=True,
|
||||
silent=True,
|
||||
)
|
||||
|
||||
|
||||
def get_version(session):
|
||||
command = ["uv", "run", "bumpver", "update", "--dry", "--no-fetch"]
|
||||
if session.posargs:
|
||||
args = []
|
||||
for arg in session.posargs:
|
||||
if arg and arg not in ["--dry", "--no-fetch"]:
|
||||
args.extend(arg.split(" "))
|
||||
command.extend(args)
|
||||
output = session.run(*command, silent=True)
|
||||
match = re.search(r"New Version: (.+)", output)
|
||||
return to_pep440(match.group(1)) if match else None
|
||||
|
||||
|
||||
@nox.session(requires=["cog", "process_docs", "update_changelog", "update_uvlock"])
|
||||
def release(session):
|
||||
command = ["uv", "run", "bumpver", "update"]
|
||||
if session.posargs:
|
||||
args = []
|
||||
for arg in session.posargs:
|
||||
if arg:
|
||||
args.extend(arg.split(" "))
|
||||
command.extend(args)
|
||||
session.run(*command)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
nox.main()
|
||||
|
|
|
@ -4,6 +4,8 @@ build-backend = "maturin"
|
|||
|
||||
[dependency-groups]
|
||||
dev = [
|
||||
"bumpver>=2024.1130",
|
||||
"cogapp>=3.4.1",
|
||||
"django-stubs>=5.1.1",
|
||||
"maturin>=1.7.8",
|
||||
"ruff>=0.8.2",
|
||||
|
@ -78,8 +80,8 @@ Source = "https://github.com/joshuadavidthomas/django-language-server"
|
|||
commit = true
|
||||
commit_message = ":bookmark: bump version {old_version} -> {new_version}"
|
||||
current_version = "5.1.0-alpha.2"
|
||||
push = false
|
||||
tag = false
|
||||
push = true
|
||||
tag = true
|
||||
version_pattern = "MAJOR.MINOR.PATCH[-TAG[.NUM]]"
|
||||
|
||||
[tool.bumpver.file_patterns]
|
||||
|
|
46
uv.lock
generated
46
uv.lock
generated
|
@ -40,6 +40,21 @@ wheels = [
|
|||
{ url = "https://files.pythonhosted.org/packages/0c/37/fb6973edeb700f6e3d6ff222400602ab1830446c25c7b4676d8de93e65b8/backrefs-5.8-py39-none-any.whl", hash = "sha256:a66851e4533fb5b371aa0628e1fee1af05135616b86140c9d787a2ffdf4b8fdc", size = 380336 },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bumpver"
|
||||
version = "2024.1130"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "click" },
|
||||
{ name = "colorama" },
|
||||
{ name = "lexid" },
|
||||
{ name = "toml" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/bb/a9/becf78cc86211bd2287114c4f990a3bed450816696f14810cc59d7815bb5/bumpver-2024.1130.tar.gz", hash = "sha256:74f7ebc294b2240f346e99748cc6f238e57b050999d7428db75d76baf2bf1437", size = 115102 }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/09/34/57d038ae30374976ce4ec57db9dea95bf55d1b5543b35e77aa9ce3543198/bumpver-2024.1130-py2.py3-none-any.whl", hash = "sha256:8e54220aefe7db25148622f45959f7beb6b8513af0b0429b38b9072566665a49", size = 65273 },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "certifi"
|
||||
version = "2025.1.31"
|
||||
|
@ -135,6 +150,15 @@ wheels = [
|
|||
{ url = "https://files.pythonhosted.org/packages/7e/d4/7ebdbd03970677812aac39c869717059dbb71a4cfc033ca6e5221787892c/click-8.1.8-py3-none-any.whl", hash = "sha256:63c132bbbed01578a06712a2d1f497bb62d9c1c0d329b7903a866228027263b2", size = 98188 },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cogapp"
|
||||
version = "3.4.1"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/b1/d7/9e40d9d957ab1042046b3f6959528f47f9c6e8cb0f2031a3ba69809ed6e9/cogapp-3.4.1.tar.gz", hash = "sha256:a806d5db9e318a1a2d3fce988008179168e7db13e5e55b19b79763f9bb9d2982", size = 53776 }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/92/4e/bd3bd0641fb05ba3ab6e16ffb9132ef71ffdeb0392ce21ec6670ff66eaf6/cogapp-3.4.1-py3-none-any.whl", hash = "sha256:1daba7b6c8bb23b733c64833de7aa3a42476c05afba19cff937e1b522216859d", size = 27328 },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "colorama"
|
||||
version = "0.4.6"
|
||||
|
@ -185,6 +209,8 @@ source = { editable = "." }
|
|||
|
||||
[package.dev-dependencies]
|
||||
dev = [
|
||||
{ name = "bumpver" },
|
||||
{ name = "cogapp" },
|
||||
{ name = "django-stubs" },
|
||||
{ name = "maturin" },
|
||||
{ name = "ruff" },
|
||||
|
@ -197,6 +223,8 @@ docs = [
|
|||
|
||||
[package.metadata.requires-dev]
|
||||
dev = [
|
||||
{ name = "bumpver", specifier = ">=2024.1130" },
|
||||
{ name = "cogapp", specifier = ">=3.4.1" },
|
||||
{ name = "django-stubs", specifier = ">=5.1.1" },
|
||||
{ name = "maturin", specifier = ">=1.7.8" },
|
||||
{ name = "ruff", specifier = ">=0.8.2" },
|
||||
|
@ -280,6 +308,15 @@ wheels = [
|
|||
{ url = "https://files.pythonhosted.org/packages/62/a1/3d680cbfd5f4b8f15abc1d571870c5fc3e594bb582bc3b64ea099db13e56/jinja2-3.1.6-py3-none-any.whl", hash = "sha256:85ece4451f492d0c13c5dd7c13a64681a86afae63a5f347908daf103ce6d2f67", size = 134899 },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lexid"
|
||||
version = "2021.1006"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/60/0b/28a3f9abc75abbf1fa996eb2dd77e1e33a5d1aac62566e3f60a8ec8b8a22/lexid-2021.1006.tar.gz", hash = "sha256:509a3a4cc926d3dbf22b203b18a4c66c25e6473fb7c0e0d30374533ac28bafe5", size = 11525 }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/cf/e3/35764404a4b7e2021be1f88f42264c2e92e0c4720273559a62461ce64a47/lexid-2021.1006-py2.py3-none-any.whl", hash = "sha256:5526bb5606fd74c7add23320da5f02805bddd7c77916f2dc1943e6bada8605ed", size = 7587 },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "markdown"
|
||||
version = "3.8"
|
||||
|
@ -656,6 +693,15 @@ wheels = [
|
|||
{ url = "https://files.pythonhosted.org/packages/a9/5c/bfd6bd0bf979426d405cc6e71eceb8701b148b16c21d2dc3c261efc61c7b/sqlparse-0.5.3-py3-none-any.whl", hash = "sha256:cf2196ed3418f3ba5de6af7e82c694a9fbdbfecccdfc72e281548517081f16ca", size = 44415 },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.10.2"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/be/ba/1f744cdc819428fc6b5084ec34d9b30660f6f9daaf70eead706e3203ec3c/toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f", size = 22253 }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/44/6f/7120676b6d73228c96e17f1f794d8ab046fc910d781c8d151120c3f1569e/toml-0.10.2-py2.py3-none-any.whl", hash = "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b", size = 16588 },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tomli"
|
||||
version = "2.2.1"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue