From ff92962c51c548519384ed80c5b7d60d5350f176 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Fri, 25 May 2018 10:50:48 +1200 Subject: [PATCH] cibuild: start building version awareness --- release/README.md | 1 - release/cibuild.py | 9 +++++++++ setup.py | 1 + test/release/test_cibuild.py | 4 +++- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/release/README.md b/release/README.md index f07357f97..d817ee18d 100644 --- a/release/README.md +++ b/release/README.md @@ -41,7 +41,6 @@ release for! The command examples assume that you have a git remote called - Please check https://hub.docker.com/r/mitmproxy/mitmproxy/tags/ about the latest version - Update `latest` tag: TODO write instructions - ## Website - Update version here: https://github.com/mitmproxy/www/blob/master/src/config.toml diff --git a/release/cibuild.py b/release/cibuild.py index 8ff6f9b65..2e543f1d2 100755 --- a/release/cibuild.py +++ b/release/cibuild.py @@ -13,6 +13,7 @@ import zipfile import click import cryptography.fernet +import parver @contextlib.contextmanager @@ -180,6 +181,14 @@ class BuildEnviron: def has_docker_creds(self) -> bool: return self.docker_username and self.docker_password + @property + def is_prod_release(self) -> bool: + try: + v = parver.Version.parse(self.version) + except (parver.ParseError, BuildError): + return False + return not v.is_prerelease + @property def is_pull_request(self) -> bool: if self.appveyor_pull_request_number: diff --git a/setup.py b/setup.py index 7300edd18..852de64c9 100644 --- a/setup.py +++ b/setup.py @@ -89,6 +89,7 @@ setup( "flake8>=3.5, <3.6", "Flask>=1.0,<1.1", "mypy>=0.590,<0.591", + "parver>=0.1<2.0", "pytest-asyncio>=0.8", "pytest-cov>=2.5.1,<3", "pytest-faulthandler>=1.3.1,<2", diff --git a/test/release/test_cibuild.py b/test/release/test_cibuild.py index 71395c6d9..596300aa4 100644 --- a/test/release/test_cibuild.py +++ b/test/release/test_cibuild.py @@ -58,6 +58,7 @@ def test_buildenviron_pr(): appveyor_pull_request_number = "xxxx", ) assert be.is_pull_request + assert not be.is_prod_release def test_buildenviron_commit(): @@ -77,6 +78,7 @@ def test_buildenviron_commit(): assert be.should_upload_docker assert not be.should_upload_pypi assert be.should_upload_docker + assert not be.is_prod_release def test_buildenviron_rleasetag(): @@ -102,7 +104,7 @@ def test_buildenviron_rleasetag(): assert be.docker_tag == "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