From 9345dad5c17f31f3d860b030de52f7d319c5c445 Mon Sep 17 00:00:00 2001 From: Andy Mender Date: Sat, 6 Oct 2018 17:49:12 +0200 Subject: [PATCH 01/28] Add 'frozen' lxml to requirements file --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index c54d143a6..fd59fc80a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,6 +4,7 @@ attrs==18.2.0 colorama==0.3.9 cssutils==1.0.2 Jinja2==2.10 +lxml==4.2.5 MarkupSafe==1.0 Pygments==2.2.0 pyPEG2==2.15.2 From acde8a12f110e407aac0fc258c1ccb8c353d60ce Mon Sep 17 00:00:00 2001 From: Andy Mender Date: Sat, 6 Oct 2018 18:51:38 +0200 Subject: [PATCH 02/28] Add example script to add new release to qutebrowser.appdata.xml --- scripts/update_version.py | 85 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 scripts/update_version.py diff --git a/scripts/update_version.py b/scripts/update_version.py new file mode 100644 index 000000000..44e9fd495 --- /dev/null +++ b/scripts/update_version.py @@ -0,0 +1,85 @@ +#!/usr/bin/env python3 +# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: + +# Copyright 2018 Andy Mender + +# This file is part of qutebrowser. +# +# qutebrowser is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# qutebrowser is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with qutebrowser. If not, see . + +from lxml import etree + +# TODO: move to global constants? +appdata_path = "misc/qutebrowser.appdata.xml" +version_xpath = '//*[@type="desktop"]/releases' + + +def read_appdata(): + """Reads the appdata XML into an ElementTree object + + :return: ElementTree object + """ + + with open(appdata_path, "rb") as f: + appdata_tree = etree.fromstring(f.read()) + + return appdata_tree + + +def write_appdata(appdata_tree): + """Write appdata tree object back to XML file + + :param appdata_tree: appdata ElementTree object + """ + + with open(appdata_path, "wb") as f: + f.write(etree.tostring(appdata_tree, pretty_print=True)) + + +def add_release(releases, version_string, date_string): + """Add new block to block of the appdata XML + + :param releases: XML ElementTree + :param version_string: new qutebrowser version + :param date_string: release date for the new version + :return: + """ + + # create block and populate + release = etree.Element("release") + release.attrib["version"] = version_string + release.attrib["date"] = date_string + + # attach new release to block + releases.append(release) + + +if __name__ == "__main__": + + # read appdata XML + appdata_tree = read_appdata() + + # get XML block + releases = appdata_tree.xpath(version_xpath)[0] + + # attach example release + add_release(releases, "1.5.0", "2018-10-06") + + # bump/add new version (from git tag?) + for release in releases.iterchildren(): + print("version: {}, date: {}".format(release.get('version'), + release.get('date'))) + + # write appdata back to XML + write_appdata(appdata_tree) From bf6cb6278973b471d299534ea27418bf70e44af6 Mon Sep 17 00:00:00 2001 From: Andy Mender Date: Sat, 6 Oct 2018 20:03:37 +0200 Subject: [PATCH 03/28] Add bumpversion config --- .bumpversion.cfg | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .bumpversion.cfg diff --git a/.bumpversion.cfg b/.bumpversion.cfg new file mode 100644 index 000000000..d5709b446 --- /dev/null +++ b/.bumpversion.cfg @@ -0,0 +1,7 @@ +[bumpversion] +; bumped by running bumpversion +current_version = 1.5.0 +commit = True +tag = True +; default tag_name value +tag_name = v{new_version} From 0b51eb5b7c6acfbfa073cc0c249ded6332fd1593 Mon Sep 17 00:00:00 2001 From: Andy Mender Date: Sat, 6 Oct 2018 20:05:39 +0200 Subject: [PATCH 04/28] Move update_version.py script to scripts/dev --- scripts/{ => dev}/update_version.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename scripts/{ => dev}/update_version.py (100%) diff --git a/scripts/update_version.py b/scripts/dev/update_version.py similarity index 100% rename from scripts/update_version.py rename to scripts/dev/update_version.py From 020f3fa11fb8b145044ea09567b6784fa7067acc Mon Sep 17 00:00:00 2001 From: Andy Mender Date: Sat, 6 Oct 2018 20:10:07 +0200 Subject: [PATCH 05/28] Add bumpversion to requirements file --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index fd59fc80a..9b1382db8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,7 @@ # This file is automatically generated by scripts/dev/recompile_requirements.py attrs==18.2.0 +bumpversion==0.5.3 colorama==0.3.9 cssutils==1.0.2 Jinja2==2.10 From b49397ff0e5305ab5311668ae8058ad0993f2a39 Mon Sep 17 00:00:00 2001 From: Andy Mender Date: Sat, 6 Oct 2018 20:33:49 +0200 Subject: [PATCH 06/28] Pull __version__ from .bumpversion.cfg INI file --- qutebrowser/__init__.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/qutebrowser/__init__.py b/qutebrowser/__init__.py index c3745e766..98a7db90a 100644 --- a/qutebrowser/__init__.py +++ b/qutebrowser/__init__.py @@ -19,15 +19,20 @@ """A keyboard-driven, vim-like browser based on PyQt5.""" +from configparser import ConfigParser import os.path +# load .bumpversion.cfg config +config = ConfigParser() +config.read('.bumpversion.cfg') + __author__ = "Florian Bruhin" __copyright__ = "Copyright 2014-2018 Florian Bruhin (The Compiler)" __license__ = "GPL" __maintainer__ = __author__ __email__ = "mail@qutebrowser.org" -__version_info__ = (1, 5, 0) -__version__ = '.'.join(str(e) for e in __version_info__) +__version__ = config['bumpversion']['current_version'] +__version_info__ = __version__.split('.') __description__ = "A keyboard-driven, vim-like browser based on PyQt5." basedir = os.path.dirname(os.path.realpath(__file__)) From 8406146db5359720dae131a8a0c2bf3c8413c4d0 Mon Sep 17 00:00:00 2001 From: Andy Mender Date: Sat, 6 Oct 2018 20:56:33 +0200 Subject: [PATCH 07/28] =?UTF-8?q?Bump=20version:=201.5.0=20=E2=86=92=201.5?= =?UTF-8?q?.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .bumpversion.cfg | 8 +++++--- qutebrowser/__init__.py | 9 +++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index d5709b446..fc2eb9a26 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,7 +1,9 @@ [bumpversion] -; bumped by running bumpversion -current_version = 1.5.0 +current_version = 1.5.1 commit = True tag = True -; default tag_name value tag_name = v{new_version} + +[bumpversion:file:qutebrowser/__init__.py] +parse = __version__ = (?P\d+)\.(?P\d+)\.(?P\d+) + diff --git a/qutebrowser/__init__.py b/qutebrowser/__init__.py index 98a7db90a..13f008e56 100644 --- a/qutebrowser/__init__.py +++ b/qutebrowser/__init__.py @@ -19,19 +19,20 @@ """A keyboard-driven, vim-like browser based on PyQt5.""" -from configparser import ConfigParser +# from configparser import ConfigParser import os.path # load .bumpversion.cfg config -config = ConfigParser() -config.read('.bumpversion.cfg') +# config = ConfigParser() +# config.read('.bumpversion.cfg') __author__ = "Florian Bruhin" __copyright__ = "Copyright 2014-2018 Florian Bruhin (The Compiler)" __license__ = "GPL" __maintainer__ = __author__ __email__ = "mail@qutebrowser.org" -__version__ = config['bumpversion']['current_version'] +__version__ = "1.5.1" +# __version__ = config['bumpversion']['current_version'] __version_info__ = __version__.split('.') __description__ = "A keyboard-driven, vim-like browser based on PyQt5." From eae9cd30afdf7073633950c1cfc79d42b6c7411a Mon Sep 17 00:00:00 2001 From: Andy Mender Date: Sat, 6 Oct 2018 20:57:35 +0200 Subject: [PATCH 08/28] =?UTF-8?q?Bump=20version:=201.5.0=20=E2=86=92=201.5?= =?UTF-8?q?.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- qutebrowser/__init__.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/qutebrowser/__init__.py b/qutebrowser/__init__.py index 13f008e56..4ca029db9 100644 --- a/qutebrowser/__init__.py +++ b/qutebrowser/__init__.py @@ -19,13 +19,8 @@ """A keyboard-driven, vim-like browser based on PyQt5.""" -# from configparser import ConfigParser import os.path -# load .bumpversion.cfg config -# config = ConfigParser() -# config.read('.bumpversion.cfg') - __author__ = "Florian Bruhin" __copyright__ = "Copyright 2014-2018 Florian Bruhin (The Compiler)" __license__ = "GPL" From 931b0926537a6f1c871fff47966674b2ce7a161f Mon Sep 17 00:00:00 2001 From: Andy Mender Date: Sat, 6 Oct 2018 21:00:36 +0200 Subject: [PATCH 09/28] Parse __version__ from/to qutebrowser/__init__.py directly --- .bumpversion.cfg | 2 +- qutebrowser/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index fc2eb9a26..dedc326b1 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 1.5.1 +current_version = 1.5.0 commit = True tag = True tag_name = v{new_version} diff --git a/qutebrowser/__init__.py b/qutebrowser/__init__.py index 4ca029db9..d338633f3 100644 --- a/qutebrowser/__init__.py +++ b/qutebrowser/__init__.py @@ -26,7 +26,7 @@ __copyright__ = "Copyright 2014-2018 Florian Bruhin (The Compiler)" __license__ = "GPL" __maintainer__ = __author__ __email__ = "mail@qutebrowser.org" -__version__ = "1.5.1" +__version__ = "1.5.0" # __version__ = config['bumpversion']['current_version'] __version_info__ = __version__.split('.') __description__ = "A keyboard-driven, vim-like browser based on PyQt5." From 1fbf5d37127ff97eeeb041cc62319894a68f7a95 Mon Sep 17 00:00:00 2001 From: Andy Mender Date: Sat, 6 Oct 2018 21:03:33 +0200 Subject: [PATCH 10/28] Add bump_version to update_version.py and include new release block in appdata.xml --- scripts/dev/update_version.py | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/scripts/dev/update_version.py b/scripts/dev/update_version.py index 44e9fd495..adf608537 100644 --- a/scripts/dev/update_version.py +++ b/scripts/dev/update_version.py @@ -18,6 +18,9 @@ # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . +from datetime import date +import subprocess + from lxml import etree # TODO: move to global constants? @@ -25,6 +28,21 @@ appdata_path = "misc/qutebrowser.appdata.xml" version_xpath = '//*[@type="desktop"]/releases' +def bump_version(version_leap = "patch"): + """Update qutebrowser release version in .bumpversion.cfg + + :param version_leap: define the jump between versions ("major", "minor", "patch") + """ + + # make sure the correct version jump was chosen + if version_leap not in ("major", "minor", "patch"): + raise ValueError("version_leap takes values of 'major', 'minor' or 'patch' only.") + + # NOTE: this may rely on the python version used to launch the function + # and whether the wrapper script 'bumpversion' was provided + subprocess.run(['bumpversion', version_leap, '--allow-dirty']) + + def read_appdata(): """Reads the appdata XML into an ElementTree object @@ -66,6 +84,12 @@ def add_release(releases, version_string, date_string): if __name__ == "__main__": + # bump version globally + bump_version() + + # NOTE: this step must be executed AFTER bumping the version! + # import __version__ and use to update remaining files + from qutebrowser import __version__ # read appdata XML appdata_tree = read_appdata() @@ -73,13 +97,9 @@ if __name__ == "__main__": # get XML block releases = appdata_tree.xpath(version_xpath)[0] - # attach example release - add_release(releases, "1.5.0", "2018-10-06") - - # bump/add new version (from git tag?) - for release in releases.iterchildren(): - print("version: {}, date: {}".format(release.get('version'), - release.get('date'))) + # attach new release + # TODO: use different date string? + add_release(releases, __version__, date.today().isoformat()) # write appdata back to XML write_appdata(appdata_tree) From 4658c4a9fd3ba85b73e8cbb9c29994f4578ee972 Mon Sep 17 00:00:00 2001 From: Andy Mender Date: Sat, 6 Oct 2018 21:08:39 +0200 Subject: [PATCH 11/28] Remove leftover __version__ line from qutebrowser/__init__.py --- qutebrowser/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/qutebrowser/__init__.py b/qutebrowser/__init__.py index d338633f3..c3dd0411c 100644 --- a/qutebrowser/__init__.py +++ b/qutebrowser/__init__.py @@ -27,7 +27,6 @@ __license__ = "GPL" __maintainer__ = __author__ __email__ = "mail@qutebrowser.org" __version__ = "1.5.0" -# __version__ = config['bumpversion']['current_version'] __version_info__ = __version__.split('.') __description__ = "A keyboard-driven, vim-like browser based on PyQt5." From 1c26ed9226b2579b96d83a8f77805440b3d79915 Mon Sep 17 00:00:00 2001 From: Andy Mender Date: Sun, 7 Oct 2018 11:55:47 +0200 Subject: [PATCH 12/28] Add bumpversion tag signing via bump2version feature --- .bumpversion.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index dedc326b1..eb9b539a1 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -2,6 +2,7 @@ current_version = 1.5.0 commit = True tag = True +sign_tags = True tag_name = v{new_version} [bumpversion:file:qutebrowser/__init__.py] From 21e49cf958aea239a3199a29c904d41237c77528 Mon Sep 17 00:00:00 2001 From: Andy Mender Date: Sun, 7 Oct 2018 11:56:28 +0200 Subject: [PATCH 13/28] Add update_version.py to build_release.py pipeline and update command-line args --- scripts/dev/build_release.py | 27 +++++++++++++++++++----- scripts/dev/update_version.py | 39 ++++++++++++++++++++--------------- 2 files changed, 44 insertions(+), 22 deletions(-) diff --git a/scripts/dev/build_release.py b/scripts/dev/build_release.py index e3f039336..f83c12f3a 100755 --- a/scripts/dev/build_release.py +++ b/scripts/dev/build_release.py @@ -84,6 +84,13 @@ def run_asciidoc2html(args): call_script('asciidoc2html.py', *a2h_args) +def run_update_version(args): + """Bump release version.""" + utils.print_title("Running update_version.py") + + call_script('update_version.py', args.bump) + + def _maybe_remove(path): """Remove a path if it exists.""" try: @@ -360,19 +367,24 @@ def main(): "asciidoc.py. If not given, it's searched in PATH.", nargs=2, required=False, metavar=('PYTHON', 'ASCIIDOC')) - parser.add_argument('--upload', help="Tag to upload the release for", - nargs=1, required=False, metavar='TAG') + parser.add_argument('--bump', type=str, choices=["major", "minor", "patch"], + required=False, help="Update release version") + parser.add_argument('--upload', action='store_true', required=False, + help="Toggle to upload the release to GitHub") args = parser.parse_args() utils.change_cwd() upload_to_pypi = False - if args.upload is not None: + if args.upload: # Fail early when trying to upload without github3 installed # or without API token import github3 # pylint: disable=unused-variable read_github_token() + if args.bump is not None: + run_update_version(args) + if args.no_asciidoc: os.makedirs(os.path.join('qutebrowser', 'html', 'doc'), exist_ok=True) else: @@ -387,10 +399,15 @@ def main(): artifacts = build_sdist() upload_to_pypi = True - if args.upload is not None: + if args.upload: + from qutebrowser import __version__ utils.print_title("Press enter to release...") input() - github_upload(artifacts, args.upload[0]) + + # create version tag + version_tag = "v" + __version__ + + github_upload(artifacts, version_tag) if upload_to_pypi: pypi_upload(artifacts) else: diff --git a/scripts/dev/update_version.py b/scripts/dev/update_version.py index adf608537..53daac7d3 100644 --- a/scripts/dev/update_version.py +++ b/scripts/dev/update_version.py @@ -18,6 +18,7 @@ # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . +import argparse from datetime import date import subprocess @@ -34,13 +35,10 @@ def bump_version(version_leap = "patch"): :param version_leap: define the jump between versions ("major", "minor", "patch") """ - # make sure the correct version jump was chosen - if version_leap not in ("major", "minor", "patch"): - raise ValueError("version_leap takes values of 'major', 'minor' or 'patch' only.") # NOTE: this may rely on the python version used to launch the function # and whether the wrapper script 'bumpversion' was provided - subprocess.run(['bumpversion', version_leap, '--allow-dirty']) + subprocess.run(['bump2version', version_leap, '--allow-dirty']) def read_appdata(): @@ -84,22 +82,29 @@ def add_release(releases, version_string, date_string): if __name__ == "__main__": + parser = argparse.ArgumentParser(description="Update release version and appdata.xml") + parser.add_argument('bump', action="store", choices=["major", "minor", "patch"], + required=False, help="Update release version") + args = parser.parse_args() + # bump version globally - bump_version() + if args.bump is not None: + bump_version(args.bump) - # NOTE: this step must be executed AFTER bumping the version! - # import __version__ and use to update remaining files - from qutebrowser import __version__ + # NOTE: this step must be executed AFTER bumping the version! + from qutebrowser import __version__ - # read appdata XML - appdata_tree = read_appdata() + # read appdata XML + appdata_tree = read_appdata() - # get XML block - releases = appdata_tree.xpath(version_xpath)[0] + # get XML block + releases = appdata_tree.xpath(version_xpath)[0] - # attach new release - # TODO: use different date string? - add_release(releases, __version__, date.today().isoformat()) + # attach new release + # TODO: use different date string? + add_release(releases, __version__, date.today().isoformat()) - # write appdata back to XML - write_appdata(appdata_tree) + # write appdata back to XML + write_appdata(appdata_tree) + else: + print("Option 'bump' not specified via command-line. Nothing was changed.") From 44f40118956346e203c797c117978add03be7676 Mon Sep 17 00:00:00 2001 From: Andy Mender Date: Sun, 7 Oct 2018 12:00:23 +0200 Subject: [PATCH 14/28] Update contributing.asciidoc (needs a revision!) --- doc/contributing.asciidoc | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/doc/contributing.asciidoc b/doc/contributing.asciidoc index bef345c0c..c7776d133 100644 --- a/doc/contributing.asciidoc +++ b/doc/contributing.asciidoc @@ -696,24 +696,15 @@ qutebrowser release * Make sure there are no unstaged changes and the tests are green. * Make sure all issues with the related milestone are closed. -* Run `x=... y=...` to set the respective shell variables. - -* Update changelog (remove *(unreleased)*). -* Adjust `__version_info__` in `qutebrowser/__init__.py`. -* Commit. - -* Create annotated git tag (`git tag -s "v1.$x.$y" -m "Release v1.$x.$y"`). -* `git push origin`; `git push origin v1.$x.$y`. +* Update changelog (remove *(unreleased)*) and commit. * If committing on minor branch, cherry-pick release commit to master. -* Create release on github. -* Mark the milestone at https://github.com/qutebrowser/qutebrowser/milestones -as closed. - -* Linux: Run `git checkout v1.$x.$y && ./.venv/bin/python3 scripts/dev/build_release.py --upload v1.$x.$y`. -* Windows: Run `git checkout v1.X.Y; py -3 scripts\dev\build_release.py --asciidoc C:\Python27\python %userprofile%\bin\asciidoc-8.6.10\asciidoc.py --upload v1.X.Y` (replace X/Y by hand). -* macOS: Run `git checkout v1.X.Y && python3 scripts/dev/build_release.py --upload v1.X.Y` (replace X/Y by hand). +* Mark the milestone at https://github.com/qutebrowser/qutebrowser/milestones as closed. +* Linux: run `./.venv/bin/python3 scripts/dev/build_release.py --bump ["major","minor","patch"] --upload`. +* Windows: Run `py -3 scripts\dev\build_release.py --asciidoc C:\Python27\python %userprofile%\bin\asciidoc-8.6.10\asciidoc.py -bump ["major","minor","patch"] --upload`. +* macOS: Run `python3 scripts/dev/build_release.py --bump ["major","minor","patch"] --upload`. * On server: - Run `python3 scripts/dev/download_release.py v1.X.Y` (replace X/Y by hand). - Run `git pull github master && sudo python3 scripts/asciidoc2html.py --website /srv/http/qutebrowser` +* Create release on github. * Update `qutebrowser-git` PKGBUILD if dependencies/install changed. * Announce to qutebrowser and qutebrowser-announce mailinglist. From 9552e5030dbaec730e5dcd5c1d434966d99a7eac Mon Sep 17 00:00:00 2001 From: Andy Mender Date: Sun, 7 Oct 2018 12:05:38 +0200 Subject: [PATCH 15/28] Make __version_info__ a list of int version parts [, , ] --- qutebrowser/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qutebrowser/__init__.py b/qutebrowser/__init__.py index c3dd0411c..620d74a61 100644 --- a/qutebrowser/__init__.py +++ b/qutebrowser/__init__.py @@ -27,7 +27,7 @@ __license__ = "GPL" __maintainer__ = __author__ __email__ = "mail@qutebrowser.org" __version__ = "1.5.0" -__version_info__ = __version__.split('.') +__version_info__ = [int(part) for part in __version__.split('.')] __description__ = "A keyboard-driven, vim-like browser based on PyQt5." basedir = os.path.dirname(os.path.realpath(__file__)) From 88fdd8675b8da85739f16b71bcc8477b22821e91 Mon Sep 17 00:00:00 2001 From: Andy Mender Date: Sun, 7 Oct 2018 12:07:12 +0200 Subject: [PATCH 16/28] Remove bumpversion from requirements file - dev package only! --- requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 9b1382db8..fd59fc80a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,6 @@ # This file is automatically generated by scripts/dev/recompile_requirements.py attrs==18.2.0 -bumpversion==0.5.3 colorama==0.3.9 cssutils==1.0.2 Jinja2==2.10 From 5231b25759a41b0650888a0497910b59fba5738d Mon Sep 17 00:00:00 2001 From: Andy Mender Date: Sun, 7 Oct 2018 12:49:25 +0200 Subject: [PATCH 17/28] Move appdata_path to qutebrowser.__init__.py and improve code style --- qutebrowser/__init__.py | 2 + scripts/dev/build_release.py | 3 +- scripts/dev/update_version.py | 72 ++++++++++++++++------------------- 3 files changed, 36 insertions(+), 41 deletions(-) diff --git a/qutebrowser/__init__.py b/qutebrowser/__init__.py index 620d74a61..790fe6d6d 100644 --- a/qutebrowser/__init__.py +++ b/qutebrowser/__init__.py @@ -31,3 +31,5 @@ __version_info__ = [int(part) for part in __version__.split('.')] __description__ = "A keyboard-driven, vim-like browser based on PyQt5." basedir = os.path.dirname(os.path.realpath(__file__)) +appdata_path = os.path.join(os.path.dirname(basedir), "misc", + "qutebrowser.appdata.xml") diff --git a/scripts/dev/build_release.py b/scripts/dev/build_release.py index f83c12f3a..8dc0ee307 100755 --- a/scripts/dev/build_release.py +++ b/scripts/dev/build_release.py @@ -367,7 +367,8 @@ def main(): "asciidoc.py. If not given, it's searched in PATH.", nargs=2, required=False, metavar=('PYTHON', 'ASCIIDOC')) - parser.add_argument('--bump', type=str, choices=["major", "minor", "patch"], + parser.add_argument('--bump', type=str, + choices=["major", "minor", "patch"], required=False, help="Update release version") parser.add_argument('--upload', action='store_true', required=False, help="Toggle to upload the release to GitHub") diff --git a/scripts/dev/update_version.py b/scripts/dev/update_version.py index 53daac7d3..4759cea15 100644 --- a/scripts/dev/update_version.py +++ b/scripts/dev/update_version.py @@ -19,71 +19,67 @@ # along with qutebrowser. If not, see . import argparse -from datetime import date +import datetime import subprocess from lxml import etree -# TODO: move to global constants? -appdata_path = "misc/qutebrowser.appdata.xml" +from qutebrowser import appdata_path + version_xpath = '//*[@type="desktop"]/releases' -def bump_version(version_leap = "patch"): - """Update qutebrowser release version in .bumpversion.cfg +def bump_version(version_leap="patch"): + """Update qutebrowser release version. - :param version_leap: define the jump between versions ("major", "minor", "patch") + Args: + version_leap: define the jump between versions + ("major", "minor", "patch") """ - - - # NOTE: this may rely on the python version used to launch the function - # and whether the wrapper script 'bumpversion' was provided - subprocess.run(['bump2version', version_leap, '--allow-dirty']) + subprocess.run(['bump2version', version_leap]) def read_appdata(): - """Reads the appdata XML into an ElementTree object + """Read qutebrowser.appdata.xml into an ElementTree object. - :return: ElementTree object + :Return: + ElementTree object representing appdata.xml """ - with open(appdata_path, "rb") as f: - appdata_tree = etree.fromstring(f.read()) + appdata = etree.fromstring(f.read()) - return appdata_tree + return appdata -def write_appdata(appdata_tree): - """Write appdata tree object back to XML file +def write_appdata(appdata): + """Write qutebrowser.appdata ElementTree object to a file. - :param appdata_tree: appdata ElementTree object + Args: + appdata: appdata ElementTree object """ - with open(appdata_path, "wb") as f: - f.write(etree.tostring(appdata_tree, pretty_print=True)) + f.write(etree.tostring(appdata, pretty_print=True)) def add_release(releases, version_string, date_string): - """Add new block to block of the appdata XML + """Add new block to block of the appdata XML. - :param releases: XML ElementTree - :param version_string: new qutebrowser version - :param date_string: release date for the new version - :return: + Args: + releases: XML ElementTree + version_string: new qutebrowser version + date_string: release date for the new version """ - - # create block and populate release = etree.Element("release") release.attrib["version"] = version_string release.attrib["date"] = date_string - # attach new release to block releases.append(release) if __name__ == "__main__": - parser = argparse.ArgumentParser(description="Update release version and appdata.xml") - parser.add_argument('bump', action="store", choices=["major", "minor", "patch"], + parser = argparse.ArgumentParser(description="Update release version.") + parser.add_argument('bump', action="store", + choices=["major", "minor", "patch"], required=False, help="Update release version") args = parser.parse_args() @@ -91,20 +87,16 @@ if __name__ == "__main__": if args.bump is not None: bump_version(args.bump) - # NOTE: this step must be executed AFTER bumping the version! from qutebrowser import __version__ - # read appdata XML appdata_tree = read_appdata() - # get XML block - releases = appdata_tree.xpath(version_xpath)[0] + releases_block = appdata_tree.xpath(version_xpath)[0] - # attach new release - # TODO: use different date string? - add_release(releases, __version__, date.today().isoformat()) + add_release(releases_block, __version__, + datetime.date.today().isoformat()) - # write appdata back to XML write_appdata(appdata_tree) else: - print("Option 'bump' not specified via command-line. Nothing was changed.") + print("Option 'bump' not specified via command-line." + " Nothing was changed.") From fd03db1f7052d9d4ba792383c60a0eb790c867f0 Mon Sep 17 00:00:00 2001 From: Andy Mender Date: Sun, 7 Oct 2018 12:51:54 +0200 Subject: [PATCH 18/28] Remove redundant newline from .bumpversion.cfg --- .bumpversion.cfg | 1 - 1 file changed, 1 deletion(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index eb9b539a1..299c56c98 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -7,4 +7,3 @@ tag_name = v{new_version} [bumpversion:file:qutebrowser/__init__.py] parse = __version__ = (?P\d+)\.(?P\d+)\.(?P\d+) - From c30059e052921ea9a0eafa3c39b037aaef0bc99f Mon Sep 17 00:00:00 2001 From: Andy Mender Date: Sun, 7 Oct 2018 13:59:57 +0200 Subject: [PATCH 19/28] Add releases to qutebrowser.appdata.xml --- misc/qutebrowser.appdata.xml | 40 +++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/misc/qutebrowser.appdata.xml b/misc/qutebrowser.appdata.xml index bdab55f54..7f98603a4 100644 --- a/misc/qutebrowser.appdata.xml +++ b/misc/qutebrowser.appdata.xml @@ -41,8 +41,46 @@ https://github.com/qutebrowser/qutebrowser/issues/ https://github.com/qutebrowser/qutebrowser#donating - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From cc6303a8cc64efc04c28107ec37651466c0b5701 Mon Sep 17 00:00:00 2001 From: Andy Mender Date: Sun, 7 Oct 2018 17:28:07 +0200 Subject: [PATCH 20/28] Move appdata_path back to scripts/dev/update_version.py --- qutebrowser/__init__.py | 2 -- scripts/dev/update_version.py | 6 +++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/qutebrowser/__init__.py b/qutebrowser/__init__.py index 790fe6d6d..620d74a61 100644 --- a/qutebrowser/__init__.py +++ b/qutebrowser/__init__.py @@ -31,5 +31,3 @@ __version_info__ = [int(part) for part in __version__.split('.')] __description__ = "A keyboard-driven, vim-like browser based on PyQt5." basedir = os.path.dirname(os.path.realpath(__file__)) -appdata_path = os.path.join(os.path.dirname(basedir), "misc", - "qutebrowser.appdata.xml") diff --git a/scripts/dev/update_version.py b/scripts/dev/update_version.py index 4759cea15..17cd2529d 100644 --- a/scripts/dev/update_version.py +++ b/scripts/dev/update_version.py @@ -20,12 +20,16 @@ import argparse import datetime +import os.path import subprocess from lxml import etree -from qutebrowser import appdata_path +from qutebrowser import basedir +# use basedir to get project root dir +appdata_path = os.path.join(os.path.dirname(basedir), "misc", + "qutebrowser.appdata.xml") version_xpath = '//*[@type="desktop"]/releases' From 16cfceb66ebff3571e2ac0c02f8678b9ad2eb958 Mon Sep 17 00:00:00 2001 From: Andy Mender Date: Sun, 7 Oct 2018 17:29:46 +0200 Subject: [PATCH 21/28] Remove lxml from requirements file --- requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index fd59fc80a..c54d143a6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,7 +4,6 @@ attrs==18.2.0 colorama==0.3.9 cssutils==1.0.2 Jinja2==2.10 -lxml==4.2.5 MarkupSafe==1.0 Pygments==2.2.0 pyPEG2==2.15.2 From d6be4aa6453b3c94f2137dae8d9c19faa9148140 Mon Sep 17 00:00:00 2001 From: Andy Mender Date: Sun, 7 Oct 2018 17:31:57 +0200 Subject: [PATCH 22/28] Remove misleading 'version tag' comment from scripts/dev/build_release.py --- scripts/dev/build_release.py | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/dev/build_release.py b/scripts/dev/build_release.py index 8dc0ee307..ce01c82b9 100755 --- a/scripts/dev/build_release.py +++ b/scripts/dev/build_release.py @@ -405,7 +405,6 @@ def main(): utils.print_title("Press enter to release...") input() - # create version tag version_tag = "v" + __version__ github_upload(artifacts, version_tag) From d125a59ec0dba276d273e5633e9c359f36261b9c Mon Sep 17 00:00:00 2001 From: Andy Mender Date: Sun, 7 Oct 2018 17:33:09 +0200 Subject: [PATCH 23/28] Add explicit output check to subprocess.run call in update_version.bump_version --- scripts/dev/update_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/dev/update_version.py b/scripts/dev/update_version.py index 17cd2529d..d5414a8f4 100644 --- a/scripts/dev/update_version.py +++ b/scripts/dev/update_version.py @@ -40,7 +40,7 @@ def bump_version(version_leap="patch"): version_leap: define the jump between versions ("major", "minor", "patch") """ - subprocess.run(['bump2version', version_leap]) + subprocess.run(['bump2version', version_leap], check=True) def read_appdata(): From e1368534e5c7e14dd1940024be20b7b06b06900f Mon Sep 17 00:00:00 2001 From: Andy Mender Date: Sun, 7 Oct 2018 17:35:18 +0200 Subject: [PATCH 24/28] Make update_version.py 'bump' command-line arg mandatory --- scripts/dev/update_version.py | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/scripts/dev/update_version.py b/scripts/dev/update_version.py index d5414a8f4..f3336780b 100644 --- a/scripts/dev/update_version.py +++ b/scripts/dev/update_version.py @@ -84,23 +84,17 @@ if __name__ == "__main__": parser = argparse.ArgumentParser(description="Update release version.") parser.add_argument('bump', action="store", choices=["major", "minor", "patch"], - required=False, help="Update release version") + required=True, help="Update release version") args = parser.parse_args() - # bump version globally - if args.bump is not None: - bump_version(args.bump) + bump_version(args.bump) - from qutebrowser import __version__ + from qutebrowser import __version__ - appdata_tree = read_appdata() + appdata_tree = read_appdata() - releases_block = appdata_tree.xpath(version_xpath)[0] + releases_block = appdata_tree.xpath(version_xpath)[0] - add_release(releases_block, __version__, - datetime.date.today().isoformat()) + add_release(releases_block, __version__, datetime.date.today().isoformat()) - write_appdata(appdata_tree) - else: - print("Option 'bump' not specified via command-line." - " Nothing was changed.") + write_appdata(appdata_tree) From 41402cb45fdb48e52dc6be915aca72f0584d06ae Mon Sep 17 00:00:00 2001 From: Andy Mender Date: Sun, 7 Oct 2018 18:03:55 +0200 Subject: [PATCH 25/28] Remove update_version.py from build_release.py pipeline --- scripts/dev/build_release.py | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/scripts/dev/build_release.py b/scripts/dev/build_release.py index ce01c82b9..dca2621f0 100755 --- a/scripts/dev/build_release.py +++ b/scripts/dev/build_release.py @@ -84,13 +84,6 @@ def run_asciidoc2html(args): call_script('asciidoc2html.py', *a2h_args) -def run_update_version(args): - """Bump release version.""" - utils.print_title("Running update_version.py") - - call_script('update_version.py', args.bump) - - def _maybe_remove(path): """Remove a path if it exists.""" try: @@ -367,9 +360,6 @@ def main(): "asciidoc.py. If not given, it's searched in PATH.", nargs=2, required=False, metavar=('PYTHON', 'ASCIIDOC')) - parser.add_argument('--bump', type=str, - choices=["major", "minor", "patch"], - required=False, help="Update release version") parser.add_argument('--upload', action='store_true', required=False, help="Toggle to upload the release to GitHub") args = parser.parse_args() @@ -383,9 +373,6 @@ def main(): import github3 # pylint: disable=unused-variable read_github_token() - if args.bump is not None: - run_update_version(args) - if args.no_asciidoc: os.makedirs(os.path.join('qutebrowser', 'html', 'doc'), exist_ok=True) else: From b684070bc934055ca77ca5e9aeb609a23a056bd9 Mon Sep 17 00:00:00 2001 From: Andy Mender Date: Sun, 7 Oct 2018 18:11:06 +0200 Subject: [PATCH 26/28] Update qutebrowser release pipeline in contributing.asciidoc --- doc/contributing.asciidoc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/doc/contributing.asciidoc b/doc/contributing.asciidoc index c7776d133..7c12d6083 100644 --- a/doc/contributing.asciidoc +++ b/doc/contributing.asciidoc @@ -699,9 +699,12 @@ qutebrowser release * Update changelog (remove *(unreleased)*) and commit. * If committing on minor branch, cherry-pick release commit to master. * Mark the milestone at https://github.com/qutebrowser/qutebrowser/milestones as closed. -* Linux: run `./.venv/bin/python3 scripts/dev/build_release.py --bump ["major","minor","patch"] --upload`. -* Windows: Run `py -3 scripts\dev\build_release.py --asciidoc C:\Python27\python %userprofile%\bin\asciidoc-8.6.10\asciidoc.py -bump ["major","minor","patch"] --upload`. -* macOS: Run `python3 scripts/dev/build_release.py --bump ["major","minor","patch"] --upload`. +* Run `./.venv/bin/python3 scripts/dev/update_version.py major | minor | patch`. +* Run 'git push origin'. +* Create new release via GitHub (required to upload release artifacts). +* Linux: run `./.venv/bin/python3 scripts/dev/build_release.py --upload`. +* Windows: Run `py -3 scripts\dev\build_release.py --asciidoc C:\Python27\python %userprofile%\bin\asciidoc-8.6.10\asciidoc.py --upload`. +* macOS: Run `python3 scripts/dev/build_release.py --upload`. * On server: - Run `python3 scripts/dev/download_release.py v1.X.Y` (replace X/Y by hand). - Run `git pull github master && sudo python3 scripts/asciidoc2html.py --website /srv/http/qutebrowser` From a2856bee2bf4a39bfa0f036e3dd08e9abd590120 Mon Sep 17 00:00:00 2001 From: Andy Mender Date: Mon, 8 Oct 2018 22:08:18 +0200 Subject: [PATCH 27/28] Improve contributing.asciidoc and return git release tag from update_version.py --- doc/contributing.asciidoc | 11 +++++------ scripts/dev/update_version.py | 2 ++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/doc/contributing.asciidoc b/doc/contributing.asciidoc index 7c12d6083..bda68689c 100644 --- a/doc/contributing.asciidoc +++ b/doc/contributing.asciidoc @@ -699,15 +699,14 @@ qutebrowser release * Update changelog (remove *(unreleased)*) and commit. * If committing on minor branch, cherry-pick release commit to master. * Mark the milestone at https://github.com/qutebrowser/qutebrowser/milestones as closed. -* Run `./.venv/bin/python3 scripts/dev/update_version.py major | minor | patch`. -* Run 'git push origin'. +* Run `VERSION_TAG=$(./.venv/bin/python3 scripts/dev/update_version.py major | minor | patch)`. +* Run `git push origin; git push $VERSION_TAG`. * Create new release via GitHub (required to upload release artifacts). -* Linux: run `./.venv/bin/python3 scripts/dev/build_release.py --upload`. -* Windows: Run `py -3 scripts\dev\build_release.py --asciidoc C:\Python27\python %userprofile%\bin\asciidoc-8.6.10\asciidoc.py --upload`. -* macOS: Run `python3 scripts/dev/build_release.py --upload`. +* Linux: Run `git checkout $VERSION_TAG && ./.venv/bin/python3 scripts/dev/build_release.py --upload`. +* Windows: Run `git checkout $VERSION_TAG; py -3 scripts\dev\build_release.py --asciidoc C:\Python27\python %userprofile%\bin\asciidoc-8.6.10\asciidoc.py --upload`. +* macOS: Run `git checkout $VERSION_TAG && python3 scripts/dev/build_release.py --upload`. * On server: - Run `python3 scripts/dev/download_release.py v1.X.Y` (replace X/Y by hand). - Run `git pull github master && sudo python3 scripts/asciidoc2html.py --website /srv/http/qutebrowser` -* Create release on github. * Update `qutebrowser-git` PKGBUILD if dependencies/install changed. * Announce to qutebrowser and qutebrowser-announce mailinglist. diff --git a/scripts/dev/update_version.py b/scripts/dev/update_version.py index f3336780b..a24ae106f 100644 --- a/scripts/dev/update_version.py +++ b/scripts/dev/update_version.py @@ -98,3 +98,5 @@ if __name__ == "__main__": add_release(releases_block, __version__, datetime.date.today().isoformat()) write_appdata(appdata_tree) + + print(__version__) From a9f9de4b35180bf403ad996c2c0de2be6216599c Mon Sep 17 00:00:00 2001 From: Andy Mender Date: Sun, 14 Oct 2018 13:35:45 +0200 Subject: [PATCH 28/28] Add instructions to update_version.py and adjust contributing.asciidoc accordingly. --- doc/contributing.asciidoc | 11 ++--------- scripts/dev/update_version.py | 25 ++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/doc/contributing.asciidoc b/doc/contributing.asciidoc index bda68689c..9e6bbe6b3 100644 --- a/doc/contributing.asciidoc +++ b/doc/contributing.asciidoc @@ -699,14 +699,7 @@ qutebrowser release * Update changelog (remove *(unreleased)*) and commit. * If committing on minor branch, cherry-pick release commit to master. * Mark the milestone at https://github.com/qutebrowser/qutebrowser/milestones as closed. -* Run `VERSION_TAG=$(./.venv/bin/python3 scripts/dev/update_version.py major | minor | patch)`. -* Run `git push origin; git push $VERSION_TAG`. -* Create new release via GitHub (required to upload release artifacts). -* Linux: Run `git checkout $VERSION_TAG && ./.venv/bin/python3 scripts/dev/build_release.py --upload`. -* Windows: Run `git checkout $VERSION_TAG; py -3 scripts\dev\build_release.py --asciidoc C:\Python27\python %userprofile%\bin\asciidoc-8.6.10\asciidoc.py --upload`. -* macOS: Run `git checkout $VERSION_TAG && python3 scripts/dev/build_release.py --upload`. -* On server: - - Run `python3 scripts/dev/download_release.py v1.X.Y` (replace X/Y by hand). - - Run `git pull github master && sudo python3 scripts/asciidoc2html.py --website /srv/http/qutebrowser` +* Run `./.venv/bin/python3 scripts/dev/update_version.py {major,minor,patch}`. +* Run the printed instructions accordingly. * Update `qutebrowser-git` PKGBUILD if dependencies/install changed. * Announce to qutebrowser and qutebrowser-announce mailinglist. diff --git a/scripts/dev/update_version.py b/scripts/dev/update_version.py index a24ae106f..ae1740357 100644 --- a/scripts/dev/update_version.py +++ b/scripts/dev/update_version.py @@ -99,4 +99,27 @@ if __name__ == "__main__": write_appdata(appdata_tree) - print(__version__) + print("Run the following commands to create a new release:") + + print("* Run `git push origin; git push {v}`.".format(v=__version__)) + + print("* Create new release via GitHub", + "(required to upload release artifacts).") + + print("* Linux: Run `git checkout {v} &&".format(v=__version__), + "./.venv/bin/python3 scripts/dev/build_release.py --upload`") + + print("* Windows: Run `git checkout {v};".format(v=__version__), + "py -3 scripts\dev\\build_release.py --asciidoc", + "C:\Python27\python", + "%userprofile%\\bin\\asciidoc-8.6.10\\asciidoc.py --upload`.") + + print("* macOS: Run `git checkout {v} &&".format(v=__version__), + "python3 scripts/dev/build_release.py --upload`.") + + print("* On server:") + print("- Run `python3 scripts/dev/download_release.py", + "v{v}`.".format(v=__version__)) + print("- Run `git pull github master &&", + "sudo python3 scripts/asciidoc2html.py", + "--website /srv/http/qutebrowser`")