def update_bottle(version_tag, github_token, tap_repo_location): release_data = get_release(version_tag) tarball_sha256 = sha256(fetch_tarball(release_data['tarball_url'])) # First, update the bottle to have the new version and tarball sha. temp_handle, temp_path = tempfile.mkstemp(text=True) with os_closing(temp_handle): with open(os.path.join(tap_repo_location, 'buck.rb'), 'r') as orig: for line in orig: line = re.sub( r'@@buck_version = .*$', '@@buck_version = "{}"'.format(version_tag[1:]), line) line = re.sub( r'sha256 "[a-z0-9]{64}"$', 'sha256 "{}"'.format(tarball_sha256), line) line = re.sub( r' url "https://.+"$', ' url "{}"'.format(release_data['tarball_url']), line) os.write(temp_handle, line) shutil.copyfile(temp_path, os.path.join(tap_repo_location, 'buck.rb')) # Now, build the bottle's binary, and update the file with the new sha. bottle_file = build_bottle(version_tag, tap_repo_location) bottle_sha256 = sha256(bottle_file) upload_release( bottle_file, release_data['upload_url'], github_token, {'Content-Type': 'application/x-tar'}) os.remove(bottle_file) temp_handle, temp_path = tempfile.mkstemp(text=True) with os_closing(temp_handle): with open(os.path.join(tap_repo_location, 'buck.rb'), 'r') as orig: for line in orig: line = re.sub( r'sha256 "[a-z0-9]{64}" => :.+$', 'sha256 "{sha}" => :{macos_version_spec}'.format( sha=bottle_sha256, macos_version_spec=TARGET_MACOS_VER_SPEC), line) os.write(temp_handle, line) shutil.copyfile(temp_path, os.path.join(tap_repo_location, 'buck.rb')) validate() subprocess.check_call( [ 'git', 'commit', '-m', 'Update `buck.rb` to {}'.format(version_tag), 'buck.rb', ], cwd=tap_repo_location) print('Your commit is ready for testing! Check it out:') print(tap_repo_location)
def update_jar(version_tag, github_token, buck_repo_location): release_data = get_release(version_tag) # Now, build the plugin's binary, and update the file. plugin_file = build_plugin(version_tag, buck_repo_location) upload_release(plugin_file, release_data['upload_url'], github_token, { 'Content-Type': 'application/java-archive', }) os.remove(plugin_file)
def update_jar(version_tag, github_token, buck_repo_location): release_data = get_release(version_tag) # Now, build the plugin's binary, and update the file. plugin_file = build_plugin(version_tag, buck_repo_location) upload_release( plugin_file, release_data['upload_url'], github_token, { 'Content-Type': 'application/java-archive', }) os.remove(plugin_file)