Skip to content
This repository was archived by the owner on Apr 9, 2026. It is now read-only.

Commit af232e6

Browse files
author
Legends11
committed
refactor(ci): pack-mcmeta-editor Python lojiği .github/scripts/edit_pack_mcmeta.py'ye taşındı
Workflow artık sadece input alma, validasyon ve commit yapar. Python inline heredoc sorunları tamamen ortadan kalktı.
1 parent b69f48d commit af232e6

2 files changed

Lines changed: 88 additions & 70 deletions

File tree

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#!/usr/bin/env python3
2+
"""
3+
pack.mcmeta düzenleyici.
4+
Kullanım: edit_pack_mcmeta.py <pack_format> <supported_min> <supported_max> [overlay_file]
5+
overlay_file: her satır "<directory>=<min>:<max>" formatında
6+
"""
7+
8+
import json
9+
import sys
10+
11+
12+
def main():
13+
if len(sys.argv) < 4:
14+
print("Kullanım: edit_pack_mcmeta.py <pack_format> <supported_min> <supported_max> [overlay_file]")
15+
sys.exit(1)
16+
17+
pf = int(sys.argv[1])
18+
smin = int(sys.argv[2])
19+
smax = int(sys.argv[3])
20+
overlay_file = sys.argv[4] if len(sys.argv) > 4 else None
21+
22+
overlay_raw = ""
23+
if overlay_file:
24+
with open(overlay_file, "r", encoding="utf-8") as f:
25+
overlay_raw = f.read().strip()
26+
27+
with open("pack.mcmeta", "r", encoding="utf-8") as f:
28+
meta = json.load(f)
29+
30+
old_pf = meta["pack"]["pack_format"]
31+
old_smin = meta["pack"].get("supported_formats", {}).get("min_inclusive", "?")
32+
old_smax = meta["pack"].get("supported_formats", {}).get("max_inclusive", "?")
33+
34+
meta["pack"]["pack_format"] = pf
35+
meta["pack"]["supported_formats"] = {
36+
"min_inclusive": smin,
37+
"max_inclusive": smax,
38+
}
39+
40+
if "min_format" in meta["pack"]:
41+
meta["pack"]["min_format"] = smin
42+
if "max_format" in meta["pack"]:
43+
meta["pack"]["max_format"] = smax
44+
45+
print(f"pack_format : {old_pf}{pf}")
46+
print(f"supported_formats: [{old_smin}, {old_smax}] → [{smin}, {smax}]")
47+
48+
if overlay_raw:
49+
entries = {e["directory"]: e for e in meta.get("overlays", {}).get("entries", [])}
50+
for line in overlay_raw.splitlines():
51+
line = line.strip()
52+
if not line or "=" not in line or ":" not in line:
53+
continue
54+
directory, fmt = line.split("=", 1)
55+
directory = directory.strip()
56+
o_min, o_max = fmt.strip().split(":", 1)
57+
o_min, o_max = int(o_min), int(o_max)
58+
59+
if directory in entries:
60+
old_fmt = entries[directory].get("formats", {})
61+
old_min = old_fmt.get("min_inclusive", "?")
62+
old_max = old_fmt.get("max_inclusive", "?")
63+
entries[directory]["formats"] = {
64+
"min_inclusive": o_min,
65+
"max_inclusive": o_max,
66+
}
67+
if "min_format" in entries[directory]:
68+
entries[directory]["min_format"] = o_min
69+
if "max_format" in entries[directory]:
70+
entries[directory]["max_format"] = o_max
71+
print(f"overlay '{directory}': [{old_min}, {old_max}] → [{o_min}, {o_max}]")
72+
else:
73+
print(f"WARN: overlay '{directory}' pack.mcmeta'da bulunamadı, atlandı.")
74+
75+
with open("pack.mcmeta", "w", encoding="utf-8") as f:
76+
json.dump(meta, f, indent=2, ensure_ascii=False)
77+
f.write("\n")
78+
79+
print("pack.mcmeta güncellendi.")
80+
81+
82+
if __name__ == "__main__":
83+
main()

