Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use 'hatch version' instead of manually updating the version #100

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 4 additions & 14 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,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 @@ -196,7 +185,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 @@ -243,7 +234,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)