| 1 |
"""Set the plugin manifest's version, the way a release does. |
| 2 |
|
| 3 |
The plugin is the skill for one release of hsql, so `plugin.json` carries that |
| 4 |
release's number -- and it is the only version `uv version` cannot reach. So |
| 5 |
`release.yml` runs this beside the two it does. |
| 6 |
|
| 7 |
Usage: |
| 8 |
python scripts/bump_plugin_version.py 2.12.0 |
| 9 |
|
| 10 |
`tests/unit_tests/test_plugin.py` is what fails when the committed manifest and |
| 11 |
this disagree, whether that is a version a release left behind or a hand edit |
| 12 |
this would reformat. |
| 13 |
""" |
| 14 |
|
| 15 |
from __future__ import annotations |
| 16 |
|
| 17 |
import json |
| 18 |
import sys |
| 19 |
from pathlib import Path |
| 20 |
|
| 21 |
PLUGIN_PATH = ( |
| 22 |
Path(__file__).resolve().parents[1] |
| 23 |
/ "src" |
| 24 |
/ "harlequin" |
| 25 |
/ "hsql" |
| 26 |
/ "skill" |
| 27 |
/ ".claude-plugin" |
| 28 |
/ "plugin.json" |
| 29 |
) |
| 30 |
|
| 31 |
|
| 32 |
def write_version(version: str, path: Path = PLUGIN_PATH) -> None: |
| 33 |
"""Rewrite the manifest with `version`, and nothing else changed. |
| 34 |
|
| 35 |
Key order survives the round trip, so a release's diff is the one line. |
| 36 |
""" |
| 37 |
manifest = json.loads(path.read_text(encoding="utf-8")) |
| 38 |
manifest["version"] = version |
| 39 |
path.write_text( |
| 40 |
json.dumps(manifest, indent=2) + "\n", encoding="utf-8", newline="\n" |
| 41 |
) |
| 42 |
|
| 43 |
|
| 44 |
def main() -> None: |
| 45 |
if len(sys.argv) != 2: |
| 46 |
sys.exit("usage: python scripts/bump_plugin_version.py VERSION") |
| 47 |
write_version(sys.argv[1]) |
| 48 |
print(f"wrote {PLUGIN_PATH}") |
| 49 |
|
| 50 |
|
| 51 |
if __name__ == "__main__": |
| 52 |
main() |