Skip to content

Commit

Permalink
show output of failed commands
Browse files Browse the repository at this point in the history
  • Loading branch information
femnad committed Dec 23, 2023
1 parent d6fa732 commit 367023d
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions .github/workflows/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,29 @@
import re
import subprocess
import shlex
import sys

MAIN_FILE = 'main.go'
VERSION_LINE = re.compile('version = "([0-9]+.[0-9]+.[0-9]+)"')


def sh(cmd: str, env: dict | None = None) -> str:
cmd_parsed = shlex.split(cmd)
output = subprocess.run(cmd_parsed, check=True, text=True, capture_output=True, env=env)
return output.stdout.strip()
proc = subprocess.run(cmd_parsed, check=True, text=True, capture_output=True, env=env)
stdout = proc.stdout.strip()
code = proc.returncode
if code:
out = ''
stderr = proc.stderr.strip()
if stderr:
out += f'stderr: {stderr}'
if stdout:
prefix = ', ' if out else ''
out += f'{prefix}stdout: {stdout}'
print(f'Command {cmd} exited with code {code}, output: {out}')
sys.exit(code)

return proc.stdout.strip()


def get_current_version() -> str:
Expand Down

0 comments on commit 367023d

Please sign in to comment.