Skip to content

Commit cf48178

Browse files
committed
add exeption handling for publishing script
1 parent e0967f7 commit cf48178

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

scripts/publish.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
11
import os
2+
import subprocess
3+
import sys
24
from pathlib import Path
3-
from subprocess import run
5+
from typing import Any
46

57
from scripts.tools import get_version
68

79

10+
def run(title: str, *args: Any, **kwargs: Any) -> None:
11+
try:
12+
print(f"running {title}")
13+
subprocess.run(*args, **kwargs)
14+
except (SystemExit, KeyboardInterrupt):
15+
raise
16+
except BaseException as e:
17+
print(f"{title} failed: {e}", file=sys.stderr)
18+
pass
19+
20+
821
def main() -> None:
922
dist_path = Path("./dist")
1023

@@ -15,14 +28,10 @@ def main() -> None:
1528

1629
vsix_path = Path(dist_path, f"robotcode-{current_version}.vsix")
1730

18-
print("publish to vscode marketplace...")
19-
run(f"npx vsce publish -i {vsix_path}", shell=True, timeout=600)
20-
21-
print("publish to openVSX...")
22-
run(f"npx ovsx publish {vsix_path}", shell=True, timeout=600)
23-
24-
print("publish to PyPi...")
31+
run("npx vsce publish", f"npx vsce publish -i {vsix_path}", shell=True, timeout=600)
32+
run("npx ovsx publish", f"npx ovsx publish {vsix_path}", shell=True, timeout=600)
2533
run(
34+
"poetry publish",
2635
f"poetry publish --username {os.environ['PYPI_USERNAME']} --password {os.environ['PYPI_PASSWORD']}",
2736
shell=True,
2837
timeout=600,

0 commit comments

Comments
 (0)