-
Notifications
You must be signed in to change notification settings - Fork 1
chore: remove bump-version.py and bump-version.yml #125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,13 +2,11 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import sys | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sys.path.append("../../") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from clang_tools import release_tag # noqa E402 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from clang_tools import binary_repo, binary_tag # noqa E402 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def get_latest_tag() -> str: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| response = requests.get( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "https://api.github.com/repos/cpp-linter/clang-tools-static-binaries/releases/latest" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| response = requests.get(f"{binary_repo}/releases/latest") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return response.json()["tag_name"] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| response = requests.get(f"{binary_repo}/releases/latest") | |
| return response.json()["tag_name"] | |
| def get_latest_tag() -> str: | |
| # Normalize to GitHub API URL | |
| from urllib.parse import urlparse | |
| import os | |
| repo = binary_repo.rstrip("/") | |
| parsed = urlparse(repo) | |
| if "api.github.com" in parsed.netloc: | |
| api_url = f"{repo}/releases/latest" | |
| elif "github.com" in parsed.netloc: | |
| parts = [p for p in parsed.path.split("/") if p] | |
| if len(parts) < 2: | |
| raise ValueError(f"Invalid binary_repo: {binary_repo}") | |
| owner, name = parts[0], parts[1] | |
| api_url = f"https://api.github.com/repos/{owner}/{name}/releases/latest" | |
| else: | |
| raise ValueError(f"Unsupported host in binary_repo: {binary_repo}") | |
| headers = {"Accept": "application/vnd.github+json"} | |
| token = os.getenv("GITHUB_TOKEN") or os.getenv("GH_TOKEN") | |
| if token: | |
| headers["Authorization"] = f"Bearer {token}" | |
| resp = requests.get(api_url, headers=headers, timeout=15) | |
| resp.raise_for_status() | |
| data = resp.json() | |
| tag = data.get("tag_name") | |
| if not tag: | |
| raise RuntimeError(f"Missing tag_name in response: {data}") | |
| return tag |
🧰 Tools
🪛 Ruff (0.12.2)
9-9: Probable use of requests call without timeout
(S113)
🪛 GitHub Actions: Bump clang-tools binaries version
[error] 10-10: JSONDecodeError: Expecting value: line 8 column 1 (char 7) while parsing API response in get_latest_tag() (response.json() call).
🤖 Prompt for AI Agents
In .github/workflows/bump-version.py around lines 9-10, change the call that
GETs "{binary_repo}/releases/latest" (which returns HTML) to call the GitHub API
releases endpoint instead, add a timeout, include an Authorization header when
GITHUB_TOKEN is set, and robustly validate the response and JSON. Specifically,
normalize binary_repo into an API URL like
"https://api.github.com/repos/{owner}/{repo}/releases/latest", call requests.get
with headers {"Accept":"application/vnd.github.v3+json", "Authorization":
f"token {GITHUB_TOKEN}"} only if the token exists, and a reasonable timeout
(e.g., 10s); check response.status_code == 200, attempt response.json() inside
try/except to catch JSONDecodeError and requests.RequestException, verify the
JSON contains "tag_name" before returning it, and raise or log a clear error if
any step fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
requestsmodule is used but not imported. Addimport requestsat the top of the file.Copilot uses AI. Check for mistakes.