.github/workflows/pack-mcmeta-editor.yml

Lines changed: 5 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -88,78 +88,13 @@ jobs:
8888
echo "OK: Girdiler geçerli."
8989
9090
- name: Apply changes to pack.mcmeta
91-
env:
92-
PF: ${{ inputs.pack_format }}
93-
SMIN: ${{ inputs.supported_min }}
94-
SMAX: ${{ inputs.supported_max }}
9591
run: |
96-
# overlay_updates'i event JSON'undan jq ile güvenli çek
9792
jq -r '.inputs.overlay_updates // ""' "$GITHUB_EVENT_PATH" > /tmp/overlay_updates.txt
98-
99-
python3 - << 'PYEOF'
100-
import json, os
101-
102-
pf = int(os.environ['PF'])
103-
smin = int(os.environ['SMIN'])
104-
smax = int(os.environ['SMAX'])
105-
106-
with open('/tmp/overlay_updates.txt', 'r') as f:
107-
overlay_raw = f.read().strip()
108-
109-
with open('pack.mcmeta', 'r', encoding='utf-8') as f:
110-
meta = json.load(f)
111-
112-
old_pf = meta['pack']['pack_format']
113-
old_smin = meta['pack'].get('supported_formats', {}).get('min_inclusive', '?')
114-
old_smax = meta['pack'].get('supported_formats', {}).get('max_inclusive', '?')
115-
116-
meta['pack']['pack_format'] = pf
117-
meta['pack']['supported_formats'] = {
118-
'min_inclusive': smin,
119-
'max_inclusive': smax
120-
}
121-
122-
if 'min_format' in meta['pack']:
123-
meta['pack']['min_format'] = smin
124-
if 'max_format' in meta['pack']:
125-
meta['pack']['max_format'] = smax
126-
127-
print(f"pack_format : {old_pf} → {pf}")
128-
print(f"supported_formats: [{old_smin}, {old_smax}] → [{smin}, {smax}]")
129-
130-
if overlay_raw:
131-
entries = {e['directory']: e for e in meta.get('overlays', {}).get('entries', [])}
132-
for line in overlay_raw.splitlines():
133-
line = line.strip()
134-
if not line or '=' not in line or ':' not in line:
135-
continue
136-
directory, fmt = line.split('=', 1)
137-
directory = directory.strip()
138-
o_min, o_max = fmt.strip().split(':', 1)
139-
o_min, o_max = int(o_min), int(o_max)
140-
141-
if directory in entries:
142-
old_fmt = entries[directory].get('formats', {})
143-
old_min = old_fmt.get('min_inclusive', '?')
144-
old_max = old_fmt.get('max_inclusive', '?')
145-
entries[directory]['formats'] = {
146-
'min_inclusive': o_min,
147-
'max_inclusive': o_max
148-
}
149-
if 'min_format' in entries[directory]:
150-
entries[directory]['min_format'] = o_min
151-
if 'max_format' in entries[directory]:
152-
entries[directory]['max_format'] = o_max
153-
print(f"overlay '{directory}': [{old_min}, {old_max}] → [{o_min}, {o_max}]")
154-
else:
155-
print(f"WARN: overlay '{directory}' pack.mcmeta'da bulunamadı, atlandı.")
156-
157-
with open('pack.mcmeta', 'w', encoding='utf-8') as f:
158-
json.dump(meta, f, indent=2, ensure_ascii=False)
159-
f.write('\n')
160-
161-
print("pack.mcmeta güncellendi.")
162-
PYEOF
93+
python3 .github/scripts/edit_pack_mcmeta.py \
94+
"${{ inputs.pack_format }}" \
95+
"${{ inputs.supported_min }}" \
96+
"${{ inputs.supported_max }}" \
97+
/tmp/overlay_updates.txt
16398
16499
- name: Commit and push
165100
run: |

0 commit comments

Comments
 (0)