From b6e1c4bb9d61a33e272ad9a755337c30ca7548df Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Fri, 25 May 2018 12:42:59 +1200 Subject: [PATCH] cibuild: tweak docker tag, only upload prod builds to pypi --- release/cibuild.py | 23 ++++++++++++----------- test/release/test_cibuild.py | 5 +++-- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/release/cibuild.py b/release/cibuild.py index 2e543f1d2..04ca9474c 100755 --- a/release/cibuild.py +++ b/release/cibuild.py @@ -153,8 +153,10 @@ class BuildEnviron: @property def docker_tag(self): if self.branch == "master": - return "dev" - return self.version + t = "dev" + else: + t = self.version + return "mitmproxy/mitmproxy:{}".format(t) def dump_info(self, fp=sys.stdout): lst = [ @@ -217,9 +219,12 @@ class BuildEnviron: @property def should_upload_pypi(self) -> bool: - if self.tag and self.should_build_wheel and self.has_twine_creds: - return True - return False + return all([ + self.tag, + self.is_prod_release, + self.should_build_wheel, + self.has_twine_creds, + ]) @property def tag(self): @@ -260,7 +265,7 @@ def build_docker_image(be: BuildEnviron, whl: str): # pragma: no cover subprocess.check_call([ "docker", "build", - "--tag", "mitmproxy/mitmproxy/{}".format(be.docker_tag), + "--tag", be.docker_tag, "--build-arg", "WHEEL_MITMPROXY={}".format(whl), "--build-arg", "WHEEL_BASENAME_MITMPROXY={}".format(os.path.basename(whl)), "--file", "docker/Dockerfile", @@ -413,11 +418,7 @@ def upload(): # pragma: no cover "-u", be.docker_username, "-p", be.docker_password, ]) - subprocess.check_call([ - "docker", - "push", - "mitmproxy/mitmproxy:{}".format(be.docker_tag), - ]) + subprocess.check_call(["docker", "push", be.docker_tag]) @cli.command("decrypt") diff --git a/test/release/test_cibuild.py b/test/release/test_cibuild.py index 596300aa4..78ddf9987 100644 --- a/test/release/test_cibuild.py +++ b/test/release/test_cibuild.py @@ -74,7 +74,7 @@ def test_buildenviron_commit(): docker_username = "foo", docker_password = "bar", ) - assert be.docker_tag == "dev" + assert be.docker_tag == "mitmproxy/mitmproxy:dev" assert be.should_upload_docker assert not be.should_upload_pypi assert be.should_upload_docker @@ -101,11 +101,12 @@ def test_buildenviron_rleasetag(): assert be.branch == "v0.x" assert be.version == "0.0.1" assert be.upload_dir == "0.0.1" - assert be.docker_tag == "0.0.1" + assert be.docker_tag == "mitmproxy/mitmproxy:0.0.1" assert be.should_upload_pypi assert be.should_upload_docker assert be.is_prod_release + def test_buildenviron_branch(): # Simulates a development branch on the main repo be = cibuild.BuildEnviron(