Skip to content

Commit

Permalink
prefix version tags with 'v'
Browse files Browse the repository at this point in the history
this got lost with mitmproxy 9 somehow. the plan is to recreate those tags with 'v', and then keep using 'v' going forward.
  • Loading branch information
mhils committed Apr 19, 2024
1 parent 4d00ec0 commit 665ed0d
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

## Unreleased: mitmproxy next

* Release tags are now prefixed with `v` again to follow SemVer convention.


## 17 April 2024: mitmproxy 10.3.0
Expand Down
4 changes: 3 additions & 1 deletion release/build-and-deploy-docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
if ref.startswith("refs/heads/"):
branch = ref.replace("refs/heads/", "")
elif ref.startswith("refs/tags/"):
tag = ref.replace("refs/tags/", "")
if not ref.startswith("refs/tags/v"):
raise AssertionError(f"Unexpected tag: {ref}")
tag = ref.replace("refs/tags/v", "")
else:
raise AssertionError("Failed to parse $GITHUB_REF")

Expand Down
15 changes: 12 additions & 3 deletions release/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,18 @@ def archive(path: Path) -> tarfile.TarFile | ZipFile2:


def version() -> str:
return os.environ.get("GITHUB_REF_NAME", "").replace("/", "-") or os.environ.get(
"BUILD_VERSION", "dev"
)
if ref := os.environ.get("GITHUB_REF", ""):
if ref.startswith("refs/tags/") and not ref.startswith("refs/tags/v"):
raise AssertionError(f"Unexpected tag: {ref}")
return (
ref
.removeprefix("refs/heads/")
.removeprefix("refs/pull/")
.removeprefix("refs/tags/v")
.replace("/", "-")
)
else:
return os.environ.get("BUILD_VERSION", "dev")


def operating_system() -> str:
Expand Down
4 changes: 3 additions & 1 deletion release/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
if ref.startswith("refs/heads/"):
branch = ref.replace("refs/heads/", "")
elif ref.startswith("refs/tags/"):
tag = ref.replace("refs/tags/", "")
if not ref.startswith("refs/tags/v"):
raise AssertionError(f"Unexpected tag: {ref}")
tag = ref.replace("refs/tags/v", "")
else:
raise AssertionError

Expand Down
9 changes: 5 additions & 4 deletions release/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ def get_json(url: str) -> dict:
subprocess.run(
["git", "commit", "-a", "-m", f"mitmproxy {version}"], cwd=root, check=True
)
subprocess.run(["git", "tag", version], cwd=root, check=True)
tag_name = f"v{version}"
subprocess.run(["git", "tag", tag_name], cwd=root, check=True)
release_sha = subprocess.run(
["git", "rev-parse", "HEAD"],
cwd=root,
Expand All @@ -124,7 +125,7 @@ def get_json(url: str) -> dict:

print("➡️ Pushing...")
subprocess.run(
["git", "push", "--atomic", "origin", branch, version], cwd=root, check=True
["git", "push", "--atomic", "origin", branch, tag_name], cwd=root, check=True
)

print("➡️ Creating release on GitHub...")
Expand All @@ -133,7 +134,7 @@ def get_json(url: str) -> dict:
"gh",
"release",
"create",
version,
tag_name,
"--title",
f"mitmproxy {version}",
"--notes-file",
Expand All @@ -145,7 +146,7 @@ def get_json(url: str) -> dict:

print("➡️ Dispatching release workflow...")
subprocess.run(
["gh", "workflow", "run", "main.yml", "--ref", version], cwd=root, check=True
["gh", "workflow", "run", "main.yml", "--ref", tag_name], cwd=root, check=True
)

print("")
Expand Down

0 comments on commit 665ed0d

Please sign in to comment.