diff options
-rw-r--r-- | release/README.md | 2 | ||||
-rwxr-xr-x | release/cibuild.py | 16 | ||||
-rw-r--r-- | test/release/test_cibuild.py | 32 |
3 files changed, 45 insertions, 5 deletions
diff --git a/release/README.md b/release/README.md index a34f1793..6f4e8f1a 100644 --- a/release/README.md +++ b/release/README.md @@ -36,7 +36,7 @@ release for! The command examples assume that you have a git remote called ## Docker - The docker image is built on Travis and pushed to Docker Hub automatically. - Please check https://hub.docker.com/r/mitmproxy/mitmproxy/tags/ about the latest version -- Update `latest` tag: `docker tag mitmproxy/mitmproxy:<version number here> mitmproxy/mitmproxy:latest && docker push mitmproxy/mitmproxy:latest` +- Update `latest` tag: `export VERSION=4.0.3 && docker pull mitmproxy/mitmproxy:$VERSION && docker tag mitmproxy/mitmproxy:$VERSION mitmproxy/mitmproxy:latest && docker push mitmproxy/mitmproxy:latest` ## Website - Update version here: diff --git a/release/cibuild.py b/release/cibuild.py index 76eb377e..37511086 100755 --- a/release/cibuild.py +++ b/release/cibuild.py @@ -196,13 +196,25 @@ class BuildEnviron: # 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}.") - 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(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: return bool(self.docker_username and self.docker_password) diff --git a/test/release/test_cibuild.py b/test/release/test_cibuild.py index 96280e35..cfa24e63 100644 --- a/test/release/test_cibuild.py +++ b/test/release/test_cibuild.py @@ -64,6 +64,7 @@ def test_buildenviron_pr(): ) assert be.is_pull_request assert not be.is_prod_release + assert not be.is_maintenance_branch def test_buildenviron_commit(): @@ -83,6 +84,7 @@ def test_buildenviron_commit(): assert not be.should_upload_pypi assert be.should_upload_docker assert not be.is_prod_release + assert not be.is_maintenance_branch def test_buildenviron_releasetag(): @@ -107,6 +109,7 @@ def test_buildenviron_releasetag(): assert be.should_upload_pypi assert be.should_upload_docker assert be.is_prod_release + assert not be.is_maintenance_branch def test_buildenviron_namedtag(): @@ -131,9 +134,10 @@ def test_buildenviron_namedtag(): assert not be.should_upload_pypi assert not be.should_upload_docker assert not be.is_prod_release + assert not be.is_maintenance_branch -def test_buildenviron_branch(): +def test_buildenviron_dev_branch(): # Simulates a commit on a development branch on the main repo be = cibuild.BuildEnviron( system="Linux", @@ -153,6 +157,30 @@ def test_buildenviron_branch(): assert be.upload_dir == "branches/mybranch" assert not be.should_upload_pypi assert not be.should_upload_docker + assert not be.is_maintenance_branch + + +def test_buildenviron_maintenance_branch(): + # Simulates a commit on a release maintenance branch on the main repo + be = cibuild.BuildEnviron( + system="Linux", + root_dir="/foo", + travis_tag="", + travis_branch="v0.x", + should_build_wheel=True, + should_build_docker=True, + should_build_pyinstaller=True, + has_twine_creds=True, + docker_username="foo", + docker_password="bar", + ) + assert be.tag == "" + assert be.branch == "v0.x" + assert be.version == "v0.x" + assert be.upload_dir == "branches/v0.x" + assert not be.should_upload_pypi + assert not be.should_upload_docker + assert be.is_maintenance_branch def test_buildenviron_osx(tmpdir): @@ -209,7 +237,7 @@ def test_buildenviron_check_version(version, tag, ok, tmpdir): be = cibuild.BuildEnviron( root_dir=tmpdir, travis_tag=tag, - travis_branch=tag + travis_branch=tag or "branch", ) if ok: be.check_version() |