diff options
Diffstat (limited to 'release/cibuild.py')
-rwxr-xr-x | release/cibuild.py | 66 |
1 files changed, 47 insertions, 19 deletions
diff --git a/release/cibuild.py b/release/cibuild.py index 17fb8554..37511086 100755 --- a/release/cibuild.py +++ b/release/cibuild.py @@ -63,6 +63,12 @@ class BuildEnviron: self.travis_tag = travis_tag self.travis_branch = travis_branch + + if travis_tag and travis_tag != travis_branch: + raise ValueError( + f"Something is wrong - TRAVIS_TAG={travis_tag}, but TRAVIS_BRANCH={travis_branch}" + ) + self.travis_pull_request = travis_pull_request self.should_build_wheel = should_build_wheel @@ -184,25 +190,29 @@ class BuildEnviron: """ with open(pathlib.Path(self.root_dir) / "mitmproxy" / "version.py") as f: contents = f.read() - version = re.search(r'^VERSION = "(.+?)"', contents, re.M).group(1) - if self.tag: - # For (tagged) releases, we are strict: - # 1. The tagname must match the version in mitmproxy/version.py - # 2. The version info must be in canonical form (as recommended in PEP 440). - - if version != self.tag: + if self.is_prod_release: + # For production releases, we require strict version equality + if self.version != version: raise ValueError(f"Tag is {self.tag}, but mitmproxy/version.py is {version}.") - try: - parver.Version.parse(version, strict=True) - except parver.ParseError as e: - raise ValueError(str(e)) from e - else: - # For snapshots, we only ensure that mitmproxy/version.py contains a dev release. + elif not self.is_maintenance_branch: + # Commits on maintenance branches don't need the dev suffix. This + # allows us to incorporate and test commits between tagged releases. + # For snapshots, we only ensure that mitmproxy/version.py contains a + # dev release. version_info = parver.Version.parse(version) if not version_info.is_devrelease: - raise ValueError("Releases must be tagged.") + raise ValueError(f"Non-production releases must have dev suffix: {version}") + + @property + def is_maintenance_branch(self) -> bool: + """ + Is this an untagged commit on a maintenance branch? + """ + if not self.tag and self.branch and re.match(r"v\d+\.x", self.branch): + return True + return False @property def has_docker_creds(self) -> bool: @@ -210,7 +220,7 @@ class BuildEnviron: @property def is_prod_release(self) -> bool: - if not self.tag: + if not (self.tag and self.tag.startswith("v")): return False try: v = parver.Version.parse(self.version, strict=True) @@ -265,10 +275,18 @@ class BuildEnviron: @property def version(self): - name = self.tag or self.branch - if not name: + if self.tag: + if self.tag.startswith("v"): + try: + parver.Version.parse(self.tag[1:], strict=True) + except parver.ParseError as e: + return self.tag + return self.tag[1:] + return self.tag + elif self.branch: + return self.branch + else: raise BuildError("We're on neither a tag nor a branch - could not establish version") - return name def build_wheel(be: BuildEnviron): # pragma: no cover @@ -287,7 +305,7 @@ def build_wheel(be: BuildEnviron): # pragma: no cover def build_docker_image(be: BuildEnviron, whl: str): # pragma: no cover - click.echo("Building Docker image...") + click.echo("Building Docker images...") subprocess.check_call([ "docker", "build", @@ -297,6 +315,15 @@ def build_docker_image(be: BuildEnviron, whl: str): # pragma: no cover "--file", "docker/Dockerfile", "." ]) + subprocess.check_call([ + "docker", + "build", + "--tag", be.docker_tag + "-ARMv7", + "--build-arg", "WHEEL_MITMPROXY={}".format(whl), + "--build-arg", "WHEEL_BASENAME_MITMPROXY={}".format(os.path.basename(whl)), + "--file", "docker/DockerfileARMv7", + "." + ]) def build_pyinstaller(be: BuildEnviron): # pragma: no cover @@ -498,6 +525,7 @@ def upload(): # pragma: no cover "-p", be.docker_password, ]) subprocess.check_call(["docker", "push", be.docker_tag]) + subprocess.check_call(["docker", "push", be.docker_tag + "-ARMv7"]) if __name__ == "__main__": # pragma: no cover |