Skip to content

Commit 31454f9

Browse files
gh가 PATH에 없어도 찾아 쓰게 한다
갓 깐 직후에는 이미 떠 있는 셸의 PATH에 gh가 잡히지 않는다. 설치 자리를 몇 군데 더 본다. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent da18f82 commit 31454f9

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

tools/make_release.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,21 @@ def pack(root, zip_path):
203203
return digest
204204

205205

206+
def find_gh():
207+
"""gh를 찾는다. 갓 깐 직후에는 PATH에 아직 안 잡혀 있을 수 있다."""
208+
found = shutil.which("gh")
209+
if found:
210+
return found
211+
for candidate in (
212+
r"C:\Program Files\GitHub CLI\gh.exe",
213+
r"C:\Program Files (x86)\GitHub CLI\gh.exe",
214+
os.path.expandvars(r"%LOCALAPPDATA%\Microsoft\WinGet\Links\gh.exe"),
215+
):
216+
if os.path.exists(candidate):
217+
return candidate
218+
return None
219+
220+
206221
def git(*args, check=True):
207222
result = subprocess.run(["git"] + list(args), cwd=ROOT, capture_output=True, text=True,
208223
encoding="utf-8", errors="replace")
@@ -217,7 +232,8 @@ def publish(version, zips, digests):
217232
if git("status", "--porcelain"):
218233
fail("고치다 만 것이 남아 있습니다. 커밋하고 다시 하십시오.")
219234

220-
if shutil.which("gh") is None:
235+
gh = find_gh()
236+
if gh is None:
221237
print("\n gh(GitHub CLI)가 없어 Release는 만들지 못했습니다.")
222238
print(" 설치: winget install --id GitHub.cli")
223239
print(f" 또는 아래에서 {tag} 태그로 직접 올리십시오.")
@@ -236,16 +252,16 @@ def publish(version, zips, digests):
236252
write_notes(notes, version, zips, digests)
237253

238254
# 태그를 밀면 워크플로가 먼저 초안을 만들어 둘 수 있다. 있으면 파일만 얹는다.
239-
exists = subprocess.run(["gh", "release", "view", tag], cwd=ROOT,
255+
exists = subprocess.run([gh, "release", "view", tag], cwd=ROOT,
240256
capture_output=True, text=True,
241257
encoding="utf-8", errors="replace").returncode == 0
242258

243259
if exists:
244260
print(f" Release {tag}가 이미 있어 파일만 올립니다")
245-
command = ["gh", "release", "upload", tag] + zips + ["--clobber"]
261+
command = [gh, "release", "upload", tag] + zips + ["--clobber"]
246262
else:
247263
print(f" Release {tag} 만드는 중")
248-
command = (["gh", "release", "create", tag] + zips
264+
command = ([gh, "release", "create", tag] + zips
249265
+ ["--title", f"한글패치 {tag}", "--notes-file", notes])
250266

251267
result = subprocess.run(command, cwd=ROOT, capture_output=True, text=True,

0 commit comments

Comments
 (0)