55"""
66Check if a new release needs to be made, and if so, make it.
77"""
8+ import argparse
89import subprocess
910import logging
1011from datetime import datetime
1112import toml
12- from jinja2 import Template
1313
1414# Empty RELEASE_TITLE will prompt to ask for a title for each release.
1515# Set a value here if you want to use the same string for the title of all releases
@@ -32,7 +32,7 @@ def make_release(new_tag, logger, test_run=False):
3232
3333 if not test_run :
3434 make_release_result = subprocess .getoutput (
35- f"gh release create { new_tag } -F release_notes.md -t '{ new_tag } - { config ['RELEASE_TITLE' ]} '"
35+ f"gh release create { new_tag } --generate-notes -t '{ new_tag } - { config ['RELEASE_TITLE' ]} '"
3636 )
3737
3838 if logger is not None :
@@ -46,29 +46,6 @@ def make_release(new_tag, logger, test_run=False):
4646 )
4747
4848
49- def create_release_notes (pypi_name ):
50- """
51- render the release notes into a md file.
52- """
53- # pylint: disable=line-too-long
54- RELEASE_NOTES_TEMPLATE = """To use in CircuitPython, simply install the [Adafruit CircuitPython Bundle](https://circuitpython.org/libraries).
55-
56- To use in CPython, `pip3 install {{ pypi_name }}`.
57-
58- Read the [docs](https://circuitpython.readthedocs.io/projects/{{ pypi_name }}/en/latest/) for info on how to use it."""
59-
60- release_notes_template = Template (RELEASE_NOTES_TEMPLATE )
61-
62- _rendered_template_text = release_notes_template .render (pypi_name = pypi_name )
63-
64- with open ("release_notes.md" , "w" ) as f :
65- f .write (_rendered_template_text )
66-
67-
68- if __name__ == "__main__" :
69- create_release_notes ("testrepo" )
70-
71-
7249def get_pypi_name ():
7350 """
7451 return the shorthand pypi project name
@@ -178,6 +155,16 @@ def main_cli():
178155 ],
179156 )
180157
158+ parser = argparse .ArgumentParser (
159+ prog = "adabot.circuitpython_library_release" ,
160+ description = "Create GitHub releases for CircuitPython Library projects if they "
161+ "contain commits newer than the most recent release." ,
162+ )
163+ parser .add_argument ("-t" , "--title" )
164+ args = parser .parse_args ()
165+ if args .title is not None :
166+ config ["RELEASE_TITLE" ] = args .title
167+
181168 def menu_prompt (release_info ):
182169 """
183170 Prompt the user to ask which part of the symantic version should be
@@ -210,19 +197,16 @@ def menu_prompt(release_info):
210197 logging .info (
211198 "Making a new release with tag: %s" , release_info ["new_tag_patch" ]
212199 )
213- create_release_notes (get_pypi_name ())
214200 make_release (release_info ["new_tag_patch" ], logging )
215201 elif choice == "2" :
216202 logging .info (
217203 "Making a new release with tag: %s" , release_info ["new_tag_minor" ]
218204 )
219- create_release_notes (get_pypi_name ())
220205 make_release (release_info ["new_tag_minor" ], logging )
221206 elif choice == "3" :
222207 logging .info (
223208 "Making a new release with tag: %s" , release_info ["new_tag_major" ]
224209 )
225- create_release_notes (get_pypi_name ())
226210 make_release (release_info ["new_tag_major" ], logging )
227211 elif choice == "4" :
228212 logging .info ("Skipping release." )
0 commit comments