|
| 1 | +#!/usr/bin/env bash |
| 2 | +set -euo pipefail |
| 3 | + |
| 4 | +root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" |
| 5 | +cmake_file="$root/CMakeLists.txt" |
| 6 | + |
| 7 | +version="$( |
| 8 | +python3 - "$cmake_file" <<'PY' |
| 9 | +import re |
| 10 | +import sys |
| 11 | +
|
| 12 | +text = open(sys.argv[1], "r", encoding="utf-8").read() |
| 13 | +
|
| 14 | +def get(name: str) -> str: |
| 15 | + match = re.search(rf"set\s*\(\s*{name}\s+([0-9]+)\s*\)", text) |
| 16 | + if not match: |
| 17 | + raise SystemExit(f"Missing {name} in {sys.argv[1]}") |
| 18 | + return match.group(1) |
| 19 | +
|
| 20 | +major = get("TOPAS_VERSION_MAJOR") |
| 21 | +minor = get("TOPAS_VERSION_MINOR") |
| 22 | +patch = get("TOPAS_VERSION_PATCH") |
| 23 | +print(f"{major}.{minor}.{patch}") |
| 24 | +PY |
| 25 | +)" |
| 26 | + |
| 27 | +tag="v${version}" |
| 28 | + |
| 29 | +python3 - "$tag" \ |
| 30 | + "$root/OpenTOPAS_quickStart_Debian.md" \ |
| 31 | + "$root/OpenTOPAS_quickStart_MacOS.md" \ |
| 32 | + "$root/OpenTOPAS_quickStart_WSL.md" \ |
| 33 | + "$root/docker/README.Docker.md" \ |
| 34 | + "$root/.github/workflows/Dockerfile.topas.workflow" <<'PY' |
| 35 | +import re |
| 36 | +import sys |
| 37 | +from pathlib import Path |
| 38 | +
|
| 39 | +tag = sys.argv[1] |
| 40 | +paths = [Path(p) for p in sys.argv[2:]] |
| 41 | +errors = [] |
| 42 | +
|
| 43 | +def expect_all_equal(values, label, path): |
| 44 | + if not values: |
| 45 | + errors.append(f"{path}: missing {label}") |
| 46 | + return |
| 47 | + unique = sorted(set(values)) |
| 48 | + if unique != [tag]: |
| 49 | + errors.append(f"{path}: {label} {unique} != {tag}") |
| 50 | +
|
| 51 | +for path in paths: |
| 52 | + text = path.read_text(encoding="utf-8") |
| 53 | + if path.name.startswith("OpenTOPAS_quickStart_"): |
| 54 | + version_line = re.findall( |
| 55 | + r"(?:TOPAS version|target) \*\*(v\d+\.\d+\.\d+)\*\*", |
| 56 | + text, |
| 57 | + ) |
| 58 | + checkout_tags = re.findall(r"\bgit checkout (v\d+\.\d+\.\d+)\b", text) |
| 59 | + app_tags = re.findall(r"\bapps/topas-(v\d+\.\d+\.\d+)\.json\b", text) |
| 60 | + expect_all_equal(version_line, "TOPAS version", path) |
| 61 | + expect_all_equal(checkout_tags, "git checkout tag", path) |
| 62 | + expect_all_equal(app_tags, "apps/topas tag", path) |
| 63 | + elif path.name == "Dockerfile.topas.workflow": |
| 64 | + desc_tags = re.findall(r"TOPAS (v\d+\.\d+\.\d+)", text) |
| 65 | + arg_tags = re.findall(r"ARG TOPAS_VERSION=(v\d+\.\d+\.\d+)", text) |
| 66 | + expect_all_equal(desc_tags, "description tag", path) |
| 67 | + expect_all_equal(arg_tags, "ARG TOPAS_VERSION", path) |
| 68 | + elif path.name == "README.Docker.md": |
| 69 | + docker_tags = re.findall(r"OpenTOPAS (v\d+\.\d+\.\d+)", text) |
| 70 | + expect_all_equal(docker_tags, "OpenTOPAS tag", path) |
| 71 | +
|
| 72 | +if errors: |
| 73 | + print("TOPAS version mismatch detected:") |
| 74 | + for err in errors: |
| 75 | + print(f"- {err}") |
| 76 | + raise SystemExit(1) |
| 77 | +
|
| 78 | +print(f"TOPAS version references are consistent: {tag}") |
| 79 | +PY |
0 commit comments