Skip to content

Commit 647eee1

Browse files
authored
Mcpb auto versioning (#27)
* autoversioning of mcpb file from git tag
1 parent 353ae6f commit 647eee1

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

.github/workflows/build-mcpb.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ jobs:
1414
- name: Checkout repository
1515
uses: actions/checkout@v4
1616

17+
- name: Setup Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: '3.12'
21+
22+
- name: Sync manifest version
23+
run: |
24+
python -m pip install --upgrade pip setuptools_scm
25+
python tools/update_manifest_version.py
26+
1727
- name: Setup Node.js
1828
uses: actions/setup-node@v4
1929
with:

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ dev = [
3030
"basedpyright>=1.25.0",
3131
"pytest>=8.3.0",
3232
"ruff>=0.9.3",
33+
"setuptools-scm>=8",
3334
"types-pyyaml>=6.0.12.20241230",
3435
"types-requests>=2.32.0.20241016",
3536
]

tools/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Helper scripts for project tooling."""

tools/update_manifest_version.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"""Update manifest.json version from setuptools_scm."""
2+
3+
from __future__ import annotations
4+
5+
import json
6+
from pathlib import Path
7+
8+
from setuptools_scm import get_version
9+
10+
11+
def main() -> None:
12+
manifest_path = Path("manifest.json")
13+
manifest_data = json.loads(manifest_path.read_text())
14+
15+
manifest_data["version"] = get_version()
16+
manifest_path.write_text(json.dumps(manifest_data, indent=2) + "\n")
17+
18+
19+
if __name__ == "__main__":
20+
main()

0 commit comments

Comments
 (0)