mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-22 15:37:45 +00:00
release: revamped release upload process
This commit is contained in:
parent
8792e07210
commit
fc23deb9f3
51
.travis.yml
51
.travis.yml
@ -18,15 +18,15 @@ matrix:
|
|||||||
include:
|
include:
|
||||||
# - python: 3.6
|
# - python: 3.6
|
||||||
# env: TOXENV=lint
|
# env: TOXENV=lint
|
||||||
# - os: osx
|
- os: osx
|
||||||
# osx_image: xcode7.3
|
osx_image: xcode7.3
|
||||||
# language: generic
|
language: generic
|
||||||
# env: TOXENV=py35 BDIST=1
|
env: TOXENV=py36 BDIST=1
|
||||||
# - python: 3.5
|
# - python: 3.5
|
||||||
# env: TOXENV=py35 BDIST=1
|
# env: TOXENV=py35
|
||||||
# dist: precise
|
# dist: precise
|
||||||
# - python: 3.6
|
# - python: 3.6
|
||||||
# env: TOXENV=py36
|
# env: TOXENV=py36 BDIST=1
|
||||||
# - python: 3.6
|
# - python: 3.6
|
||||||
# env: TOXENV=individual_coverage
|
# env: TOXENV=individual_coverage
|
||||||
# - language: node_js
|
# - language: node_js
|
||||||
@ -42,17 +42,17 @@ matrix:
|
|||||||
# yarn: true
|
# yarn: true
|
||||||
# directories:
|
# directories:
|
||||||
# - web/node_modules
|
# - web/node_modules
|
||||||
- language: python
|
# - language: python
|
||||||
env:
|
# env:
|
||||||
- NAME=docs
|
# - NAME=docs
|
||||||
install:
|
# install:
|
||||||
- wget https://github.com/gohugoio/hugo/releases/download/v0.37/hugo_0.37_Linux-64bit.deb
|
# - wget https://github.com/gohugoio/hugo/releases/download/v0.37/hugo_0.37_Linux-64bit.deb
|
||||||
- sudo dpkg -i hugo*.deb
|
# - sudo dpkg -i hugo*.deb
|
||||||
- pip install awscli
|
# - pip install awscli
|
||||||
script:
|
# script:
|
||||||
- cd docs && ./ci
|
# - cd docs && ./ci
|
||||||
after_success:
|
# after_success:
|
||||||
- echo done
|
# - echo done
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- |
|
- |
|
||||||
@ -61,12 +61,11 @@ install:
|
|||||||
brew update || brew update
|
brew update || brew update
|
||||||
brew outdated pyenv || brew upgrade pyenv
|
brew outdated pyenv || brew upgrade pyenv
|
||||||
eval "$(pyenv init -)"
|
eval "$(pyenv init -)"
|
||||||
env PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install --skip-existing 3.5.3
|
env PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install --skip-existing 3.6.4
|
||||||
pyenv global 3.5.3
|
pyenv global 3.6.4
|
||||||
pyenv shell 3.5.3
|
pyenv shell 3.6.4
|
||||||
pip install -U pip setuptools wheel virtualenv
|
|
||||||
fi
|
fi
|
||||||
- pip install tox
|
- pip install tox virtualenv setuptools
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- tox -- --verbose --cov-report=term
|
- tox -- --verbose --cov-report=term
|
||||||
@ -74,16 +73,14 @@ script:
|
|||||||
if [[ $BDIST == "1" ]]
|
if [[ $BDIST == "1" ]]
|
||||||
then
|
then
|
||||||
git fetch --unshallow --tags
|
git fetch --unshallow --tags
|
||||||
tox -e rtool -- bdist
|
tox -e cibuild -- build
|
||||||
fi
|
fi
|
||||||
|
|
||||||
after_success:
|
after_success:
|
||||||
# we build binaries on every run, but we only upload them for master snapshots or tags.
|
|
||||||
- |
|
- |
|
||||||
if [[ $BDIST == "1" && $TRAVIS_PULL_REQUEST == "false" && ($TRAVIS_BRANCH == "pyinstaller" || $TRAVIS_BRANCH == "master" || -n $TRAVIS_TAG) ]]
|
if [[ $BDIST == "1" ]]
|
||||||
then
|
then
|
||||||
tox -e rtool -- decrypt release/known_hosts.enc release/known_hosts
|
tox -e cibuild -- upload
|
||||||
tox -e rtool -- upload-snapshot --bdist
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
|
2
docs/ci
2
docs/ci
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
# Only upload if we have defined credentials - we only have these defined for
|
# Only upload if we have defined credentials - we only have these defined for
|
||||||
# trusted commits (i.e. not PRs).
|
# trusted commits (i.e. not PRs).
|
||||||
if [[ ! -z "${AWS_ACCESS_KEY_ID}" && $TRAVIS_BRANCH == "updocs" ]]; then
|
if [[ ! -z "${AWS_ACCESS_KEY_ID}" && $TRAVIS_BRANCH == "master" ]]; then
|
||||||
aws s3 sync --acl public-read ./public s3://docs.mitmproxy.org/master
|
aws s3 sync --acl public-read ./public s3://docs.mitmproxy.org/master
|
||||||
# aws cloudfront create-invalidation --distribution-id E3UCZ4MLN4TO7U \
|
# aws cloudfront create-invalidation --distribution-id E3UCZ4MLN4TO7U \
|
||||||
# --paths "/master"
|
# --paths "/master"
|
||||||
|
250
release/ci.py
Executable file
250
release/ci.py
Executable file
@ -0,0 +1,250 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import contextlib
|
||||||
|
import os
|
||||||
|
import platform
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
import shutil
|
||||||
|
import subprocess
|
||||||
|
import tarfile
|
||||||
|
import zipfile
|
||||||
|
from os.path import join, abspath, dirname, exists, basename
|
||||||
|
|
||||||
|
import click
|
||||||
|
|
||||||
|
# https://virtualenv.pypa.io/en/latest/userguide.html#windows-notes
|
||||||
|
# scripts and executables on Windows go in ENV\Scripts\ instead of ENV/bin/
|
||||||
|
if platform.system() == "Windows":
|
||||||
|
VENV_BIN = "Scripts"
|
||||||
|
PYINSTALLER_ARGS = [
|
||||||
|
# PyInstaller < 3.2 does not handle Python 3.5's ucrt correctly.
|
||||||
|
"-p", r"C:\Program Files (x86)\Windows Kits\10\Redist\ucrt\DLLs\x86",
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
VENV_BIN = "bin"
|
||||||
|
PYINSTALLER_ARGS = []
|
||||||
|
|
||||||
|
# ZipFile and tarfile have slightly different APIs. Fix that.
|
||||||
|
if platform.system() == "Windows":
|
||||||
|
def Archive(name):
|
||||||
|
a = zipfile.ZipFile(name, "w")
|
||||||
|
a.add = a.write
|
||||||
|
return a
|
||||||
|
else:
|
||||||
|
def Archive(name):
|
||||||
|
return tarfile.open(name, "w:gz")
|
||||||
|
|
||||||
|
PLATFORM_TAG = {
|
||||||
|
"Darwin": "osx",
|
||||||
|
"Windows": "windows",
|
||||||
|
"Linux": "linux",
|
||||||
|
}.get(platform.system(), platform.system())
|
||||||
|
|
||||||
|
ROOT_DIR = abspath(join(dirname(__file__), ".."))
|
||||||
|
RELEASE_DIR = join(ROOT_DIR, "release")
|
||||||
|
|
||||||
|
BUILD_DIR = join(RELEASE_DIR, "build")
|
||||||
|
DIST_DIR = join(RELEASE_DIR, "dist")
|
||||||
|
|
||||||
|
PYINSTALLER_SPEC = join(RELEASE_DIR, "specs")
|
||||||
|
# PyInstaller 3.2 does not bundle pydivert's Windivert binaries
|
||||||
|
PYINSTALLER_HOOKS = join(RELEASE_DIR, "hooks")
|
||||||
|
PYINSTALLER_TEMP = join(BUILD_DIR, "pyinstaller")
|
||||||
|
PYINSTALLER_DIST = join(BUILD_DIR, "binaries", PLATFORM_TAG)
|
||||||
|
|
||||||
|
VENV_DIR = join(BUILD_DIR, "venv")
|
||||||
|
|
||||||
|
# Project Configuration
|
||||||
|
SNAPSHOT_BRANCHES = ["master", "updocs"]
|
||||||
|
VERSION_FILE = join(ROOT_DIR, "mitmproxy", "version.py")
|
||||||
|
BDISTS = {
|
||||||
|
"mitmproxy": ["mitmproxy", "mitmdump", "mitmweb"],
|
||||||
|
"pathod": ["pathoc", "pathod"]
|
||||||
|
}
|
||||||
|
if platform.system() == "Windows":
|
||||||
|
BDISTS["mitmproxy"].remove("mitmproxy")
|
||||||
|
|
||||||
|
TOOLS = [
|
||||||
|
tool
|
||||||
|
for tools in sorted(BDISTS.values())
|
||||||
|
for tool in tools
|
||||||
|
]
|
||||||
|
|
||||||
|
if os.environ.get("TRAVIS_TAG", None):
|
||||||
|
VERSION = os.environ["TRAVIS_TAG"]
|
||||||
|
elif os.environ.get("TRAVIS_BRANCH", None) in SNAPSHOT_BRANCHES:
|
||||||
|
VERSION = os.environ["TRAVIS_BRANCH"]
|
||||||
|
else:
|
||||||
|
print("Branch %s is not buildabranch - exiting." % os.environ.get("TRAVIS_BRANCH", None))
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
print("BUILD VERSION=%s" % VERSION)
|
||||||
|
|
||||||
|
|
||||||
|
def set_version(dev: bool) -> None:
|
||||||
|
"""
|
||||||
|
Update version information in mitmproxy's version.py to either include hardcoded information or not.
|
||||||
|
"""
|
||||||
|
version = get_version(dev, dev)
|
||||||
|
with open(VERSION_FILE, "r") as f:
|
||||||
|
content = f.read()
|
||||||
|
content = re.sub(r'^VERSION = ".+?"', 'VERSION = "{}"'.format(version), content, flags=re.M)
|
||||||
|
with open(VERSION_FILE, "w") as f:
|
||||||
|
f.write(content)
|
||||||
|
|
||||||
|
|
||||||
|
def archive_name(bdist: str) -> str:
|
||||||
|
if platform.system() == "Windows":
|
||||||
|
ext = "zip"
|
||||||
|
else:
|
||||||
|
ext = "tar.gz"
|
||||||
|
return "{project}-{version}-{platform}.{ext}".format(
|
||||||
|
project=bdist,
|
||||||
|
version=VERSION,
|
||||||
|
platform=PLATFORM_TAG,
|
||||||
|
ext=ext
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def wheel_name() -> str:
|
||||||
|
return "mitmproxy-{version}-py3-none-any.whl".format(version=VERSION)
|
||||||
|
|
||||||
|
|
||||||
|
def installer_name() -> str:
|
||||||
|
ext = {
|
||||||
|
"Windows": "exe",
|
||||||
|
"Darwin": "dmg",
|
||||||
|
"Linux": "run"
|
||||||
|
}[platform.system()]
|
||||||
|
return "mitmproxy-{version}-{platform}-installer.{ext}".format(
|
||||||
|
version=VERSION,
|
||||||
|
platform=PLATFORM_TAG,
|
||||||
|
ext=ext,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@contextlib.contextmanager
|
||||||
|
def chdir(path: str):
|
||||||
|
old_dir = os.getcwd()
|
||||||
|
os.chdir(path)
|
||||||
|
yield
|
||||||
|
os.chdir(old_dir)
|
||||||
|
|
||||||
|
|
||||||
|
@click.group(chain=True)
|
||||||
|
def cli():
|
||||||
|
"""
|
||||||
|
mitmproxy build tool
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
@cli.command("info")
|
||||||
|
def info():
|
||||||
|
print("Version: %s" % VERSION)
|
||||||
|
|
||||||
|
|
||||||
|
@cli.command("wheel")
|
||||||
|
def make_wheel():
|
||||||
|
"""
|
||||||
|
Build a Python wheel
|
||||||
|
"""
|
||||||
|
set_version(True)
|
||||||
|
try:
|
||||||
|
subprocess.check_call([
|
||||||
|
"tox", "-e", "wheel",
|
||||||
|
], env={
|
||||||
|
**os.environ,
|
||||||
|
"VERSION": VERSION,
|
||||||
|
})
|
||||||
|
finally:
|
||||||
|
set_version(False)
|
||||||
|
|
||||||
|
|
||||||
|
@cli.command("build")
|
||||||
|
def build():
|
||||||
|
"""
|
||||||
|
Build a binary distribution
|
||||||
|
"""
|
||||||
|
if exists(PYINSTALLER_TEMP):
|
||||||
|
shutil.rmtree(PYINSTALLER_TEMP)
|
||||||
|
if exists(PYINSTALLER_DIST):
|
||||||
|
shutil.rmtree(PYINSTALLER_DIST)
|
||||||
|
|
||||||
|
os.makedirs(DIST_DIR, exist_ok=True)
|
||||||
|
|
||||||
|
for bdist, tools in sorted(BDISTS.items()):
|
||||||
|
with Archive(join(DIST_DIR, archive_name(bdist))) as archive:
|
||||||
|
for tool in tools:
|
||||||
|
# We can't have a folder and a file with the same name.
|
||||||
|
if tool == "mitmproxy":
|
||||||
|
tool = "mitmproxy_main"
|
||||||
|
# This is PyInstaller, so it messes up paths.
|
||||||
|
# We need to make sure that we are in the spec folder.
|
||||||
|
with chdir(PYINSTALLER_SPEC):
|
||||||
|
print("Building %s binary..." % tool)
|
||||||
|
excludes = []
|
||||||
|
if tool != "mitmweb":
|
||||||
|
excludes.append("mitmproxy.tools.web")
|
||||||
|
if tool != "mitmproxy_main":
|
||||||
|
excludes.append("mitmproxy.tools.console")
|
||||||
|
|
||||||
|
subprocess.check_call(
|
||||||
|
[
|
||||||
|
"pyinstaller",
|
||||||
|
"--clean",
|
||||||
|
"--workpath", PYINSTALLER_TEMP,
|
||||||
|
"--distpath", PYINSTALLER_DIST,
|
||||||
|
"--additional-hooks-dir", PYINSTALLER_HOOKS,
|
||||||
|
"--onefile",
|
||||||
|
"--console",
|
||||||
|
"--icon", "icon.ico",
|
||||||
|
# This is PyInstaller, so setting a
|
||||||
|
# different log level obviously breaks it :-)
|
||||||
|
# "--log-level", "WARN",
|
||||||
|
]
|
||||||
|
+ [x for e in excludes for x in ["--exclude-module", e]]
|
||||||
|
+ PYINSTALLER_ARGS
|
||||||
|
+ [tool]
|
||||||
|
)
|
||||||
|
# Delete the spec file - we're good without.
|
||||||
|
os.remove("{}.spec".format(tool))
|
||||||
|
|
||||||
|
# Test if it works at all O:-)
|
||||||
|
executable = join(PYINSTALLER_DIST, tool)
|
||||||
|
if platform.system() == "Windows":
|
||||||
|
executable += ".exe"
|
||||||
|
|
||||||
|
# Remove _main suffix from mitmproxy executable
|
||||||
|
if "_main" in executable:
|
||||||
|
shutil.move(
|
||||||
|
executable,
|
||||||
|
executable.replace("_main", "")
|
||||||
|
)
|
||||||
|
executable = executable.replace("_main", "")
|
||||||
|
|
||||||
|
print("> %s --version" % executable)
|
||||||
|
print(subprocess.check_output([executable, "--version"]).decode())
|
||||||
|
|
||||||
|
archive.add(executable, basename(executable))
|
||||||
|
print("Packed {}.".format(archive_name(bdist)))
|
||||||
|
|
||||||
|
|
||||||
|
@cli.command("upload")
|
||||||
|
def upload():
|
||||||
|
"""
|
||||||
|
Upload snapshot to snapshot server
|
||||||
|
"""
|
||||||
|
subprocess.check_call(
|
||||||
|
[
|
||||||
|
"aws", "s3", "cp",
|
||||||
|
"--acl", "public-read",
|
||||||
|
DIST_DIR + "/",
|
||||||
|
"s3://snapshots.mitmproxy.org/%s/" % VERSION,
|
||||||
|
"--recursive",
|
||||||
|
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6i-BiGmCHt3iDxR1Fkm31b50kWW3jCe6fcwMDeu3I_8mkQs_7mCFUjSDbvFUr2Y45a5guRlw63_KUW_mNN9td9hk8POWfxWEGhcZ9eRXh_eEdEaYZmviZdHi0I8pV52CqiEO-ZrnMw-w4rSpUQeRn9oKwp3GgB9j51RNlLqK9LTp-jfSGGi5GM-ab9sPgFCJLQ-HvHdGu0tQsF2wTD3qbJwNqapx28yNVfY6e8F2jOWjmP-zzFez8VNXcfoS--Ji_zI-VqsDx-cfz3DccWEjL6vjQOvaQTRwzhI7
|
|
@ -1,68 +0,0 @@
|
|||||||
-----BEGIN RSA PRIVATE KEY-----
|
|
||||||
Proc-Type: 4,ENCRYPTED
|
|
||||||
DEK-Info: AES-128-CBC,7A4E07094E1AC0B74BB3D172A73A62DB
|
|
||||||
|
|
||||||
0H4otaU3/McUviuQh/6L1tQM/gUjAc0nn1QESZ/n2R/VOlmLGwYPlMxHLXcs6a+y
|
|
||||||
byfQc/wcy1taPHSIVbEH1bYUfrFucLhlOq8jINPfsMqhPRGbH7DwTfAFNljZTGLU
|
|
||||||
V9zMXedIGujOdbJ29gClbYkaNbHB7wd+7icpRMJ/buEC5W9lZXpt5kspsG9Ueu6Z
|
|
||||||
T6rljxOQ5lyLun9E0y8H/f/RLViEyeEBSGK3UAHzz7+OJjKkKzVLfAFF2It4rfIh
|
|
||||||
PdFBhfyp3ihfs4Dy+eG2LzVSZC+D01uj0WkhGwIGzpB4XAgNjtbUeaz9o8649lLl
|
|
||||||
w4QuoX2cxbcLj4KVqSCml8aHA18oNtBdGx/s/+26bopmapcLwp01G51T/MMJTVpD
|
|
||||||
P+6GoFvHxE7YKasJV2fxQW70U3B8Ruu5ImZkKa9Dw7VI1XL0DY/WvQ46tYZqllyt
|
|
||||||
JeHxg21z0MeH6RiU7aT79tYB1KNcuuq9ujPFOSAED0C7TUEycvN4tyySPxqBAnBE
|
|
||||||
yHT0UU3AE1VpQJaYDlQWrZPC813WoPI8pjLw+v99f918TWOOQk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G3IljaBijzzwMGkEXmPiO+4WM/mp8dv29GpNj0/Dr8L/hYGcZ87CzWGnSu93yToi
|
|
||||||
o1paUjM1zmK0CKHKda8FxaVUchIHEmi4DGxY1Ywj0NjeV5U3VQpLQawGm88aqdkq
|
|
||||||
2aF5annHPNfp5tncL3eySrZxy6Yy9hI1/CCxV9r/31JZdRofqwftgKyxrTN0TzXL
|
|
||||||
5fpvzZQly1B46yVzUUjPkez+t18Rr9i7Js/Dxop2+IHx1EDAlkeoz4OIDa6fUssp
|
|
||||||
30eVjsy4QTV65HUS2vIraoqvKHwiabqz+QU/k6EVmln5cM6fuqN4m9HBiGVVLTac
|
|
||||||
7WAzuW7D5mmIGXtl4JdoLXW9NuKAn7MIBixhlWY8/rdvBGRJ4zHQxM3RTmcAlaEA
|
|
||||||
1/BoQUNXundypyFO/dYH01N4N4TNJDXTpOslmJHc78c09w4PN6/MjQMF8SkTHCJ8
|
|
||||||
eKPXxQOh7arK/ibyhT6cVE29BmBS2OAeIYxRpqVOxndnSv+dpH02L5NjgDi97YIB
|
|
||||||
bb2zMqyy+0ajQexov+PH1X2bxMLgY7GZ9zJ3GEyrq3MXYCLkR7IKm6R45xNMhFPO
|
|
||||||
VWx0CLZCFIiHbdUg1YPWhaqHK5fqIAlQSDgdurnWvvz3Y9gnbZxuzMQt4sAwiN/+
|
|
||||||
2XM5ekMi50JEtiUyIggtLJl/0HAiGeAEld9Gbtl1uTQjngC1i6fLzvvBwUCQQ175
|
|
||||||
-----END RSA PRIVATE KEY-----
|
|
||||||
-----BEGIN PUBLIC KEY-----
|
|
||||||
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAs0xeGx+bc+NCLGRJDr6y
|
|
||||||
qv825685l1Tb6lhLvYVYUFJfcxL1V79ML13CO09TPxGTbmKw7iI33ef9N2mUHHVe
|
|
||||||
24EjcSnYZ2Zx5zYIY4ejnDKCzM0md9XA3RpfTI9F3zGsJPt72veyHy6alCbF4NgX
|
|
||||||
FgAvp2UJmWwTLnJj3oIEwfGJeEcQRKjCFjSJlHGxbB6L0MSCgRtDxwlBfinzkriZ
|
|
||||||
0C8YyVv6u+DidHtobbZvwk/4uV3+KhoDfkpT2VE57a2KXr4c9Fekzr6szduFMkcI
|
|
||||||
KPqKouOOnaiNjOoKofbZ5I6cB6qoMkh+ebJvfPuEYBwhHmDDhpdjdk5v3LkeD5kt
|
|
||||||
0GtOaF5A3LbdZhgsC+1v1dHrL6Vndrb9KhO8ATHvlzJOonV73AoJFygp6upCvIt+
|
|
||||||
tPUuy3VE0kjc2mJDDJr5V28pSBJ5r9uz1rXZWP+9aduR3M+RUGzHS7cUdsl+lHyQ
|
|
||||||
TFQAQIDhWXyokMGqVZBm9xJ2KcDiQAEr5+kP0BrhPmBtfHSnLA1tIXlFcOqakvyQ
|
|
||||||
q1cACMvwbkZpupTqMhCr2S4V9dKxnlO5EIWYJmme9moU/zu1KA0mcwqfnNeDOR2J
|
|
||||||
6c3/x3E+AqBoFzDQb6LQ2Iw+9bkKWKgDml4paLPu/ot8vA2ZB9/mujFUvp/1MLuD
|
|
||||||
5I1jQDXFbjAgAnaSyqyW368CAwEAAQ==
|
|
||||||
-----END PUBLIC KEY-----
|
|
198
release/rtool.py
198
release/rtool.py
@ -8,14 +8,12 @@ import platform
|
|||||||
import re
|
import re
|
||||||
import runpy
|
import runpy
|
||||||
import shlex
|
import shlex
|
||||||
import shutil
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import tarfile
|
import tarfile
|
||||||
import zipfile
|
import zipfile
|
||||||
from os.path import join, abspath, dirname, exists, basename
|
from os.path import join, abspath, dirname
|
||||||
|
|
||||||
import click
|
import click
|
||||||
import cryptography.fernet
|
|
||||||
import pysftp
|
import pysftp
|
||||||
|
|
||||||
# https://virtualenv.pypa.io/en/latest/userguide.html#windows-notes
|
# https://virtualenv.pypa.io/en/latest/userguide.html#windows-notes
|
||||||
@ -86,18 +84,6 @@ def get_version(dev: bool = False, build: bool = False) -> str:
|
|||||||
return x["get_version"](dev, build, True)
|
return x["get_version"](dev, build, True)
|
||||||
|
|
||||||
|
|
||||||
def set_version(dev: bool) -> None:
|
|
||||||
"""
|
|
||||||
Update version information in mitmproxy's version.py to either include hardcoded information or not.
|
|
||||||
"""
|
|
||||||
version = get_version(dev, dev)
|
|
||||||
with open(VERSION_FILE, "r") as f:
|
|
||||||
content = f.read()
|
|
||||||
content = re.sub(r'^VERSION = ".+?"', 'VERSION = "{}"'.format(version), content, flags=re.M)
|
|
||||||
with open(VERSION_FILE, "w") as f:
|
|
||||||
f.write(content)
|
|
||||||
|
|
||||||
|
|
||||||
def archive_name(bdist: str) -> str:
|
def archive_name(bdist: str) -> str:
|
||||||
if platform.system() == "Windows":
|
if platform.system() == "Windows":
|
||||||
ext = "zip"
|
ext = "zip"
|
||||||
@ -146,24 +132,6 @@ def cli():
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@cli.command("encrypt")
|
|
||||||
@click.argument('infile', type=click.File('rb'))
|
|
||||||
@click.argument('outfile', type=click.File('wb'))
|
|
||||||
@click.argument('key', envvar='RTOOL_KEY')
|
|
||||||
def encrypt(infile, outfile, key):
|
|
||||||
f = cryptography.fernet.Fernet(key.encode())
|
|
||||||
outfile.write(f.encrypt(infile.read()))
|
|
||||||
|
|
||||||
|
|
||||||
@cli.command("decrypt")
|
|
||||||
@click.argument('infile', type=click.File('rb'))
|
|
||||||
@click.argument('outfile', type=click.File('wb'))
|
|
||||||
@click.argument('key', envvar='RTOOL_KEY')
|
|
||||||
def decrypt(infile, outfile, key):
|
|
||||||
f = cryptography.fernet.Fernet(key.encode())
|
|
||||||
outfile.write(f.decrypt(infile.read()))
|
|
||||||
|
|
||||||
|
|
||||||
@cli.command("contributors")
|
@cli.command("contributors")
|
||||||
def contributors():
|
def contributors():
|
||||||
"""
|
"""
|
||||||
@ -176,97 +144,6 @@ def contributors():
|
|||||||
f.write(contributors_data.encode())
|
f.write(contributors_data.encode())
|
||||||
|
|
||||||
|
|
||||||
@cli.command("wheel")
|
|
||||||
def make_wheel():
|
|
||||||
"""
|
|
||||||
Build a Python wheel
|
|
||||||
"""
|
|
||||||
set_version(True)
|
|
||||||
try:
|
|
||||||
subprocess.check_call([
|
|
||||||
"tox", "-e", "wheel",
|
|
||||||
], env={
|
|
||||||
**os.environ,
|
|
||||||
"VERSION": get_version(True),
|
|
||||||
})
|
|
||||||
finally:
|
|
||||||
set_version(False)
|
|
||||||
|
|
||||||
|
|
||||||
@cli.command("bdist")
|
|
||||||
def make_bdist():
|
|
||||||
"""
|
|
||||||
Build a binary distribution
|
|
||||||
"""
|
|
||||||
if exists(PYINSTALLER_TEMP):
|
|
||||||
shutil.rmtree(PYINSTALLER_TEMP)
|
|
||||||
if exists(PYINSTALLER_DIST):
|
|
||||||
shutil.rmtree(PYINSTALLER_DIST)
|
|
||||||
|
|
||||||
os.makedirs(DIST_DIR, exist_ok=True)
|
|
||||||
|
|
||||||
for bdist, tools in sorted(BDISTS.items()):
|
|
||||||
with Archive(join(DIST_DIR, archive_name(bdist))) as archive:
|
|
||||||
for tool in tools:
|
|
||||||
# We can't have a folder and a file with the same name.
|
|
||||||
if tool == "mitmproxy":
|
|
||||||
tool = "mitmproxy_main"
|
|
||||||
# This is PyInstaller, so it messes up paths.
|
|
||||||
# We need to make sure that we are in the spec folder.
|
|
||||||
with chdir(PYINSTALLER_SPEC):
|
|
||||||
print("Building %s binary..." % tool)
|
|
||||||
excludes = []
|
|
||||||
if tool != "mitmweb":
|
|
||||||
excludes.append("mitmproxy.tools.web")
|
|
||||||
if tool != "mitmproxy_main":
|
|
||||||
excludes.append("mitmproxy.tools.console")
|
|
||||||
|
|
||||||
# Overwrite mitmproxy/version.py to include commit info
|
|
||||||
set_version(True)
|
|
||||||
try:
|
|
||||||
subprocess.check_call(
|
|
||||||
[
|
|
||||||
"pyinstaller",
|
|
||||||
"--clean",
|
|
||||||
"--workpath", PYINSTALLER_TEMP,
|
|
||||||
"--distpath", PYINSTALLER_DIST,
|
|
||||||
"--additional-hooks-dir", PYINSTALLER_HOOKS,
|
|
||||||
"--onefile",
|
|
||||||
"--console",
|
|
||||||
"--icon", "icon.ico",
|
|
||||||
# This is PyInstaller, so setting a
|
|
||||||
# different log level obviously breaks it :-)
|
|
||||||
# "--log-level", "WARN",
|
|
||||||
]
|
|
||||||
+ [x for e in excludes for x in ["--exclude-module", e]]
|
|
||||||
+ PYINSTALLER_ARGS
|
|
||||||
+ [tool]
|
|
||||||
)
|
|
||||||
finally:
|
|
||||||
set_version(False)
|
|
||||||
# Delete the spec file - we're good without.
|
|
||||||
os.remove("{}.spec".format(tool))
|
|
||||||
|
|
||||||
# Test if it works at all O:-)
|
|
||||||
executable = join(PYINSTALLER_DIST, tool)
|
|
||||||
if platform.system() == "Windows":
|
|
||||||
executable += ".exe"
|
|
||||||
|
|
||||||
# Remove _main suffix from mitmproxy executable
|
|
||||||
if "_main" in executable:
|
|
||||||
shutil.move(
|
|
||||||
executable,
|
|
||||||
executable.replace("_main", "")
|
|
||||||
)
|
|
||||||
executable = executable.replace("_main", "")
|
|
||||||
|
|
||||||
print("> %s --version" % executable)
|
|
||||||
print(subprocess.check_output([executable, "--version"]).decode())
|
|
||||||
|
|
||||||
archive.add(executable, basename(executable))
|
|
||||||
print("Packed {}.".format(archive_name(bdist)))
|
|
||||||
|
|
||||||
|
|
||||||
@cli.command("upload-release")
|
@cli.command("upload-release")
|
||||||
@click.option('--username', prompt=True)
|
@click.option('--username', prompt=True)
|
||||||
@click.password_option(confirmation_prompt=False)
|
@click.password_option(confirmation_prompt=False)
|
||||||
@ -305,78 +182,5 @@ def homebrew_pr():
|
|||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
@cli.command("upload-snapshot")
|
|
||||||
@click.option("--host", envvar="SNAPSHOT_HOST", prompt=True)
|
|
||||||
@click.option("--port", envvar="SNAPSHOT_PORT", type=int, default=22)
|
|
||||||
@click.option("--user", envvar="SNAPSHOT_USER", prompt=True)
|
|
||||||
@click.option("--private-key", default=join(RELEASE_DIR, "rtool.pem"))
|
|
||||||
@click.option("--private-key-password", envvar="SNAPSHOT_PASS", prompt=True, hide_input=True)
|
|
||||||
@click.option("--wheel/--no-wheel", default=False)
|
|
||||||
@click.option("--bdist/--no-bdist", default=False)
|
|
||||||
@click.option("--installer/--no-installer", default=False)
|
|
||||||
def upload_snapshot(host, port, user, private_key, private_key_password, wheel, bdist, installer):
|
|
||||||
"""
|
|
||||||
Upload snapshot to snapshot server
|
|
||||||
"""
|
|
||||||
cnopts = pysftp.CnOpts(
|
|
||||||
knownhosts=join(RELEASE_DIR, 'known_hosts')
|
|
||||||
)
|
|
||||||
with pysftp.Connection(host=host,
|
|
||||||
port=port,
|
|
||||||
username=user,
|
|
||||||
private_key=private_key,
|
|
||||||
private_key_pass=private_key_password,
|
|
||||||
cnopts=cnopts) as sftp:
|
|
||||||
dir_name = "snapshots/v{}".format(get_version())
|
|
||||||
sftp.makedirs(dir_name)
|
|
||||||
with sftp.cd(dir_name):
|
|
||||||
files = []
|
|
||||||
if wheel:
|
|
||||||
files.append(wheel_name())
|
|
||||||
if bdist:
|
|
||||||
for bdist in sorted(BDISTS.keys()):
|
|
||||||
files.append(archive_name(bdist))
|
|
||||||
if installer:
|
|
||||||
files.append(installer_name())
|
|
||||||
|
|
||||||
for f in files:
|
|
||||||
local_path = join(DIST_DIR, f)
|
|
||||||
remote_filename = re.sub(
|
|
||||||
r"{version}(\.dev\d+(-0x[0-9a-f]+)?)?".format(version=get_version()),
|
|
||||||
get_version(True, True),
|
|
||||||
f
|
|
||||||
)
|
|
||||||
symlink_path = "../{}".format(f.replace(get_version(), "latest"))
|
|
||||||
|
|
||||||
# Upload new version
|
|
||||||
print("Uploading {} as {}...".format(f, remote_filename))
|
|
||||||
with click.progressbar(length=os.stat(local_path).st_size) as bar:
|
|
||||||
# We hide the file during upload
|
|
||||||
sftp.put(
|
|
||||||
local_path,
|
|
||||||
"." + remote_filename,
|
|
||||||
callback=lambda done, total: bar.update(done - bar.pos)
|
|
||||||
)
|
|
||||||
|
|
||||||
# Delete old versions
|
|
||||||
old_version = f.replace(get_version(), "*")
|
|
||||||
for f_old in sftp.listdir():
|
|
||||||
if fnmatch.fnmatch(f_old, old_version):
|
|
||||||
print("Removing {}...".format(f_old))
|
|
||||||
sftp.remove(f_old)
|
|
||||||
|
|
||||||
# Show new version
|
|
||||||
sftp.rename("." + remote_filename, remote_filename)
|
|
||||||
|
|
||||||
# update symlink for the latest release
|
|
||||||
if sftp.lexists(symlink_path):
|
|
||||||
print("Removing {}...".format(symlink_path))
|
|
||||||
sftp.remove(symlink_path)
|
|
||||||
if f != wheel_name():
|
|
||||||
# "latest" isn't a proper wheel version, so this could not be installed.
|
|
||||||
# https://github.com/mitmproxy/mitmproxy/issues/1065
|
|
||||||
sftp.symlink("v{}/{}".format(get_version(), remote_filename), symlink_path)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
cli()
|
cli()
|
||||||
|
10
tox.ini
10
tox.ini
@ -45,14 +45,12 @@ commands =
|
|||||||
pathod --version
|
pathod --version
|
||||||
pathoc --version
|
pathoc --version
|
||||||
|
|
||||||
[testenv:rtool]
|
[testenv:cibuild]
|
||||||
passenv = SKIP_MITMPROXY SNAPSHOT_HOST SNAPSHOT_PORT SNAPSHOT_USER SNAPSHOT_PASS RTOOL_KEY
|
passenv = TRAVIS_TAG TRAVIS_BRANCH AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY
|
||||||
deps =
|
deps =
|
||||||
-rrequirements.txt
|
-rrequirements.txt
|
||||||
pyinstaller==3.3.1
|
pyinstaller==3.3.1
|
||||||
twine==1.9.1
|
awscli
|
||||||
pysftp==0.2.9
|
|
||||||
|
|
||||||
commands =
|
commands =
|
||||||
mitmdump --version
|
mitmdump --version
|
||||||
python ./release/rtool.py {posargs}
|
python ./release/ci.py {posargs}
|
||||||
|
Loading…
Reference in New Issue
Block a user