def create_version(target_gen_dir): version_path = os.path.abspath(os.path.join(CHROMIUM_ROOT, target_gen_dir, '..', 'version')) with open(version_path, 'w') as version_file: version_file.write(get_brave_version()) version_h_path = os.path.join(CHROMIUM_ROOT, target_gen_dir, 'brave', 'version.h') with open(version_h_path, 'w') as version_h_file: # Strip off the v prefix. version = get_brave_version()[1:] version_h_file.write(''.join(['#define BRAVE_BROWSER_VERSION "', version, '"']))
def main(): repo = GitHub(get_env_var('GITHUB_TOKEN')).repos(BRAVE_REPO) release = get_draft(repo, get_brave_version()) commit_tag = get_commit_tag(get_raw_version()) print("[INFO] Releasing {}".format(release['tag_name'])) publish_release(repo, release['id'], get_tag(), commit_tag)
def parse_args(): parser = argparse.ArgumentParser(description='upload distribution file') parser.add_argument('--force', action='store_true', help='Overwrite files in ' 'destination draft on upload.') parser.add_argument('-v', '--version', help='Specify the version', default=get_brave_version()) return parser.parse_args()
def parse_args(): parser = argparse.ArgumentParser(description='upload distribution file') parser.add_argument('-v', '--version', help='Specify the version', default=get_brave_version()) parser.add_argument('-p', '--publish-release', help='Publish the release', action='store_true') parser.add_argument('-d', '--dist-url', help='The base dist url for download', default=DIST_URL) return parser.parse_args()
def main(): if len(sys.argv) != 2 or sys.argv[1] == '-h': print 'Usage: bump-version.py [<version> | major | minor | patch]' return 1 option = sys.argv[1] increments = ['major', 'minor', 'patch'] if option in increments: version = get_brave_version() versions = parse_version(version.split('-')[0]) versions = increase_version(versions, increments.index(option)) chrome = get_chrome_version() else: versions = parse_version(option) chrome = versions[3] version = '.'.join(versions[:3]) version = version + '+' + chrome with scoped_cwd(SOURCE_ROOT): update_package_json(version) tag_version(version)
def main(): args = parse_args() print('[INFO] Running upload...') # Enable urllib3 debugging output if os.environ.get('DEBUG_HTTP_HEADERS') == 'true': logging.basicConfig(level=logging.DEBUG) logging.getLogger("urllib3").setLevel(logging.DEBUG) logging.debug( "DEBUG_HTTP_HEADERS env var is enabled, logging HTTP headers") debug_requests_on() # BRAVE_REPO is defined in lib/helpers.py for now repo = GitHub(get_env_var('GITHUB_TOKEN')).repos(BRAVE_REPO) tag = get_brave_version() release = get_release(repo, tag, allow_published_release_updates=False) if not release: print("[INFO] No existing release found, creating new " "release for this upload") release = create_release_draft(repo, tag) print('[INFO] Uploading release {}'.format(release['tag_name'])) # Upload Brave with GitHub Releases API. upload_brave(repo, release, os.path.join(dist_dir(), DIST_NAME), force=args.force) upload_brave(repo, release, os.path.join(dist_dir(), SYMBOLS_NAME), force=args.force) # if PLATFORM == 'darwin': # upload_brave(repo, release, os.path.join(dist_dir(), DSYM_NAME)) # elif PLATFORM == 'win32': # upload_brave(repo, release, os.path.join(dist_dir(), PDB_NAME)) pkgs = get_brave_packages(output_dir(), release_channel(), get_raw_version()) if PLATFORM == 'darwin': for pkg in pkgs: upload_brave(repo, release, os.path.join(output_dir(), pkg), force=args.force) elif PLATFORM == 'win32': if get_target_arch() == 'x64': upload_brave(repo, release, os.path.join(output_dir(), 'brave_installer.exe'), 'brave_installer-x64.exe', force=args.force) for pkg in pkgs: upload_brave(repo, release, os.path.join(output_dir(), pkg), force=args.force) else: upload_brave(repo, release, os.path.join(output_dir(), 'brave_installer.exe'), 'brave_installer-ia32.exe', force=args.force) for pkg in pkgs: upload_brave(repo, release, os.path.join(output_dir(), pkg), force=args.force) else: if get_target_arch() == 'x64': for pkg in pkgs: upload_brave(repo, release, os.path.join(output_dir(), pkg), force=args.force) else: upload_brave(repo, release, os.path.join(output_dir(), 'brave-i386.rpm'), force=args.force) upload_brave(repo, release, os.path.join(output_dir(), 'brave-i386.deb'), force=args.force) # mksnapshot = get_zip_name('mksnapshot', get_brave_version()) # upload_brave(repo, release, os.path.join(dist_dir(), mksnapshot)) # if PLATFORM == 'win32' and not tag_exists: # # Upload PDBs to Windows symbol server. # run_python_script('upload-windows-pdb.py') if os.environ.get('DEBUG_HTTP_HEADERS') == 'true': debug_requests_off() print('[INFO] Finished upload')
import requests import re import shutil import subprocess import sys import tempfile from lib.config import (PLATFORM, get_target_arch, get_env_var, get_zip_name, product_name, project_name, SOURCE_ROOT, dist_dir, output_dir, get_brave_version, get_raw_version) from lib.util import execute, parse_version, scoped_cwd, s3put from lib.helpers import * from lib.github import GitHub DIST_NAME = get_zip_name(project_name(), get_brave_version()) SYMBOLS_NAME = get_zip_name(project_name(), get_brave_version(), 'symbols') DSYM_NAME = get_zip_name(project_name(), get_brave_version(), 'dsym') PDB_NAME = get_zip_name(project_name(), get_brave_version(), 'pdb') if os.environ.get('DEBUG_HTTP_HEADERS') == 'true': try: from http.client import HTTPConnection # python3 except ImportError: from httplib import HTTPConnection # python2 def main(): args = parse_args() print('[INFO] Running upload...')
def main(): args = parse_args() if not args.publish_release: build_version = get_brave_version() if not get_brave_version().startswith(build_version): error = 'Tag name ({0}) should match build version ({1})\n'.format( get_brave_version(), build_version) sys.stderr.write(error) sys.stderr.flush() return 1 github = GitHub(auth_token()) releases = github.repos(BRAVE_REPO).releases.get() tag_exists = False for release in releases: if not release['draft'] and release['tag_name'] == args.version: tag_exists = True break release = create_or_get_release_draft(github, releases, args.version, tag_exists) if args.publish_release: # Create and upload the Brave SHASUMS*.txt release_brave_checksums(github, release) # Press the publish button. # publish_release(github, release['id']) # Do not upload other files when passed "-p". return # Upload Brave with GitHub Releases API. upload_brave(github, release, os.path.join(dist_dir(), DIST_NAME)) upload_brave(github, release, os.path.join(dist_dir(), SYMBOLS_NAME)) # if PLATFORM == 'darwin': # upload_brave(github, release, os.path.join(dist_dir(), DSYM_NAME)) # elif PLATFORM == 'win32': # upload_brave(github, release, os.path.join(dist_dir(), PDB_NAME)) # Upload chromedriver and mksnapshot. chromedriver = get_zip_name('chromedriver', get_chromedriver_version()) upload_brave(github, release, os.path.join(dist_dir(), chromedriver)) if PLATFORM == 'darwin': upload_brave(github, release, os.path.join(output_dir(), 'Brave.dmg')) elif PLATFORM == 'win32': if get_target_arch() == 'x64': upload_brave(github, release, os.path.join(output_dir(), 'brave_installer.exe'), 'brave_installer-x64.exe') else: upload_brave(github, release, os.path.join(output_dir(), 'brave_installer.exe'), 'brave_installer-ia32.exe') # TODO: Enable after linux packaging lands #else: #if get_target_arch() == 'x64': #upload_brave(github, release, os.path.join(output_dir(), 'brave-x86_64.rpm')) #upload_brave(github, release, os.path.join(output_dir(), 'brave-amd64.deb')) #else: #upload_brave(github, release, os.path.join(output_dir(), 'brave-i386.rpm')) #upload_brave(github, release, os.path.join(output_dir(), 'brave-i386.deb')) # mksnapshot = get_zip_name('mksnapshot', get_brave_version()) # upload_brave(github, release, os.path.join(dist_dir(), mksnapshot)) # if PLATFORM == 'win32' and not tag_exists: # # Upload PDBs to Windows symbol server. # run_python_script('upload-windows-pdb.py') versions = parse_version(args.version) version = '.'.join(versions[:3])
def release_brave_checksums(github, release): checksums = run_python_script('merge-brave-checksums.py', '-v', get_brave_version()) upload_io_to_github(github, release, 'SHASUMS256.txt', StringIO(checksums.decode('utf-8')), 'text/plain')
def main(): args = parse_args() print('[INFO] Running upload...') # Repo is defined in lib/helpers.py for now repo = GitHub(get_env_var('GITHUB_TOKEN')).repos(BRAVE_REPO) tag = get_brave_version() release = get_draft(repo, tag) if not release: print( "[INFO] No existing release found, creating new release for this upload" ) release = create_release_draft(repo, tag) print('[INFO] Uploading release {}'.format(release['tag_name'])) # Upload Brave with GitHub Releases API. upload_brave(repo, release, os.path.join(dist_dir(), DIST_NAME), force=args.force) upload_brave(repo, release, os.path.join(dist_dir(), SYMBOLS_NAME), force=args.force) # if PLATFORM == 'darwin': # upload_brave(repo, release, os.path.join(dist_dir(), DSYM_NAME)) # elif PLATFORM == 'win32': # upload_brave(repo, release, os.path.join(dist_dir(), PDB_NAME)) # Upload chromedriver and mksnapshot. chromedriver = get_zip_name('chromedriver', get_chromedriver_version()) upload_brave(repo, release, os.path.join(dist_dir(), chromedriver), force=args.force) pkgs = yield_brave_packages(output_dir(), release_channel(), get_raw_version()) if PLATFORM == 'darwin': for pkg in pkgs: upload_brave(repo, release, os.path.join(output_dir(), pkg), force=args.force) elif PLATFORM == 'win32': if get_target_arch() == 'x64': upload_brave(repo, release, os.path.join(output_dir(), 'brave_installer.exe'), 'brave_installer-x64.exe', force=args.force) else: upload_brave(repo, release, os.path.join(output_dir(), 'brave_installer.exe'), 'brave_installer-ia32.exe', force=args.force) else: if get_target_arch() == 'x64': for pkg in pkgs: upload_brave(repo, release, os.path.join(output_dir(), pkg), force=args.force) else: upload_brave(repo, release, os.path.join(output_dir(), 'brave-i386.rpm'), force=args.force) upload_brave(repo, release, os.path.join(output_dir(), 'brave-i386.deb'), force=args.force) # mksnapshot = get_zip_name('mksnapshot', get_brave_version()) # upload_brave(repo, release, os.path.join(dist_dir(), mksnapshot)) # if PLATFORM == 'win32' and not tag_exists: # # Upload PDBs to Windows symbol server. # run_python_script('upload-windows-pdb.py') versions = parse_version(args.version) version = '.'.join(versions[:3]) print('[INFO] Finished upload')
def download_from_github(args, logging): file_list = [] # BRAVE_REPO defined in helpers.py repo = GitHub(get_env_var('GITHUB_TOKEN')).repos(BRAVE_REPO) if args.tag: tag_name = args.tag else: tag_name = get_brave_version() release = None releases = get_releases_by_tag(repo, tag_name, include_drafts=True) if releases: if len(releases) > 1: exit("Error: More than 1 release exists with the tag: \'{}\'".format(tag_name)) release = releases[0] for asset in release['assets']: if re.match(r'.*\.dmg$', asset['name']) \ or re.match(r'brave_installer.*\.exe$', asset['name']): filename = asset['name'] asset_url = asset['url'] if args.debug: logging.debug("GitHub asset_url: {}".format( asset_url + '/' + filename)) # Instantiate new requests session, versus reusing the repo session above. # Headers was likely being reused in that session, and not allowing us # to set the Accept header to the below. headers = {'Accept': 'application/octet-stream'} asset_auth_url = asset_url + '?access_token=' + \ os.environ.get('BRAVE_GITHUB_TOKEN') if args.debug: # disable urllib3 logging for this session to avoid showing # access_token in logs logging.getLogger("urllib3").setLevel(logging.WARNING) r = requests.get(asset_auth_url, headers=headers, stream=True) if args.debug: logging.getLogger("urllib3").setLevel(logging.DEBUG) with open(filename, 'wb') as f: for chunk in r.iter_content(chunk_size=1024): if chunk: f.write(chunk) logging.debug( "Requests Response status_code: {}".format(r.status_code)) if r.status_code == 200: file_list.append('./' + filename) else: logging.debug( "Requests Response status_code != 200: {}".format(r.status_code)) if len(file_list) < 3: logging.error( "Cannot get all 3 install files from Github! (\'*.dmg\', \'brave_installer-x64.exe\'," " \'brave-installer-ia32.exe\')") remove_github_downloaded_files(file_list, logging) exit(1) return file_list
def download_from_github(args, logging): file_list = [] # BRAVE_REPO defined in helpers.py repo = GitHub(get_env_var('GITHUB_TOKEN')).repos(BRAVE_REPO) if args.tag: tag_name = args.tag else: tag_name = get_brave_version() release = None releases = get_releases_by_tag(repo, tag_name, include_drafts=True) if releases: if len(releases) > 1: exit("Error: More than 1 release exists with the tag: \'{}\'". format(tag_name)) release = releases[0] else: exit("Error: Did not get the release \'{}\' from Github.".format( tag_name)) found_assets_in_github_release = {} for asset in release['assets']: if re.match(r'.*\.dmg$', asset['name']): if args.uploaded: if not args.platform: args.platform = [] args.platform.append('darwin') found_assets_in_github_release['darwin'] = {} found_assets_in_github_release['darwin']['name'] = asset['name'] found_assets_in_github_release['darwin']['url'] = asset['url'] elif re.match(r'brave_installer-ia32\.exe$', asset['name']): if args.uploaded: if not args.platform: args.platform = [] args.platform.append('win32') found_assets_in_github_release['win32'] = {} found_assets_in_github_release['win32']['name'] = asset['name'] found_assets_in_github_release['win32']['url'] = asset['url'] elif re.match(r'brave_installer-x64\.exe$', asset['name']): if args.uploaded: if not args.platform: args.platform = [] args.platform.append('win64') found_assets_in_github_release['win64'] = {} found_assets_in_github_release['win64']['name'] = asset['name'] found_assets_in_github_release['win64']['url'] = asset['url'] logging.debug("Found assets in github release: {}".format( found_assets_in_github_release)) for requested_platform in args.platform: logging.debug( "Verifying platform \'{}\' exists in GitHub release".format( requested_platform)) if requested_platform not in found_assets_in_github_release.keys(): logging.error( "Platform \'{}\' does not exist in GitHub release".format( requested_platform)) exit(1) for platform in args.platform: if args.debug: logging.debug("GitHub asset_url: {}".format( found_assets_in_github_release[platform]['url'] + '/' + found_assets_in_github_release[platform]['name'])) # Instantiate new requests session, versus reusing the repo session above. # Headers was likely being reused in that session, and not allowing us # to set the Accept header to the below. headers = { 'Accept': 'application/octet-stream', 'Authorization': 'token ' + get_env_var('GITHUB_TOKEN') } asset_url = found_assets_in_github_release[platform]['url'] if args.debug: # disable urllib3 logging for this session to avoid showing # access_token in logs logging.getLogger("urllib3").setLevel(logging.WARNING) r = requests.get(asset_url, headers=headers, stream=True) if args.debug: logging.getLogger("urllib3").setLevel(logging.DEBUG) logging.debug("Writing GitHub download to file: {}".format( found_assets_in_github_release[platform]['name'])) with open(found_assets_in_github_release[platform]['name'], 'wb') as f: for chunk in r.iter_content(chunk_size=1024): if chunk: f.write(chunk) logging.debug("Requests Response status_code: {}".format( r.status_code)) if r.status_code == 200: file_list.append('./' + found_assets_in_github_release[platform]['name']) else: logging.debug("Requests Response status_code != 200: {}".format( r.status_code)) if len(file_list) < len(args.platform): for item in args.platform: logging.error("Cannot get requested file from Github! {}".format( found_assets_in_github_release[item]['name'])) remove_github_downloaded_files(file_list, logging) exit(1) return file_list
def download_from_github(args, logging): file_list = [] # BRAVE_REPO defined in helpers.py repo = GitHub(get_env_var('GITHUB_TOKEN')).repos(BRAVE_REPO) if args.tag: tag_name = args.tag else: tag_name = get_brave_version() release = None releases = get_releases_by_tag(repo, tag_name, include_drafts=True) if releases: if len(releases) > 1: exit("Error: More than 1 release exists with the tag: \'{}\'".format(tag_name)) release = releases[0] else: exit("Error: Did not get the release \'{}\' from Github.".format(tag_name)) found_assets_in_github_release = {} for asset in release['assets']: if re.match(r'.*\.dmg$', asset['name']): if args.uploaded: if not args.platform: args.platform = [] args.platform.append('darwin') found_assets_in_github_release['darwin'] = {} found_assets_in_github_release['darwin']['name'] = asset['name'] found_assets_in_github_release['darwin']['url'] = asset['url'] elif re.match(r'brave_installer-ia32\.exe$', asset['name']): if args.uploaded: if not args.platform: args.platform = [] args.platform.append('win32') found_assets_in_github_release['win32'] = {} found_assets_in_github_release['win32']['name'] = asset['name'] found_assets_in_github_release['win32']['url'] = asset['url'] elif re.match(r'brave_installer-x64\.exe$', asset['name']): if args.uploaded: if not args.platform: args.platform = [] args.platform.append('win64') found_assets_in_github_release['win64'] = {} found_assets_in_github_release['win64']['name'] = asset['name'] found_assets_in_github_release['win64']['url'] = asset['url'] logging.debug("Found assets in github release: {}".format( found_assets_in_github_release)) for requested_platform in args.platform: logging.debug("Verifying platform \'{}\' exists in GitHub release". format(requested_platform)) if requested_platform not in found_assets_in_github_release.keys(): logging.error("Platform \'{}\' does not exist in GitHub release". format(requested_platform)) exit(1) for platform in args.platform: if args.debug: logging.debug("GitHub asset_url: {}".format( found_assets_in_github_release[platform]['url'] + '/' + found_assets_in_github_release[platform]['name'])) # Instantiate new requests session, versus reusing the repo session above. # Headers was likely being reused in that session, and not allowing us # to set the Accept header to the below. headers = {'Accept': 'application/octet-stream'} asset_auth_url = found_assets_in_github_release[platform]['url'] + \ '?access_token=' + os.environ.get('BRAVE_GITHUB_TOKEN') if args.debug: # disable urllib3 logging for this session to avoid showing # access_token in logs logging.getLogger("urllib3").setLevel(logging.WARNING) r = requests.get(asset_auth_url, headers=headers, stream=True) if args.debug: logging.getLogger("urllib3").setLevel(logging.DEBUG) logging.debug("Writing GitHub download to file: {}".format( found_assets_in_github_release[platform]['name'])) with open(found_assets_in_github_release[platform]['name'], 'wb') as f: for chunk in r.iter_content(chunk_size=1024): if chunk: f.write(chunk) logging.debug( "Requests Response status_code: {}".format(r.status_code)) if r.status_code == 200: file_list.append('./' + found_assets_in_github_release[platform]['name']) else: logging.debug( "Requests Response status_code != 200: {}".format(r.status_code)) if len(file_list) < len(args.platform): for item in args.platform: logging.error( "Cannot get requested file from Github! {}".format(found_assets_in_github_release[item]['name'])) remove_github_downloaded_files(file_list, logging) exit(1) return file_list