예제 #1
0
def main():

  parser = argparse.ArgumentParser(
    description='Bump version numbers. Must specify at least one of the three'
               +' options:\n'
               +'   --bump=patch to increment patch version, or\n'
               +'   --stable to promote current beta to stable, or\n'
               +'   --version={version} to set version number directly\n'
               +'Note that you can use both --bump and --stable '
               +'simultaneously.',
               formatter_class=argparse.RawTextHelpFormatter
  )
  parser.add_argument(
    '--version',
    default=None,
    dest='new_version',
    help='new version number'
  )
  parser.add_argument(
    '--bump',
    action='store',
    default=None,
    dest='bump',
    help='increment [stable | beta | nightly]'
  )
  parser.add_argument(
    '--dry-run',
    action='store_true',
    default= False,
    dest='dry_run',
    help='just to check that version number is correct'
  )

  args = parser.parse_args()
  curr_version = get_electron_version()

  if args.bump not in ['stable', 'beta', 'nightly']:
    raise Exception('bump must be set to either stable, beta or nightly')

  if is_nightly(curr_version):
    if args.bump == 'nightly':
      version = get_next_nightly(curr_version)
    elif args.bump == 'beta':
      version = get_next_beta(curr_version)
    elif args.bump == 'stable':
      version = get_next_stable_from_pre(curr_version)
    else:
      not_reached()
  elif is_beta(curr_version):
    if args.bump == 'nightly':
      version = get_next_nightly(curr_version)
    elif args.bump == 'beta':
      version = get_next_beta(curr_version)
    elif args.bump == 'stable':
      version = get_next_stable_from_pre(curr_version)
    else:
      not_reached()
  elif is_stable(curr_version):
    if args.bump == 'nightly':
      version = get_next_nightly(curr_version)
    elif args.bump == 'beta':
      raise Exception("You can\'t bump to a beta from stable")
    elif args.bump == 'stable':
      version = get_next_stable_from_stable(curr_version)
    else:
      not_reached()
  else:
    raise Exception("Invalid current version: " + curr_version)

  if args.new_version == None and args.bump == None and args.stable == False:
    parser.print_help()
    return 1

  versions = clean_parse_version(version)
  suffix = ''
  if '-' in version:
    suffix = '-' + version.split('-')[1]
    versions[3] = parse_version(version)[3]
  version = version.split('-')[0]

  if args.dry_run:
    print 'new version number would be: {0}\n'.format(version + suffix)
    return 0

  with scoped_cwd(SOURCE_ROOT):
    update_electron_gyp(version, suffix)
    update_win_rc(version, versions)
    update_version_h(versions, suffix)
    update_info_plist(version)
    update_package_json(version, suffix)
    tag_version(version, suffix)

  print 'Bumped to version: {0}'.format(version + suffix)
예제 #2
0
def main():

  parser = argparse.ArgumentParser(
    description='Bump version numbers. Must specify at least one of the three'
               +' options:\n'
               +'   --bump=patch to increment patch version, or\n'
               +'   --stable to promote current beta to stable, or\n'
               +'   --version={version} to set version number directly\n'
               +'Note that you can use both --bump and --stable '
               +'simultaneously.',
               formatter_class=argparse.RawTextHelpFormatter
  )
  parser.add_argument(
    '--version',
    default=None,
    dest='new_version',
    help='new version number'
  )
  parser.add_argument(
    '--bump',
    action='store',
    default=None,
    dest='bump',
    help='increment [stable | beta | nightly]'
  )
  parser.add_argument(
    '--dry-run',
    action='store_true',
    default= False,
    dest='dry_run',
    help='just to check that version number is correct'
  )

  args = parser.parse_args()
  curr_version = get_electron_version()

  if args.bump not in ['stable', 'beta', 'nightly']:
    raise Exception('bump must be set to either stable, beta or nightly')

  if is_nightly(curr_version):
    if args.bump == 'nightly':
      version = get_next_nightly(curr_version)
    elif args.bump == 'beta':
      version = get_next_beta(curr_version)
    elif args.bump == 'stable':
      version = get_next_stable_from_pre(curr_version)
    else:
      not_reached()
  elif is_beta(curr_version):
    if args.bump == 'nightly':
      version = get_next_nightly(curr_version)
    elif args.bump == 'beta':
      version = get_next_beta(curr_version)
    elif args.bump == 'stable':
      version = get_next_stable_from_pre(curr_version)
    else:
      not_reached()
  elif is_stable(curr_version):
    if args.bump == 'nightly':
      version = get_next_nightly(curr_version)
    elif args.bump == 'beta':
      raise Exception("You can\'t bump to a beta from stable")
    elif args.bump == 'stable':
      version = get_next_stable_from_stable(curr_version)
    else:
      not_reached()
  else:
    raise Exception("Invalid current version: " + curr_version)

  if args.new_version is None and args.bump is None and not args.stable:
    parser.print_help()
    return 1

  versions = clean_parse_version(version)
  suffix = ''
  if '-' in version:
    suffix = '-' + version.split('-')[1]
    versions[3] = parse_version(version)[3]
  version = version.split('-')[0]

  if args.dry_run:
    print 'new version number would be: {0}\n'.format(version + suffix)
    return 0

  with scoped_cwd(SOURCE_ROOT):
    update_version(version, suffix)
    update_win_rc(version, versions, args.bump == "nightly")
    update_version_h(versions, suffix)
    update_info_plist(version)
    update_package_json(version, suffix)
    tag_version(version, suffix)

  print 'Bumped to version: {0}'.format(version + suffix)