From c5301bf8bf0891c633ac61ca66eb1ae0d3e0aa65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Mon, 11 Jun 2018 22:44:14 +0200 Subject: [PATCH] Updated release process documentation to reflect vcpkg autoupdate --- docs/release-process.md | 16 +---- scripts/updateVcpkgPackage.py | 108 ---------------------------------- 2 files changed, 2 insertions(+), 122 deletions(-) delete mode 100644 scripts/updateVcpkgPackage.py diff --git a/docs/release-process.md b/docs/release-process.md index 9990bab2..b556c399 100644 --- a/docs/release-process.md +++ b/docs/release-process.md @@ -49,17 +49,5 @@ on a specific version of the single-include header. ## Optional steps -The following steps are optional, and do not have to be performed when releasing new version of Catch. However, they *should* happen, but they can happen the next day without losing anything significant. - - -### vcpkg update - -Catch is maintaining its own port in Microsoft's package manager [vcpkg](https://github.com/Microsoft/vcpkg). This means that when new version of Catch is released, it should be posted there as well. `updateVcpkgPackage.py` can do a lot of necessary work for you, it creates a branch and commits necessary changes. You should review these changes, push and open a PR against vcpkg's upstream. - -Note that the script assumes you have your fork of vcpkg checked out in a directory next to the directory where you have checked out Catch, like so: -``` -GitHub - Catch - vcpkg -``` - +Because Catch's [vcpkg](https://github.com/Microsoft/vcpkg) port updates +itself automagically, there are no optional steps at this time. diff --git a/scripts/updateVcpkgPackage.py b/scripts/updateVcpkgPackage.py deleted file mode 100644 index c1f40b59..00000000 --- a/scripts/updateVcpkgPackage.py +++ /dev/null @@ -1,108 +0,0 @@ -#!/usr/bin/env python - -import io, os, re, sys, subprocess -import hashlib - -from scriptCommon import catchPath -from releaseCommon import Version - -print(catchPath) - -default_path = '../vcpkg/ports/catch2/' - -def adjusted_path(path): - return os.path.join(catchPath, path) - -def get_hash(path): - BUFF_SIZE = 65536 - sha512 = hashlib.sha512() - # The newlines should be normalized into \n, which is what we want - # If reused use 'rb' with a file written with io.open(newline='\n') - with open(path, 'r') as f: - while True: - data = f.read(BUFF_SIZE) - if not data: - break - if sys.version_info[0] < 3: - sha512.update(data) - else: - sha512.update(data.encode('utf-8')) - return sha512.hexdigest() - -def update_control(path): - v = Version() - - # Update control - lines = [] - control_path = os.path.join(path, 'CONTROL') - with open(control_path, 'r') as f: - for line in f: - lines.append(line) - with open(control_path, 'w') as f: - for line in lines: - if 'Version: ' in line: - line = 'Version: {}\n'.format(v.getVersionString()) - f.write(line) - -def update_portfile(path, header_hash, licence_hash): - print('Updating portfile') - v = Version() - - # Update portfile - lines = [] - portfile_path = os.path.join(path, 'portfile.cmake') - with open(portfile_path, 'r') as f: - for line in f: - lines.append(line) - with open(portfile_path, 'w') as f: - # There are three things we need to change/update - # 1) CATCH_VERSION cmake variable - # 2) Hash of header - # 3) Hash of licence - # We could assume licence never changes, but where is the fun in that? - for line in lines: - # Update the version - if 'set(CATCH_VERSION' in line: - line = 'set(CATCH_VERSION v{})\n'.format(v.getVersionString()) - - # Determine which file we are updating - if 'vcpkg_download_distfile' in line: - kind = line.split('(')[-1].strip() - - # Update the hashes - if 'SHA512' in line and kind == 'HEADER': - line = ' SHA512 {}\n'.format(header_hash) - if 'SHA512' in line and kind == 'LICENSE': - line = ' SHA512 {}\n'.format(licence_hash) - f.write(line) - - -def git_push(path_to_repo): - v = Version() - ver_string = v.getVersionString() - - os.chdir(path_to_repo) - - # Work with git - # Make sure we branch off master - subprocess.call('git checkout master', shell=True) - - # Update repo to current master, so we don't work off old version of the portfile - subprocess.call('git pull Microsoft master', shell=True) - subprocess.call('git push', shell=True) - - # Create a new branch for the update - subprocess.call('git checkout -b catch-{}'.format(ver_string), shell=True) - # Add changed files (should be only our files) - subprocess.call('git add -u .', shell=True) - # Create a commit with these changes - subprocess.call('git commit -m "Update Catch to {}"'.format(ver_string), shell=True) - # Don't push, so author can review - print('Changes were commited to the vcpkg fork. Please check, push and open PR.') - -header_hash = get_hash(adjusted_path('single_include/catch.hpp')) -licence_hash = get_hash(adjusted_path('LICENSE.txt')) -update_control(adjusted_path(default_path)) -update_portfile(adjusted_path(default_path), header_hash, licence_hash) - -git_push(adjusted_path('../vcpkg'))