docs: def main(mode):
      """Tags the current repository
  
      and commits changes to news files
  
      :param mode: ReleaseTarget mode (i.e. beta or prod)
      :type mode: ReleaseTarget
      """
      # see:
      # https://packaging.python.org/tutorials/distributing-packages/#uploading-your-project-to-pypi
      version = subprocess.check_output(['python', 'setup.py', '--version']).decode().strip()
  
      twine_repo = os.getenv('TWINE_REPOSITORY_URL') or os.getenv('TWINE_REPOSITORY')
      print('tagging and releasing %r as a %s release to %s as Twine user %s' % (
          version,
          mode.name,
          twine_repo,
          os.getenv('TWINE_USERNAME')
      ))
  
      print('python - preparing environment')
      subprocess.check_call(['apk', 'update'])
      subprocess.check_call(['apk', 'add', 'git'])
      # Pin twine to 1.11 due to https://github.com/pypa/twine/issues/404
      subprocess.check_call(['pip', 'install', 'twine<1.12'])
      url = subprocess.check_output(['git', 'remote', 'get-url', 'origin'])
      new_url = git_url_ssh_to_https(url.decode())
      subprocess.check_call(['git', 'remote', 'set-url', 'origin', new_url])
      branch_spec = 'origin/%s' % os.getenv('CIRCLE_BRANCH')
      subprocess.check_call(['git', 'branch', '--set-upstream-to', branch_spec])
      subprocess.check_call(['git', 'fetch', '--tags', '--force'])
  
      # tags
      subprocess.check_call(['git', 'tag', '-a', version, '-m', 'release %s' % version])
      subprocess.check_call(['git', 'tag', '-f', 'latest'])
      if mode == release_target_map['prod']:
          print('git - pushing %s tags' % mode.name)
          subprocess.check_call(['git', 'push', '-f', 'origin', '--tags'])
  
      print('git - add changes')
      subprocess.check_call(['git', 'add', 'src/mbed_cloud/_version.py'])
      subprocess.check_call(['git', 'add', 'CHANGELOG.rst'])
      subprocess.check_call(['git', 'add', 'docs/news/*'])
      message = ':checkered_flag: :newspaper: releasing version %s\n[skip ci]' % version
      subprocess.check_call(['git', 'commit', '-m', message])
  
      if mode == release_target_map['prod']:
          print('git - pushing %s changelog commit' % mode.name)
          subprocess.check_call(['git', 'push', 'origin'])
  
      print('pypi - uploading')
      subprocess.check_call(['python', '-m', 'twine', 'upload', mode.bundle])
      print('pypi - uploading successful')