2015-03-24 23:14:09 +01:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et:
|
|
|
|
|
2018-02-05 12:19:50 +01:00
|
|
|
# Copyright 2014-2018 Florian Bruhin (The Compiler) <mail@qutebrowser.org>
|
2015-03-24 23:14:09 +01:00
|
|
|
#
|
|
|
|
# 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 <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
"""Build a new release."""
|
|
|
|
|
|
|
|
|
|
|
|
import os
|
2017-12-15 23:08:53 +01:00
|
|
|
import os.path
|
2015-03-24 23:14:09 +01:00
|
|
|
import sys
|
2018-03-11 21:06:31 +01:00
|
|
|
import time
|
2015-03-24 23:14:09 +01:00
|
|
|
import shutil
|
2017-10-02 00:04:12 +02:00
|
|
|
import plistlib
|
2015-03-24 23:14:09 +01:00
|
|
|
import subprocess
|
|
|
|
import argparse
|
2016-01-05 06:49:43 +01:00
|
|
|
import tarfile
|
2016-07-26 16:10:25 +02:00
|
|
|
import tempfile
|
2016-01-05 06:49:43 +01:00
|
|
|
import collections
|
2015-03-24 23:14:09 +01:00
|
|
|
|
2018-06-13 20:15:16 +02:00
|
|
|
try:
|
2018-06-11 19:43:11 +02:00
|
|
|
import winreg
|
2018-06-13 20:15:16 +02:00
|
|
|
except ImportError:
|
|
|
|
pass
|
2018-06-11 19:43:11 +02:00
|
|
|
|
2015-06-28 22:31:30 +02:00
|
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir,
|
2016-04-27 18:30:54 +02:00
|
|
|
os.pardir))
|
2015-03-24 23:14:09 +01:00
|
|
|
|
|
|
|
import qutebrowser
|
2017-09-26 10:47:07 +02:00
|
|
|
from scripts import utils
|
2018-09-24 15:39:07 +02:00
|
|
|
from scripts.dev import update_3rdparty
|
2015-03-24 23:14:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
def call_script(name, *args, python=sys.executable):
|
|
|
|
"""Call a given shell script.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
name: The script to call.
|
|
|
|
*args: The arguments to pass.
|
|
|
|
python: The python interpreter to use.
|
|
|
|
"""
|
2015-08-16 21:30:12 +02:00
|
|
|
path = os.path.join(os.path.dirname(__file__), os.pardir, name)
|
2017-10-23 11:22:56 +02:00
|
|
|
subprocess.run([python, path] + list(args), check=True)
|
2015-03-24 23:14:09 +01:00
|
|
|
|
|
|
|
|
2017-04-14 20:11:40 +02:00
|
|
|
def call_tox(toxenv, *args, python=sys.executable):
|
2016-04-06 20:34:09 +02:00
|
|
|
"""Call tox.
|
2015-06-23 18:36:10 +02:00
|
|
|
|
|
|
|
Args:
|
2016-04-06 20:34:09 +02:00
|
|
|
toxenv: Which tox environment to use
|
2015-06-23 18:36:10 +02:00
|
|
|
*args: The arguments to pass.
|
|
|
|
python: The python interpreter to use.
|
|
|
|
"""
|
|
|
|
env = os.environ.copy()
|
|
|
|
env['PYTHON'] = python
|
2017-05-24 20:52:57 +02:00
|
|
|
env['PATH'] = os.environ['PATH'] + os.pathsep + os.path.dirname(python)
|
2017-10-23 11:22:56 +02:00
|
|
|
subprocess.run(
|
2017-07-04 19:56:54 +02:00
|
|
|
[sys.executable, '-m', 'tox', '-vv', '-e', toxenv] + list(args),
|
2017-10-23 11:22:56 +02:00
|
|
|
env=env, check=True)
|
2015-06-23 18:36:10 +02:00
|
|
|
|
|
|
|
|
2016-01-05 06:49:43 +01:00
|
|
|
def run_asciidoc2html(args):
|
2015-03-24 23:14:09 +01:00
|
|
|
"""Common buildsteps used for all OS'."""
|
2017-09-26 07:25:59 +02:00
|
|
|
utils.print_title("Running asciidoc2html.py")
|
2015-03-24 23:14:09 +01:00
|
|
|
if args.asciidoc is not None:
|
|
|
|
a2h_args = ['--asciidoc'] + args.asciidoc
|
|
|
|
else:
|
|
|
|
a2h_args = []
|
|
|
|
call_script('asciidoc2html.py', *a2h_args)
|
|
|
|
|
|
|
|
|
|
|
|
def _maybe_remove(path):
|
|
|
|
"""Remove a path if it exists."""
|
|
|
|
try:
|
|
|
|
shutil.rmtree(path)
|
|
|
|
except FileNotFoundError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2015-06-23 23:50:14 +02:00
|
|
|
def smoke_test(executable):
|
|
|
|
"""Try starting the given qutebrowser executable."""
|
2017-10-23 11:22:56 +02:00
|
|
|
subprocess.run([executable, '--no-err-windows', '--nowindow',
|
2017-11-02 11:03:19 +01:00
|
|
|
'--temp-basedir', 'about:blank', ':later 500 quit'],
|
2017-10-23 11:22:56 +02:00
|
|
|
check=True)
|
2015-06-23 23:50:14 +02:00
|
|
|
|
|
|
|
|
2017-07-08 11:12:43 +02:00
|
|
|
def patch_mac_app():
|
2018-09-22 18:22:48 +02:00
|
|
|
"""Patch .app to use our Info.plist and save some space."""
|
2017-02-19 15:41:20 +01:00
|
|
|
app_path = os.path.join('dist', 'qutebrowser.app')
|
2018-09-22 18:22:48 +02:00
|
|
|
|
2017-10-05 00:08:50 +02:00
|
|
|
# Patch Info.plist - pyinstaller's options are too limiting
|
2017-10-02 00:04:12 +02:00
|
|
|
plist_path = os.path.join(app_path, 'Contents', 'Info.plist')
|
|
|
|
with open(plist_path, "rb") as f:
|
|
|
|
plist_data = plistlib.load(f)
|
2017-10-03 23:02:03 +02:00
|
|
|
plist_data.update(INFO_PLIST_UPDATES)
|
|
|
|
with open(plist_path, "wb") as f:
|
|
|
|
plistlib.dump(plist_data, f)
|
|
|
|
|
2018-09-22 18:22:48 +02:00
|
|
|
# Replace some duplicate files by symlinks
|
2018-09-24 12:44:31 +02:00
|
|
|
framework_path = os.path.join(app_path, 'Contents', 'Resources', 'PyQt5',
|
|
|
|
'Qt', 'lib', 'QtWebEngineCore.framework')
|
2018-09-22 18:22:48 +02:00
|
|
|
|
|
|
|
core_lib = os.path.join(framework_path, 'Versions', '5', 'QtWebEngineCore')
|
|
|
|
os.remove(core_lib)
|
|
|
|
core_target = os.path.join(*[os.pardir] * 7, 'MacOS', 'QtWebEngineCore')
|
|
|
|
os.symlink(core_target, core_lib)
|
|
|
|
|
|
|
|
framework_resource_path = os.path.join(framework_path, 'Resources')
|
|
|
|
for name in os.listdir(framework_resource_path):
|
|
|
|
file_path = os.path.join(framework_resource_path, name)
|
|
|
|
target = os.path.join(*[os.pardir] * 5, name)
|
|
|
|
if os.path.isdir(file_path):
|
|
|
|
shutil.rmtree(file_path)
|
|
|
|
else:
|
|
|
|
os.remove(file_path)
|
|
|
|
os.symlink(target, file_path)
|
|
|
|
|
2017-10-03 23:02:03 +02:00
|
|
|
|
|
|
|
INFO_PLIST_UPDATES = {
|
2017-10-05 00:13:53 +02:00
|
|
|
'CFBundleVersion': qutebrowser.__version__,
|
|
|
|
'CFBundleShortVersionString': qutebrowser.__version__,
|
2017-10-05 00:08:50 +02:00
|
|
|
'NSSupportsAutomaticGraphicsSwitching': True,
|
|
|
|
'NSHighResolutionCapable': True,
|
2017-10-03 23:02:03 +02:00
|
|
|
'CFBundleURLTypes': [{
|
2017-10-02 00:04:12 +02:00
|
|
|
"CFBundleURLName": "http(s) URL",
|
|
|
|
"CFBundleURLSchemes": ["http", "https"]
|
|
|
|
}, {
|
|
|
|
"CFBundleURLName": "local file URL",
|
|
|
|
"CFBundleURLSchemes": ["file"]
|
2017-10-03 23:02:03 +02:00
|
|
|
}],
|
|
|
|
'CFBundleDocumentTypes': [{
|
|
|
|
"CFBundleTypeExtensions": ["html", "htm"],
|
|
|
|
"CFBundleTypeMIMETypes": ["text/html"],
|
|
|
|
"CFBundleTypeName": "HTML document",
|
|
|
|
"CFBundleTypeOSTypes": ["HTML"],
|
|
|
|
"CFBundleTypeRole": "Viewer",
|
|
|
|
}, {
|
|
|
|
"CFBundleTypeExtensions": ["xhtml"],
|
|
|
|
"CFBundleTypeMIMETypes": ["text/xhtml"],
|
|
|
|
"CFBundleTypeName": "XHTML document",
|
|
|
|
"CFBundleTypeRole": "Viewer",
|
2017-10-02 00:04:12 +02:00
|
|
|
}]
|
2017-10-03 23:02:03 +02:00
|
|
|
}
|
2017-02-19 15:41:20 +01:00
|
|
|
|
|
|
|
|
2017-07-08 11:12:43 +02:00
|
|
|
def build_mac():
|
|
|
|
"""Build macOS .dmg/.app."""
|
2017-09-26 07:25:59 +02:00
|
|
|
utils.print_title("Cleaning up...")
|
2017-07-04 21:03:55 +02:00
|
|
|
for f in ['wc.dmg', 'template.dmg']:
|
|
|
|
try:
|
|
|
|
os.remove(f)
|
|
|
|
except FileNotFoundError:
|
|
|
|
pass
|
|
|
|
for d in ['dist', 'build']:
|
|
|
|
shutil.rmtree(d, ignore_errors=True)
|
2017-09-26 07:25:59 +02:00
|
|
|
utils.print_title("Updating 3rdparty content")
|
2018-09-24 15:39:07 +02:00
|
|
|
update_3rdparty.run(ace=False, pdfjs=True, fancy_dmg=False)
|
2017-09-26 07:25:59 +02:00
|
|
|
utils.print_title("Building .app via pyinstaller")
|
2016-07-26 16:38:18 +02:00
|
|
|
call_tox('pyinstaller', '-r')
|
2017-09-26 07:25:59 +02:00
|
|
|
utils.print_title("Patching .app")
|
2017-07-08 11:12:43 +02:00
|
|
|
patch_mac_app()
|
2017-09-26 07:25:59 +02:00
|
|
|
utils.print_title("Building .dmg")
|
2017-10-23 11:22:56 +02:00
|
|
|
subprocess.run(['make', '-f', 'scripts/dev/Makefile-dmg'], check=True)
|
2016-04-06 20:34:09 +02:00
|
|
|
|
2016-08-02 22:25:31 +02:00
|
|
|
dmg_name = 'qutebrowser-{}.dmg'.format(qutebrowser.__version__)
|
|
|
|
os.rename('qutebrowser.dmg', dmg_name)
|
|
|
|
|
2017-09-26 07:25:59 +02:00
|
|
|
utils.print_title("Running smoke test")
|
2017-07-04 22:16:21 +02:00
|
|
|
|
|
|
|
try:
|
|
|
|
with tempfile.TemporaryDirectory() as tmpdir:
|
2017-10-23 11:22:56 +02:00
|
|
|
subprocess.run(['hdiutil', 'attach', dmg_name,
|
|
|
|
'-mountpoint', tmpdir], check=True)
|
2017-07-04 22:16:21 +02:00
|
|
|
try:
|
|
|
|
binary = os.path.join(tmpdir, 'qutebrowser.app', 'Contents',
|
|
|
|
'MacOS', 'qutebrowser')
|
|
|
|
smoke_test(binary)
|
|
|
|
finally:
|
2018-03-11 21:06:31 +01:00
|
|
|
time.sleep(5)
|
2017-10-23 11:22:56 +02:00
|
|
|
subprocess.run(['hdiutil', 'detach', tmpdir])
|
2017-07-04 22:16:21 +02:00
|
|
|
except PermissionError as e:
|
|
|
|
print("Failed to remove tempdir: {}".format(e))
|
2016-07-26 16:10:25 +02:00
|
|
|
|
2017-07-08 11:12:43 +02:00
|
|
|
return [(dmg_name, 'application/x-apple-diskimage', 'macOS .dmg')]
|
2016-08-02 22:25:31 +02:00
|
|
|
|
2016-04-06 20:34:09 +02:00
|
|
|
|
2015-03-24 23:14:09 +01:00
|
|
|
def build_windows():
|
|
|
|
"""Build windows executables/setups."""
|
2017-09-26 07:25:59 +02:00
|
|
|
utils.print_title("Updating 3rdparty content")
|
2018-09-24 15:39:07 +02:00
|
|
|
update_3rdparty.run(ace=False, pdfjs=True, fancy_dmg=False)
|
2016-01-05 07:27:58 +01:00
|
|
|
|
2017-09-26 07:25:59 +02:00
|
|
|
utils.print_title("Building Windows binaries")
|
2015-03-24 23:14:09 +01:00
|
|
|
parts = str(sys.version_info.major), str(sys.version_info.minor)
|
|
|
|
ver = ''.join(parts)
|
2018-06-11 19:43:11 +02:00
|
|
|
dot_ver = '.'.join(parts)
|
|
|
|
|
|
|
|
# Get python path from registry if possible
|
|
|
|
try:
|
|
|
|
reg64_key = winreg.OpenKeyEx(winreg.HKEY_LOCAL_MACHINE,
|
2018-06-11 23:27:43 +02:00
|
|
|
r'SOFTWARE\Python\PythonCore'
|
|
|
|
r'\{}\InstallPath'.format(dot_ver))
|
2018-06-11 19:43:11 +02:00
|
|
|
python_x64 = winreg.QueryValueEx(reg64_key, 'ExecutablePath')[0]
|
|
|
|
except FileNotFoundError:
|
|
|
|
python_x64 = r'C:\Python{}\python.exe'.format(ver)
|
|
|
|
|
2017-04-14 20:46:35 +02:00
|
|
|
out_pyinstaller = os.path.join('dist', 'qutebrowser')
|
|
|
|
out_64 = os.path.join('dist',
|
2017-04-14 20:01:57 +02:00
|
|
|
'qutebrowser-{}-x64'.format(qutebrowser.__version__))
|
2015-03-24 23:14:09 +01:00
|
|
|
|
2016-08-02 22:25:31 +02:00
|
|
|
artifacts = []
|
|
|
|
|
2018-07-03 11:38:48 +02:00
|
|
|
from scripts.dev import gen_versioninfo
|
2018-04-20 16:48:51 +02:00
|
|
|
utils.print_title("Updating VersionInfo file")
|
2018-06-10 01:24:47 +02:00
|
|
|
gen_versioninfo.main()
|
2018-04-20 16:48:51 +02:00
|
|
|
|
2017-09-26 07:25:59 +02:00
|
|
|
utils.print_title("Running pyinstaller 64bit")
|
2017-04-14 22:10:45 +02:00
|
|
|
_maybe_remove(out_64)
|
2017-04-14 20:46:35 +02:00
|
|
|
call_tox('pyinstaller', '-r', python=python_x64)
|
2017-04-14 20:01:57 +02:00
|
|
|
shutil.move(out_pyinstaller, out_64)
|
|
|
|
|
2018-09-19 11:10:17 +02:00
|
|
|
utils.print_title("Running 64bit smoke test")
|
|
|
|
smoke_test(os.path.join(out_64, 'qutebrowser.exe'))
|
|
|
|
|
2017-09-26 07:25:59 +02:00
|
|
|
utils.print_title("Building installers")
|
2017-10-23 11:22:56 +02:00
|
|
|
subprocess.run(['makensis.exe',
|
|
|
|
'/DX64',
|
|
|
|
'/DVERSION={}'.format(qutebrowser.__version__),
|
|
|
|
'misc/qutebrowser.nsi'], check=True)
|
2017-05-23 22:29:44 +02:00
|
|
|
|
2017-07-04 22:27:17 +02:00
|
|
|
name_64 = 'qutebrowser-{}-amd64.exe'.format(qutebrowser.__version__)
|
2017-05-23 22:29:44 +02:00
|
|
|
|
|
|
|
artifacts += [
|
|
|
|
(os.path.join('dist', name_64),
|
|
|
|
'application/vnd.microsoft.portable-executable',
|
|
|
|
'Windows 64bit installer'),
|
|
|
|
]
|
2016-08-02 22:25:31 +02:00
|
|
|
|
2017-09-26 07:25:59 +02:00
|
|
|
utils.print_title("Zipping 64bit standalone...")
|
2015-03-24 23:14:09 +01:00
|
|
|
name = 'qutebrowser-{}-windows-standalone-amd64'.format(
|
|
|
|
qutebrowser.__version__)
|
2017-04-14 22:10:45 +02:00
|
|
|
shutil.make_archive(name, 'zip', 'dist', os.path.basename(out_64))
|
2016-08-02 22:25:31 +02:00
|
|
|
artifacts.append(('{}.zip'.format(name),
|
|
|
|
'application/zip',
|
|
|
|
'Windows 64bit standalone'))
|
2015-03-24 23:14:09 +01:00
|
|
|
|
2016-08-02 22:25:31 +02:00
|
|
|
return artifacts
|
2015-03-24 23:14:09 +01:00
|
|
|
|
|
|
|
|
2016-01-05 06:49:43 +01:00
|
|
|
def build_sdist():
|
|
|
|
"""Build an sdist and list the contents."""
|
2017-09-26 07:25:59 +02:00
|
|
|
utils.print_title("Building sdist")
|
2016-01-05 06:49:43 +01:00
|
|
|
|
2016-01-05 07:14:11 +01:00
|
|
|
_maybe_remove('dist')
|
2016-01-05 06:49:43 +01:00
|
|
|
|
2017-10-23 11:22:56 +02:00
|
|
|
subprocess.run([sys.executable, 'setup.py', 'sdist'], check=True)
|
2016-01-05 06:49:43 +01:00
|
|
|
dist_files = os.listdir(os.path.abspath('dist'))
|
|
|
|
assert len(dist_files) == 1
|
|
|
|
|
|
|
|
dist_file = os.path.join('dist', dist_files[0])
|
2017-10-23 11:22:56 +02:00
|
|
|
subprocess.run(['gpg', '--detach-sign', '-a', dist_file], check=True)
|
2016-01-05 06:49:43 +01:00
|
|
|
|
|
|
|
tar = tarfile.open(dist_file)
|
|
|
|
by_ext = collections.defaultdict(list)
|
|
|
|
|
|
|
|
for tarinfo in tar.getmembers():
|
|
|
|
if not tarinfo.isfile():
|
|
|
|
continue
|
|
|
|
name = os.sep.join(tarinfo.name.split(os.sep)[1:])
|
|
|
|
_base, ext = os.path.splitext(name)
|
|
|
|
by_ext[ext].append(name)
|
|
|
|
|
|
|
|
assert '.pyc' not in by_ext
|
|
|
|
|
2017-09-26 07:25:59 +02:00
|
|
|
utils.print_title("sdist contents")
|
2016-01-05 06:49:43 +01:00
|
|
|
|
|
|
|
for ext, files in sorted(by_ext.items()):
|
2017-09-26 07:25:59 +02:00
|
|
|
utils.print_subtitle(ext)
|
2016-01-05 06:49:43 +01:00
|
|
|
print('\n'.join(files))
|
|
|
|
|
2016-08-02 22:25:31 +02:00
|
|
|
filename = 'qutebrowser-{}.tar.gz'.format(qutebrowser.__version__)
|
|
|
|
artifacts = [
|
|
|
|
(os.path.join('dist', filename), 'application/gzip', 'Source release'),
|
|
|
|
(os.path.join('dist', filename + '.asc'), 'application/pgp-signature',
|
|
|
|
'Source release - PGP signature'),
|
|
|
|
]
|
|
|
|
|
|
|
|
return artifacts
|
|
|
|
|
|
|
|
|
2018-01-15 22:42:12 +01:00
|
|
|
def test_makefile():
|
|
|
|
"""Make sure the Makefile works correctly."""
|
|
|
|
utils.print_title("Testing makefile")
|
|
|
|
with tempfile.TemporaryDirectory() as tmpdir:
|
|
|
|
subprocess.run(['make', '-f', 'misc/Makefile',
|
|
|
|
'DESTDIR={}'.format(tmpdir), 'install'], check=True)
|
|
|
|
|
|
|
|
|
2017-07-07 14:28:36 +02:00
|
|
|
def read_github_token():
|
|
|
|
"""Read the GitHub API token from disk."""
|
|
|
|
token_file = os.path.join(os.path.expanduser('~'), '.gh_token')
|
|
|
|
with open(token_file, encoding='ascii') as f:
|
|
|
|
token = f.read().strip()
|
2017-07-07 15:18:05 +02:00
|
|
|
return token
|
2017-07-07 14:28:36 +02:00
|
|
|
|
|
|
|
|
2016-08-02 22:25:31 +02:00
|
|
|
def github_upload(artifacts, tag):
|
|
|
|
"""Upload the given artifacts to GitHub.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
artifacts: A list of (filename, mimetype, description) tuples
|
|
|
|
tag: The name of the release tag
|
|
|
|
"""
|
|
|
|
import github3
|
2017-09-26 07:25:59 +02:00
|
|
|
utils.print_title("Uploading to github...")
|
2016-08-02 22:25:31 +02:00
|
|
|
|
2017-07-07 14:28:36 +02:00
|
|
|
token = read_github_token()
|
2016-08-02 22:25:31 +02:00
|
|
|
gh = github3.login(token=token)
|
2017-04-14 18:09:01 +02:00
|
|
|
repo = gh.repository('qutebrowser', 'qutebrowser')
|
2016-08-02 22:25:31 +02:00
|
|
|
|
|
|
|
release = None # to satisfy pylint
|
2018-03-14 21:11:03 +01:00
|
|
|
for release in repo.releases():
|
2016-08-02 22:25:31 +02:00
|
|
|
if release.tag_name == tag:
|
|
|
|
break
|
|
|
|
else:
|
|
|
|
raise Exception("No release found for {!r}!".format(tag))
|
|
|
|
|
|
|
|
for filename, mimetype, description in artifacts:
|
|
|
|
with open(filename, 'rb') as f:
|
|
|
|
basename = os.path.basename(filename)
|
|
|
|
asset = release.upload_asset(mimetype, basename, f)
|
2016-11-05 23:35:56 +01:00
|
|
|
asset.edit(basename, description)
|
2016-08-02 22:25:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
def pypi_upload(artifacts):
|
|
|
|
"""Upload the given artifacts to PyPI using twine."""
|
|
|
|
filenames = [a[0] for a in artifacts]
|
2017-10-23 11:22:56 +02:00
|
|
|
subprocess.run(['twine', 'upload'] + filenames, check=True)
|
2016-08-02 22:25:31 +02:00
|
|
|
|
2016-01-05 06:49:43 +01:00
|
|
|
|
2015-03-24 23:14:09 +01:00
|
|
|
def main():
|
|
|
|
parser = argparse.ArgumentParser()
|
2018-09-19 11:13:01 +02:00
|
|
|
parser.add_argument('--no-asciidoc', action='store_true',
|
|
|
|
help="Don't generate docs")
|
2015-03-24 23:14:09 +01:00
|
|
|
parser.add_argument('--asciidoc', help="Full path to python and "
|
|
|
|
"asciidoc.py. If not given, it's searched in PATH.",
|
|
|
|
nargs=2, required=False,
|
|
|
|
metavar=('PYTHON', 'ASCIIDOC'))
|
2016-08-02 22:25:31 +02:00
|
|
|
parser.add_argument('--upload', help="Tag to upload the release for",
|
|
|
|
nargs=1, required=False, metavar='TAG')
|
2015-03-24 23:14:09 +01:00
|
|
|
args = parser.parse_args()
|
2017-09-26 07:25:59 +02:00
|
|
|
utils.change_cwd()
|
2016-01-05 06:49:43 +01:00
|
|
|
|
2016-08-02 22:25:31 +02:00
|
|
|
upload_to_pypi = False
|
|
|
|
|
2017-07-07 14:28:36 +02:00
|
|
|
if args.upload is not None:
|
|
|
|
# Fail early when trying to upload without github3 installed
|
|
|
|
# or without API token
|
2018-11-28 13:01:43 +01:00
|
|
|
import github3 # pylint: disable=unused-import
|
2017-07-07 14:28:36 +02:00
|
|
|
read_github_token()
|
|
|
|
|
2018-09-19 11:39:21 +02:00
|
|
|
if args.no_asciidoc:
|
2018-09-19 15:14:24 +02:00
|
|
|
os.makedirs(os.path.join('qutebrowser', 'html', 'doc'), exist_ok=True)
|
2018-09-19 11:39:21 +02:00
|
|
|
else:
|
2018-09-19 11:13:01 +02:00
|
|
|
run_asciidoc2html(args)
|
|
|
|
|
2017-09-26 07:25:59 +02:00
|
|
|
if os.name == 'nt':
|
2016-08-02 22:25:31 +02:00
|
|
|
artifacts = build_windows()
|
2017-09-26 07:25:59 +02:00
|
|
|
elif sys.platform == 'darwin':
|
2017-07-08 11:12:43 +02:00
|
|
|
artifacts = build_mac()
|
2015-03-24 23:14:09 +01:00
|
|
|
else:
|
2018-01-15 22:42:12 +01:00
|
|
|
test_makefile()
|
2016-08-02 22:25:31 +02:00
|
|
|
artifacts = build_sdist()
|
|
|
|
upload_to_pypi = True
|
|
|
|
|
|
|
|
if args.upload is not None:
|
2017-09-26 07:25:59 +02:00
|
|
|
utils.print_title("Press enter to release...")
|
2016-08-02 22:25:31 +02:00
|
|
|
input()
|
|
|
|
github_upload(artifacts, args.upload[0])
|
|
|
|
if upload_to_pypi:
|
|
|
|
pypi_upload(artifacts)
|
2017-09-26 07:12:38 +02:00
|
|
|
else:
|
|
|
|
print()
|
2017-09-26 07:25:59 +02:00
|
|
|
utils.print_title("Artifacts")
|
2017-09-26 07:12:38 +02:00
|
|
|
for artifact in artifacts:
|
|
|
|
print(artifact)
|
2015-03-24 23:14:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|