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

Generated release notes & --title argument #384

Merged
merged 3 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
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
40 changes: 12 additions & 28 deletions adabot/circuitpython_library_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
"""
Check if a new release needs to be made, and if so, make it.
"""
import argparse
import subprocess
import logging
from datetime import datetime
import toml
from jinja2 import Template

# Empty RELEASE_TITLE will prompt to ask for a title for each release.
# Set a value here if you want to use the same string for the title of all releases
Expand All @@ -32,7 +32,7 @@ def make_release(new_tag, logger, test_run=False):

if not test_run:
make_release_result = subprocess.getoutput(
f"gh release create {new_tag} -F release_notes.md -t '{new_tag} - {config['RELEASE_TITLE']}'"
f"gh release create {new_tag} --generate-notes -t '{new_tag} - {config['RELEASE_TITLE']}'"
)

if logger is not None:
Expand All @@ -46,29 +46,6 @@ def make_release(new_tag, logger, test_run=False):
)


def create_release_notes(pypi_name):
"""
render the release notes into a md file.
"""
# pylint: disable=line-too-long
RELEASE_NOTES_TEMPLATE = """To use in CircuitPython, simply install the [Adafruit CircuitPython Bundle](https://circuitpython.org/libraries).

To use in CPython, `pip3 install {{ pypi_name }}`.

Read the [docs](https://circuitpython.readthedocs.io/projects/{{ pypi_name }}/en/latest/) for info on how to use it."""

release_notes_template = Template(RELEASE_NOTES_TEMPLATE)

_rendered_template_text = release_notes_template.render(pypi_name=pypi_name)

with open("release_notes.md", "w") as f:
f.write(_rendered_template_text)


if __name__ == "__main__":
create_release_notes("testrepo")


def get_pypi_name():
"""
return the shorthand pypi project name
Expand Down Expand Up @@ -178,6 +155,16 @@ def main_cli():
],
)

parser = argparse.ArgumentParser(
prog="adabot.circuitpython_library_release",
description="Create GitHub releases for CircuitPython Library projects if they "
"contain commits newer than the most recent release.",
)
parser.add_argument("-t", "--title")
args = parser.parse_args()
if args.title is not None:
config["RELEASE_TITLE"] = args.title

def menu_prompt(release_info):
"""
Prompt the user to ask which part of the symantic version should be
Expand Down Expand Up @@ -210,19 +197,16 @@ def menu_prompt(release_info):
logging.info(
"Making a new release with tag: %s", release_info["new_tag_patch"]
)
create_release_notes(get_pypi_name())
make_release(release_info["new_tag_patch"], logging)
elif choice == "2":
logging.info(
"Making a new release with tag: %s", release_info["new_tag_minor"]
)
create_release_notes(get_pypi_name())
make_release(release_info["new_tag_minor"], logging)
elif choice == "3":
logging.info(
"Making a new release with tag: %s", release_info["new_tag_major"]
)
create_release_notes(get_pypi_name())
make_release(release_info["new_tag_major"], logging)
elif choice == "4":
logging.info("Skipping release.")
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ typing-extensions~=4.0
google-auth~=2.13
google-cloud-bigquery~=3.3
toml
jinja2
Loading