Skip to content

Commit

Permalink
Merge pull request #384 from FoamyGuy/generated_release_notes
Browse files Browse the repository at this point in the history
Generated release notes & --title argument
  • Loading branch information
tannewt authored Oct 10, 2024
2 parents 4e0086b + dc0b9fa commit d9386e4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 29 deletions.
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 @@ -18,4 +18,3 @@ typing-extensions~=4.0
google-auth~=2.13
google-cloud-bigquery~=3.3
toml
jinja2

0 comments on commit d9386e4

Please sign in to comment.