5
5
"""
6
6
Check if a new release needs to be made, and if so, make it.
7
7
"""
8
+ import argparse
8
9
import subprocess
9
10
import logging
10
11
from datetime import datetime
11
12
import toml
12
- from jinja2 import Template
13
13
14
14
# Empty RELEASE_TITLE will prompt to ask for a title for each release.
15
15
# 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):
32
32
33
33
if not test_run :
34
34
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' ]} '"
36
36
)
37
37
38
38
if logger is not None :
@@ -46,29 +46,6 @@ def make_release(new_tag, logger, test_run=False):
46
46
)
47
47
48
48
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
-
72
49
def get_pypi_name ():
73
50
"""
74
51
return the shorthand pypi project name
@@ -178,6 +155,16 @@ def main_cli():
178
155
],
179
156
)
180
157
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
+
181
168
def menu_prompt (release_info ):
182
169
"""
183
170
Prompt the user to ask which part of the symantic version should be
@@ -210,19 +197,16 @@ def menu_prompt(release_info):
210
197
logging .info (
211
198
"Making a new release with tag: %s" , release_info ["new_tag_patch" ]
212
199
)
213
- create_release_notes (get_pypi_name ())
214
200
make_release (release_info ["new_tag_patch" ], logging )
215
201
elif choice == "2" :
216
202
logging .info (
217
203
"Making a new release with tag: %s" , release_info ["new_tag_minor" ]
218
204
)
219
- create_release_notes (get_pypi_name ())
220
205
make_release (release_info ["new_tag_minor" ], logging )
221
206
elif choice == "3" :
222
207
logging .info (
223
208
"Making a new release with tag: %s" , release_info ["new_tag_major" ]
224
209
)
225
- create_release_notes (get_pypi_name ())
226
210
make_release (release_info ["new_tag_major" ], logging )
227
211
elif choice == "4" :
228
212
logging .info ("Skipping release." )
0 commit comments