Skip to content

Commit

Permalink
Use 'hatch version' instead of manually updating the version.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein committed Sep 27, 2023
1 parent 1115a30 commit f3916e2
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,17 +289,6 @@ def check_package_files(
)


def _repl_version(session: nox.Session, new_version: str):
with open("pyproject.toml", "r+") as fp:
lines = tuple(fp)
fp.seek(0)
for line in lines:
if line.startswith("version = "):
line = f'version = "{new_version}"\n'
fp.write(line)
fp.truncate()


def check_no_modifications(session: nox.Session) -> None:
modified = session.run(
"git",
Expand Down Expand Up @@ -356,7 +345,9 @@ def bump(session: nox.Session):
"or two positional arguments must be provided."
)
install(session, "antsibull-changelog[toml]", "hatch")
_repl_version(session, version)
current_version = session.run("hatch", "version", silent=True).strip()
if version != current_version:
session.run("hatch", "version", version)
if len(session.posargs) > 1:
fragment = session.run(
"python",
Expand Down Expand Up @@ -403,8 +394,7 @@ def publish(session: nox.Session):
check_no_modifications(session)
install(session, "hatch")
session.run("hatch", "publish", *session.posargs)
version = session.run("hatch", "version", silent=True).strip()
_repl_version(session, f"{version}.post0")
session.run("hatch", "version", "post")
session.run("git", "add", "pyproject.toml", external=True)
session.run("git", "commit", "-m", "Post-release version bump.", external=True)

Expand Down

0 comments on commit f3916e2

Please sign in to comment.