Skip to content

Commit 4e067eb

Browse files
committed
Fix release script
1 parent 4c34830 commit 4e067eb

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

tasks/release.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,11 @@ def _render_log(ctx=None, version=None):
5050
if ctx and not version:
5151
version = find_version(ctx)
5252

53-
# Towncrier expects --version to be a flag to show its own version
54-
# For setting the project version, we need to use a positional argument
55-
cmd = ["towncrier", "--draft"]
53+
# Use towncrier build --draft with --version flag
54+
cmd = ["towncrier", "build", "--draft"]
5655
if version:
57-
# Add version as a positional argument
58-
cmd.append(version)
56+
# Add version using the --version flag
57+
cmd.extend(["--version", version])
5958

6059
rendered = subprocess.check_output(cmd).decode("utf-8")
6160
return rendered
@@ -82,7 +81,7 @@ def release(
8281
tag_content = _render_log(ctx, version)
8382
if dry_run:
8483
# Use the correct version when generating the draft
85-
ctx.run(f"towncrier --draft {version} > CHANGELOG.draft.md")
84+
ctx.run(f"towncrier build --draft --version {version} > CHANGELOG.draft.md")
8685
log("would remove: news/*")
8786
log("would remove: CHANGELOG.draft.md")
8887
log("would update: pipenv/pipenv.1")
@@ -91,11 +90,11 @@ def release(
9190
if pre:
9291
log("generating towncrier draft...")
9392
# Use the correct version when generating the draft
94-
ctx.run(f"towncrier --draft {version} > CHANGELOG.draft.md")
93+
ctx.run(f"towncrier build --draft --version {version} > CHANGELOG.draft.md")
9594
ctx.run(f"git add {get_version_file(ctx).as_posix()}")
9695
else:
9796
# Use the correct version when generating the changelog
98-
ctx.run(f"towncrier {version}")
97+
ctx.run(f"towncrier build --version {version}")
9998
ctx.run(f"git add CHANGELOG.md news/ {get_version_file(ctx).as_posix()}")
10099
log("removing changelog draft if present")
101100
draft_changelog = pathlib.Path("CHANGELOG.draft.md")
@@ -203,9 +202,9 @@ def generate_changelog(ctx, commit=False, draft=False):
203202
if draft:
204203
commit = False
205204
log("Writing draft to file...")
206-
ctx.run(f"towncrier --draft --name={version} > CHANGELOG.draft.md")
205+
ctx.run(f"towncrier build --draft --version {version} > CHANGELOG.draft.md")
207206
else:
208-
ctx.run(f"towncrier --name={version}")
207+
ctx.run(f"towncrier build --version {version}")
209208
if commit:
210209
log("Committing...")
211210
ctx.run("git add CHANGELOG.md")

0 commit comments

Comments
 (0)