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 0d1d8d5 commit a8b59eb
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 @@ -125,17 +125,6 @@ def typing(session: nox.Session):
)


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 @@ -192,7 +181,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 @@ -239,7 +230,6 @@ 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)

0 comments on commit a8b59eb

Please sign in to comment.