diff --git a/release/cibuild.py b/release/cibuild.py index e2ac88d31..491617fa3 100755 --- a/release/cibuild.py +++ b/release/cibuild.py @@ -158,6 +158,12 @@ class BuildEnviron: def dist_dir(self): return os.path.join(self.release_dir, "dist") + @property + def docker_tag(self): + if self.branch == "master": + return "dev" + return self.version + def archive(self, path): # ZipFile and tarfile have slightly different APIs. Fix that. if self.system == "Windows": @@ -222,6 +228,7 @@ def build_docker_image(be: BuildEnviron, whl: str): # pragma: no cover subprocess.check_call([ "docker", "build", + "--tag", be.docker_tag, "--build-arg", "WHEEL_MITMPROXY={}".format(whl), "--build-arg", "WHEEL_BASENAME_MITMPROXY={}".format(os.path.basename(whl)), "--file", "docker/Dockerfile", @@ -373,9 +380,7 @@ def upload(): # pragma: no cover be.has_docker_creds, ) if upload_docker: - docker_tag = "dev" if be.branch == "master" else be.version - - click.echo("Uploading Docker image to tag={}...".format(docker_tag)) + click.echo("Uploading Docker image to tag={}...".format(be.docker_tag)) subprocess.check_call([ "docker", "login", @@ -385,7 +390,7 @@ def upload(): # pragma: no cover subprocess.check_call([ "docker", "push", - "mitmproxy/mitmproxy:{}".format(docker_tag), + "mitmproxy/mitmproxy:{}".format(be.docker_tag), ]) diff --git a/test/release/test_cibuild.py b/test/release/test_cibuild.py index 23b8e6cd3..a60f101ff 100644 --- a/test/release/test_cibuild.py +++ b/test/release/test_cibuild.py @@ -53,6 +53,14 @@ def test_buildenviron_pr(): assert be.is_pull_request +def test_buildenviron_commit(): + be = cibuild.BuildEnviron( + travis_branch = "master", + travis_pull_request = "false", + ) + assert be.docker_tag == "dev" + + def test_buildenviron_tag(): be = cibuild.BuildEnviron( system = "Linux", @@ -65,6 +73,7 @@ def test_buildenviron_tag(): 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" def test_buildenviron_branch():