Skip to content

Commit

Permalink
Minor changes to release script and workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
GjjvdBurg committed Dec 7, 2024
1 parent ae043c9 commit d0c3602
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ jobs:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
name: artifact
path: dist/

- name: Sign the dists with Sigstore
Expand Down
45 changes: 33 additions & 12 deletions make_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

from pathlib import Path

from typing import Dict
from typing import Optional

import colorama
Expand Down Expand Up @@ -121,15 +122,31 @@ def get_last_release_candidate_tag(version: str):
return versions[-1]


def read_changelog_section(context: Dict[str, str]) -> str:
next_version = context["next_version"]
section_lines = []
record = False
with open(CHANGELOG_FILENAME, "r") as fileobj:
for line in fileobj:
if line.startswith(f"## Version {next_version}"):
section_lines.append(line)
record = True
continue
if record and line.startswith("## Version"):
record = False
break
elif record:
section_lines.append(line)
return "".join(section_lines)


def build_release_message(context, commit: bool = False) -> str:
prefix = "bump: " if commit else ""
message = (
f"{prefix}{context['pkgname'].capitalize()} Release "
f"{context['next_version']}"
)
# prefix = "bump: " if commit else ""
prefix = ""
message = f"{prefix}{PACKAGE_NICE_NAME} Release {context['next_version']}"
message += "\n"
message += "\n"
message += context["changelog_update"]
message += read_changelog_section(context)
return message


Expand Down Expand Up @@ -210,8 +227,10 @@ def post(self, context):

class UpdateChangelog(Step):
def action(self, context):
self.instruct(f"Update change log for version {context['version']}")
self.print_run("vi CHANGELOG.md")
self.instruct(
f"Update change log for version {context['next_version']}"
)
self.print_command("vi CHANGELOG.md")


class UpdateReadme(Step):
Expand Down Expand Up @@ -259,7 +278,7 @@ def action(self, context):
f"cd {parent} && python -m venv {tmpvenv} && source {tmpvenv}"
"/bin/activate && pip install --no-cache-dir --index-url "
"https://test.pypi.org/simple/ --extra-index-url "
f"https://pypi.org/simple {context['pkgname']}=="
f"https://pypi.org/simple {context['pkgname']}[full]=="
f"{context['next_version']}"
)
context["tmpvenv"] = tmpvenv
Expand All @@ -271,7 +290,7 @@ def action(self, context):
f"Ensuring that the package has version {context['next_version']}"
)
version = self.execute(
f"source {context['tmpvenv']}/bin/activate && veld -V",
f"source {context['tmpvenv']}/bin/activate && clevercsv -V",
silent=True,
confirm=False,
)
Expand Down Expand Up @@ -347,6 +366,8 @@ def action(self, context):
self.instruct("Add Changelog & Readme to git")
self.execute("git add CHANGELOG.md", confirm=False)
self.execute("git add README.md", confirm=False)
self.execute("git add docs/CHANGELOG.rst", confirm=False)
self.execute("git add man/", confirm=False)
self.instruct("Going to commit with the following message:")

commit_message = build_release_message(context, commit=True)
Expand Down Expand Up @@ -397,8 +418,8 @@ def main(target=None):
procedure = [
("gittomaster", GitToMaster()),
("clean1", MakeClean()),
("docs1", MakeDocs()),
("man1", MakeMan()),
# ("docs1", MakeDocs()),
# ("man1", MakeMan()),
("runtests", RunTests()),
# trigger CI to run tests on all platforms
("push1", PushToGitHub()),
Expand Down

0 comments on commit d0c3602

Please sign in to comment.