From 367023d2a13abcbf769a1e03ffcd291352e79e4d Mon Sep 17 00:00:00 2001 From: fcd <1352288+femnad@users.noreply.github.com> Date: Sat, 23 Dec 2023 22:21:21 +0300 Subject: [PATCH] show output of failed commands --- .github/workflows/release.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.py b/.github/workflows/release.py index 54b6bcb..6e3c8e7 100644 --- a/.github/workflows/release.py +++ b/.github/workflows/release.py @@ -3,6 +3,7 @@ import re import subprocess import shlex +import sys MAIN_FILE = 'main.go' VERSION_LINE = re.compile('version = "([0-9]+.[0-9]+.[0-9]+)"') @@ -10,8 +11,21 @@ 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: