Bump the version in CITATION.cff to new_version and date-released to new_date Returns True on success, False on failure
(new_version, new_date)
| 346 | |
| 347 | |
| 348 | def bump_version_citation_cff(new_version, new_date): |
| 349 | """ |
| 350 | Bump the version in CITATION.cff to new_version and date-released to new_date |
| 351 | Returns True on success, False on failure |
| 352 | """ |
| 353 | citation_cff_path = "CITATION.cff" |
| 354 | pattern_version = r"(^\s*version\s*:\s*)([\w.]+)(\s*$)" |
| 355 | pattern_date = r"(^\s*date-released\s*:\s*)([0-9\-]+)(\s*$)" |
| 356 | |
| 357 | with open(citation_cff_path, "r") as f: |
| 358 | content = f.read() |
| 359 | new_content, n_subs = re.subn( |
| 360 | pattern_version, |
| 361 | rf"\g<1>{new_version}\g<3>", |
| 362 | content, |
| 363 | count=1, # replace only the first match |
| 364 | flags=re.MULTILINE, |
| 365 | ) |
| 366 | if n_subs < 1: |
| 367 | print( |
| 368 | f"FAILED to update version in {citation_cff_path}.", |
| 369 | "Please update manually.", |
| 370 | ) |
| 371 | return False |
| 372 | new_content, n_subs = re.subn( |
| 373 | pattern_date, |
| 374 | rf"\g<1>{new_date}\g<3>", |
| 375 | new_content, |
| 376 | count=1, # replace only the first match |
| 377 | flags=re.MULTILINE, |
| 378 | ) |
| 379 | if n_subs < 1: |
| 380 | print( |
| 381 | f"FAILED to update date-released in {citation_cff_path}.", |
| 382 | "Please update manually.", |
| 383 | ) |
| 384 | return False |
| 385 | |
| 386 | with open(citation_cff_path, "w") as f: |
| 387 | f.write(new_content) |
| 388 | print( |
| 389 | f"SUCCESS: Updated version in {citation_cff_path} to {new_version}", |
| 390 | f"and date-released to {new_date}", |
| 391 | ) |
| 392 | return True |
| 393 | |
| 394 | |
| 395 | def bump_version_changelog_md(new_version, new_date): |
no test coverage detected