mirror of
https://github.com/vee1e/mitmproxy.git
synced 2026-09-01 18:27:18 +00:00
prefix version tags with 'v' (#6810)
This commit is contained in:
parent
4d00ec03b4
commit
2c96c96e75
6 changed files with 30 additions and 17 deletions
|
|
@ -19,7 +19,9 @@ tag: str | None = None
|
|||
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")
|
||||
|
||||
|
|
|
|||
|
|
@ -83,9 +83,17 @@ 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:
|
||||
|
|
|
|||
|
|
@ -14,7 +14,9 @@ if __name__ == "__main__":
|
|||
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
|
||||
|
||||
|
|
|
|||
|
|
@ -99,7 +99,8 @@ if __name__ == "__main__":
|
|||
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,
|
||||
|
|
@ -124,7 +125,7 @@ if __name__ == "__main__":
|
|||
|
||||
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...")
|
||||
|
|
@ -133,7 +134,7 @@ if __name__ == "__main__":
|
|||
"gh",
|
||||
"release",
|
||||
"create",
|
||||
version,
|
||||
tag_name,
|
||||
"--title",
|
||||
f"mitmproxy {version}",
|
||||
"--notes-file",
|
||||
|
|
@ -145,7 +146,7 @@ if __name__ == "__main__":
|
|||
|
||||
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("")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue