def update_history(new_version: str, dry_run: bool, force_update: bool) -> None:
    """Generate release notes and prepend them to HISTORY.md."""
    history_path = ROOT_DIR / HISTORY_FILE
    history_content = history_path.read_text(encoding='utf8')

    # use ( to avoid matching beta versions
    if f'## v{new_version} (' in history_content and not force_update:
        warnings.warn(
            f'WARNING: v{new_version} already in history, {HISTORY_FILE} not updated. \n'
            'Use --force or -f to update the history file anyway.'
        )
        return

    date_today_str = f'{date.today():%Y-%m-%d}'
    title = f'v{new_version} ({date_today_str})'
    notes = get_notes(new_version)
    new_chunk = (
        f'## {title}\n\n'
        f'[GitHub release](https://github.com/{REPO}/releases/tag/v{new_version})\n\n'
        f'{notes}\n\n'
    )
    if dry_run:
        print(f"Would add the following to {history_path}:\n{new_chunk}")
    history = new_chunk + history_content

    if not dry_run:
        history_path.write_text(history)
        print(f'\nSUCCESS: added "{title}" section to {history_path.relative_to(ROOT_DIR)}')

    citation_path = ROOT_DIR / 'CITATION.cff'
    citation_text = citation_path.read_text()

    is_release_version = not ('a' in new_version or 'b' in new_version)
    if not is_release_version:
        version_typ = 'alpha' if 'a' in new_version else 'beta'
        warnings.warn(
            f'WARNING: not updating CITATION.cff because version is {version_typ} version {new_version}'
        )
        return
    else:
        citation_text = re.sub(r'(?<=\nversion: ).*', f'v{new_version}', citation_text)
        citation_text = re.sub(r'(?<=date-released: ).*', date_today_str, citation_text)
    if dry_run:
        print(
            f'Would update version=v{new_version} and date-released={date_today_str} in '
            f'{citation_path.relative_to(ROOT_DIR)}'
        )
        print(f'Updated content:\n{citation_text}')

    else:
        citation_path.write_text(citation_text)
        print(
            f'SUCCESS: updated version=v{new_version} and date-released={date_today_str} '
            f'in {citation_path.relative_to(ROOT_DIR)}'
        )
Generate release notes and prepend them to HISTORY.md.
release/prepare.py