Viewing is open to everyone. Downloading and starring need a GitHub sign-in.
Sign in with GitHub
bump_version.py
v0.1.0-build.85
Latest
Commit ede38f5
Sign in with GitHub to download. Each download is recorded with your GitHub username.
| 1 | #!/usr/bin/env python3 |
| 2 | """Bump the build number in every versioned file (CONTRIBUTING_VERSIONING.md). |
| 3 | |
| 4 | tools/bump_version.py # 0.1.0-build.N -> 0.1.0-build.N+1 |
| 5 | tools/bump_version.py --check # list the files that carry the version |
| 6 | |
| 7 | The changelog entry is still written by hand; tools/check_version.py fails |
| 8 | until its top heading matches. |
| 9 | """ |
| 10 | import re |
| 11 | import sys |
| 12 | from pathlib import Path |
| 13 | |
| 14 | root = Path(__file__).resolve().parents[1] |
| 15 | FILES = [ |
| 16 | "VERSION", "CONTEXT.md", "include/ckey/ckey.h", "tests/vectors/locator-v14.json", |
| 17 | "ios/README.md", "macos/README.md", "docs/support-matrix.json", |
| 18 | "sdk/web/package.json", "sdk/android/gradle.properties", "sdk/dotnet/README.md", |
| 19 | "sdk/android/README.md", "sdk/swift/README.md", "sdk/web/README.md", "README.md", |
| 20 | ] |
| 21 | old = (root / "VERSION").read_text().strip() |
| 22 | m = re.fullmatch(r"(\d+\.\d+\.\d+)-build\.(\d+)", old) |
| 23 | if not m: |
| 24 | sys.exit(f"VERSION {old!r} is not of the form X.Y.Z-build.N") |
| 25 | present = [f for f in FILES if (root / f).exists() and old in (root / f).read_text()] |
| 26 | if "--check" in sys.: |
| 27 | print("\n".join(present)); sys.exit(0) |
| 28 | new = f"{m.group(1)}-build.{int(m.group(2)) + 1}" |
| 29 | for f in present: |
| 30 | p = root / f |
| 31 | p.write_text(p.read_text().replace(old, new)) |
| 32 | print(f"{old} -> {new} in {len(present)} files:\n " + "\n ".join(present)) |