-
Notifications
You must be signed in to change notification settings - Fork 0
Fix versioning scheme for updates and SDK re-generation. #2
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 all commits
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 |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| usage() { | ||
| cat <<'USAGE' | ||
| Usage: scripts/regenerate-sdk.sh VERSION | ||
|
|
||
| Regenerates the AuditHub Python SDK from the live OpenAPI document using | ||
| VERSION as the packageVersion, then syncs repository-maintained version | ||
| references. | ||
| USAGE | ||
| } | ||
|
|
||
| if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then | ||
| usage | ||
| exit 0 | ||
| fi | ||
|
|
||
| if [[ $# -ne 1 ]]; then | ||
| usage >&2 | ||
| exit 2 | ||
| fi | ||
|
|
||
| VERSION="$1" | ||
|
|
||
| if [[ -z "$VERSION" || "$VERSION" == *","* || "$VERSION" =~ [[:space:]] ]]; then | ||
| echo "Version must be non-empty and must not contain commas or whitespace." >&2 | ||
| exit 2 | ||
| fi | ||
|
|
||
| if ! command -v openapi-generator >/dev/null 2>&1; then | ||
| echo "openapi-generator is required. Install OpenAPI Generator 7.20.0 before regenerating." >&2 | ||
| exit 127 | ||
| fi | ||
|
|
||
| PYTHON="${PYTHON:-python3}" | ||
| if ! command -v "$PYTHON" >/dev/null 2>&1; then | ||
| echo "$PYTHON is required to sync repository metadata." >&2 | ||
| exit 127 | ||
| fi | ||
|
|
||
| openapi-generator generate \ | ||
| -i https://audithub.dev.veridise.tools/api/v1/openapi.json \ | ||
| -g python \ | ||
| -o . \ | ||
| --additional-properties="packageName=audithub_sdk,projectName=audithub-sdk,packageVersion=${VERSION},hideGenerationTimestamp=true,library=httpx" | ||
|
|
||
| "$PYTHON" - "$VERSION" <<'PY' | ||
| from __future__ import annotations | ||
|
|
||
| from pathlib import Path | ||
| import re | ||
| import sys | ||
|
|
||
|
|
||
| version = sys.argv[1] | ||
|
|
||
|
|
||
| def replace_exact(path: str, pattern: str, replacement, expected: int) -> None: | ||
| file_path = Path(path) | ||
| text = file_path.read_text(encoding="utf-8") | ||
| updated, count = re.subn(pattern, replacement, text, flags=re.MULTILINE) | ||
| if count != expected: | ||
| raise SystemExit(f"{path}: expected {expected} replacement(s), made {count}") | ||
| file_path.write_text(updated, encoding="utf-8") | ||
|
|
||
|
|
||
| replace_exact( | ||
| "pyproject.toml", | ||
| r'^(version = ")[^"]+(")$', | ||
| lambda match: f"{match.group(1)}{version}{match.group(2)}", | ||
| 1, | ||
| ) | ||
| replace_exact( | ||
| "setup.py", | ||
| r'^(VERSION = ")[^"]+(")$', | ||
| lambda match: f"{match.group(1)}{version}{match.group(2)}", | ||
| 1, | ||
| ) | ||
| replace_exact( | ||
| "README.md", | ||
| r"packageVersion=[^,]+", | ||
| f"packageVersion={version}", | ||
| 1, | ||
| ) | ||
| replace_exact( | ||
| "AGENTS.md", | ||
| r"(Package version currently used during generation: `)[^`]+(`)", | ||
| lambda match: f"{match.group(1)}{version}{match.group(2)}", | ||
| 1, | ||
|
Comment on lines
+87
to
+90
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The AGENTS sync only rewrites the package-version bullet and the Useful? React with 👍 / 👎. |
||
| ) | ||
| replace_exact( | ||
| "AGENTS.md", | ||
| r"packageVersion=[^,]+", | ||
| f"packageVersion={version}", | ||
| 1, | ||
| ) | ||
| PY | ||
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 regeneration script says it syncs
README.md, but this replacement only updates thepackageVersion=...fragment in the generator command. It does not update the README sentence declaring the “current generated package version”, so after runningscripts/regenerate-sdk.sh VERSIONthe file can immediately contain contradictory versions and mislead future releases.Useful? React with 👍 / 👎.