code: def add_release_to_changelog(version):
      
      temp_file = changelog_file().parent / ("~" + changelog_file().name)
      now = datetime.today()
      release_added = False
      with open(str(temp_file), 'w') as g:
          with open(str(changelog_file()), 'r') as f:
              for line in f:
                  list_match = list_match_re.match(line)
                  if list_match and not release_added:
                      release_line = "{}{} :release:`{} <{}-{:02}-{:02}>`".format(
                                          list_match.group("leading"),
                                          list_match.group("mark"),
                                          version, now.year, now.month, now.day)
                      print(release_line, file=g)
                      release_added = True
                  print(line, file=g, end="")
              if not release_added:
                  release_line = "{}{} :release:`{} <{}-{:02}-{:02}>`".format(
                                  " ", "-", version, now.year, now.month, now.day)
                  print(release_line, file=g)
          print('', file=g)  # add a blank line at the end of the file
      shutil.copyfile(str(temp_file), str(changelog_file()))
      os.remove(str(temp_file))
docs: Add release line at the top of the first list it finds
  
      Assumes your changelog in managed with `releases`