forked from planetarium/NineChronicles.Headless
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prepare-pluggable-lib9c.py
58 lines (42 loc) · 1.14 KB
/
prepare-pluggable-lib9c.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import tomllib
import tempfile
import os
import subprocess
import shutil
from typing import TypedDict
from git import Repo
class VersionSpec(TypedDict):
ref: str
class BuildConfiguration(TypedDict):
output_path: str
repository_url: str
class Configuration(TypedDict):
versions: dict[str, VersionSpec]
config: BuildConfiguration
conf: Configuration
with open(".versions.toml", "rb") as f:
conf = tomllib.load(f)
output_path = conf["config"]["output_path"]
repository_url = conf["config"]["repository_url"]
tmpdir = tempfile.mkdtemp()
if os.path.exists(output_path):
shutil.rmtree(output_path)
os.mkdir(output_path)
repo = Repo.clone_from(repository_url, tmpdir, multi_options=["--recurse-submodules"])
for version, spec in conf["versions"].items():
ref = spec["ref"]
repo.head.reset(ref)
publish_directory = os.path.join(output_path, version)
subprocess.run(
[
"dotnet",
"publish",
"Lib9c/Lib9c.csproj",
"-c",
"Release",
"-o",
publish_directory,
],
cwd=tmpdir,
capture_output=True,
)