|
40 | 40 | PATCH - Whether or not this a patch release. e.g. PATCH=1 or PATCH=0 |
41 | 41 | PRINT - Whether or not the release notes should be printed to CLI or be used to create a Github release. Default is 0 e.g. PRINT=1 or PRINT=0 |
42 | 42 | NOTEBOOK - Whether or not to create a notebook in staging. Note this only works for RC1s since those are usually what we create notebooks for. |
43 | | - Default is 0 e.g. NOTEBOOK=0 or NOTEBOOK=1 |
| 43 | + Default is 1 for RC1s, 0 for everything else e.g. NOTEBOOK=0 or NOTEBOOK=1 |
44 | 44 | Examples: |
45 | 45 | Generate release notes and staging testing notebook for next release candidate version of 1.11: `BASE=1.11 RC=1 NOTEBOOK=1 python release.py` |
46 | 46 |
|
@@ -234,7 +234,7 @@ def setup_gh(): |
234 | 234 | def create_notebook(dd_repo, name, rn, base, rc, patch): |
235 | 235 | dd_api_key = os.getenv("DD_API_KEY_STAGING") |
236 | 236 | dd_app_key = os.getenv("DD_APP_KEY_STAGING") |
237 | | - if not dd_api_key and dd_app_key: |
| 237 | + if not dd_api_key or not dd_app_key: |
238 | 238 | raise ValueError( |
239 | 239 | "We need DD_API_KEY_STAGING and DD_APP_KEY_STAGING values. Please follow the instructions in the script." |
240 | 240 | ) |
@@ -282,12 +282,20 @@ def create_notebook(dd_repo, name, rn, base, rc, patch): |
282 | 282 | for file in files: |
283 | 283 | filename = file.filename |
284 | 284 | if filename.startswith("releasenotes/notes/"): |
285 | | - # we need to make another api call to get ContentFile object so we can see what's in there |
286 | | - rn_file_content = dd_repo.get_contents(filename).decoded_content.decode("utf8") |
287 | | - # try to grab a good portion of the release note for us to use to insert in our reno release notes |
288 | | - # this is a bit hacky, will only attach to one section if you have multiple sections in a release note |
289 | | - # (e.g. a features and a fix section): |
290 | | - # for example: https://github.com/DataDog/dd-trace-py/blob/1.x/releasenotes/notes/asm-user-id-blocking-5048b1cef07c80fd.yaml # noqa |
| 285 | + try: |
| 286 | + # we need to make another api call to get ContentFile object so we can see what's in there |
| 287 | + rn_file_content = dd_repo.get_contents(filename).decoded_content.decode("utf8") |
| 288 | + # try to grab a good portion of the release note for us to use to insert in our reno release notes |
| 289 | + # this is a bit hacky, will only attach to one section if you have multiple sections |
| 290 | + # in a release note |
| 291 | + # (e.g. a features and a fix section): |
| 292 | + # for example: https://github.com/DataDog/dd-trace-py/blob/1.x/releasenotes/notes/asm-user-id-blocking-5048b1cef07c80fd.yaml # noqa |
| 293 | + except Exception: |
| 294 | + print( |
| 295 | + """File contents were not obtained for {file} in commit {commit}.""" |
| 296 | + """It's likely this file was deleted in a PR""".format(file=file, commit=commit) |
| 297 | + ) |
| 298 | + continue |
291 | 299 | try: |
292 | 300 | rn_piece = re.findall( |
293 | 301 | r" - \|\n ((.|\n)*)\n(((issues|features|upgrade|deprecations|fixes|other):\n)|.*)", |
@@ -426,7 +434,7 @@ def create_notebook(dd_repo, name, rn, base, rc, patch): |
426 | 434 | dd_repo = setup_gh() |
427 | 435 | name, rn = create_release_draft(dd_repo, base, rc, patch) |
428 | 436 |
|
429 | | - if os.getenv("NOTEBOOK"): |
| 437 | + if os.getenv("NOTEBOOK", 1): |
430 | 438 | if rc: |
431 | 439 | print("Creating Notebook") |
432 | 440 | create_notebook(dd_repo, name, rn, base, rc, patch) |
|
0 commit comments