prefix version tags with 'v' (#6810)

This commit is contained in:
Maximilian Hils 2024-04-19 21:28:05 +02:00 committed by GitHub
parent 4d00ec03b4
commit 2c96c96e75
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 30 additions and 17 deletions

View File

@ -72,11 +72,10 @@ jobs:
# run tests with loopback only. We need to sudo for unshare, which means we need an absolute path for tox.
sudo unshare --net -- sh -c "ip link set lo up; $(which tox) -e py"
if: matrix.os == 'ubuntu-latest'
- uses: mhils/better-codecov-action@main
- uses: codecov/codecov-action@v4
with:
arguments: '--file ./coverage.xml --name ${{ matrix.os }}'
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
build:
strategy:
@ -166,11 +165,10 @@ jobs:
run: npm ci
- working-directory: ./web
run: npm test
- uses: mhils/better-codecov-action@main
- uses: codecov/codecov-action@v4
with:
arguments: '--file ./web/coverage/coverage-final.json'
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
token: ${{ secrets.CODECOV_TOKEN }}
files: ./web/coverage/coverage-final.json
docs:
runs-on: ubuntu-latest

View File

@ -7,6 +7,8 @@
## Unreleased: mitmproxy next
* Release tags are now prefixed with `v` again to follow SemVer convention.
([#6810](https://github.com/mitmproxy/mitmproxy/pull/6810), @mhils)
## 17 April 2024: mitmproxy 10.3.0

View File

@ -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")

View File

@ -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:

View File

@ -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

View File

@ -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("")