debug: add extensive logging to release workflow
Local Build and Deploy / deploy (push) Successful in 1m20s

Writes debug output to /tmp/release-debug.log for post-mortem analysis.
This commit is contained in:
openhands committed 2026-07-20 15:23:14 +02:00
1 parent 57ef6289ff
commit 25a8d6ab22
1 file changed
+54 -43
+54 -43
View File
@@ -16,66 +16,73 @@ jobs:
set -e
LOCAL="/var/www/atom-nexst"
DEBUG="/tmp/release-debug.log"
: > "$DEBUG"
debug() { echo "[$(date '+%H:%M:%S')] $*" >> "$DEBUG"; }
debug "=== RELEASE WORKFLOW START ==="
debug "VERSION=${VERSION}"
debug "PWD=$(pwd)"
debug "LOCAL=${LOCAL}"
debug "git -C ${LOCAL} tag list:"
git -C "$LOCAL" tag --sort=-creatordate >> "$DEBUG" 2>&1
debug "git -C ${LOCAL} log -1:"
git -C "$LOCAL" log --oneline -1 >> "$DEBUG" 2>&1
# Generate changelog to a temp file
PREV_TAG="$(git -C "$LOCAL" tag --sort=-creatordate | head -2 | tail -1 || echo '')"
debug "PREV_TAG=${PREV_TAG}"
if [ -n "$PREV_TAG" ] && [ "$PREV_TAG" != "$VERSION" ]; then
RANGE="${PREV_TAG}..${VERSION}"
debug "RANGE=${RANGE}"
git -C "$LOCAL" log --oneline --no-decorate "${RANGE}" > /tmp/changelog.txt 2>>"$DEBUG"
else
debug "First tag or same tag, using ${VERSION}"
git -C "$LOCAL" log --oneline --no-decorate "${VERSION}" > /tmp/changelog.txt 2>>"$DEBUG"
fi
NOTES="$(cat /tmp/changelog.txt)"
debug "NOTES length: ${#NOTES}"
debug "NOTES first 200 chars: ${NOTES:0:200}"
# Shallow clone for build
SRC="/tmp/epicnext-release"
rm -rf "$SRC"
git clone --branch "${VERSION}" --depth 1 \
/docker/gitea/gitea/git/repositories/remco/epicnext-cms.git \
"$SRC"
"$SRC" 2>>"$DEBUG"
cd "$SRC"
if [ -f /var/www/atom-nexst/.env ]; then
cp /var/www/atom-nexst/.env "$SRC/.env"
fi
cd "$SRC"
pnpm install --frozen-lockfile
pnpm prisma:generate
pnpm install --frozen-lockfile 2>>"$DEBUG"
pnpm prisma:generate 2>>"$DEBUG"
export SKIP_ENV_VALIDATION=1
pnpm build
pnpm build 2>>"$DEBUG"
# Create release — Python reads changelog directly from git
python3 << 'PYEOF'
import json, os, subprocess, urllib.request, urllib.error
# Create release via API
debug "Creating release..."
python3 /dev/stdin << 'PYEOF' 2>>"$DEBUG"
import json, os
version = os.environ["VERSION"]
api = os.environ["GITEA_API"]
repo = os.environ["GITEA_REPO"]
token = "${{ secrets.GITEA_TOKEN }}"
local = "/var/www/atom-nexst"
# Get previous tag
tags = subprocess.run(
["git", "-C", local, "tag", "--sort=-creatordate"],
capture_output=True, text=True, check=False,
).stdout.strip().split("\n")
tags = [t for t in tags if t]
with open("/tmp/changelog.txt") as f:
notes_raw = f.read().strip()
prev_tag = tags[1] if len(tags) > 1 else ""
print(f"Tags: {tags}")
print(f"Version: {version}, Previous: {prev_tag}")
if prev_tag and prev_tag != version:
r = subprocess.run(
["git", "-C", local, "log", "--oneline", "--no-decorate", f"{prev_tag}..{version}"],
capture_output=True, text=True, check=False,
)
notes_raw = r.stdout.strip()
print(f"Range: {prev_tag}..{version}, stderr: {r.stderr.strip()}")
else:
r = subprocess.run(
["git", "-C", local, "log", "--oneline", "--no-decorate", version],
capture_output=True, text=True, check=False,
)
notes_raw = r.stdout.strip()
print(f"Single tag {version}, stderr: {r.stderr.strip()}")
print(f"Read {len(notes_raw)} chars from /tmp/changelog.txt")
print(f"Token set: {bool(token)}")
print(f"API URL: {api}")
if not notes_raw:
notes_raw = "Initial release"
print(f"Notes ({len(notes_raw)} chars):")
print(notes_raw)
print("=== End notes ===")
body = f"""## EpicNext-CMS {version}
### Changes
@@ -93,9 +100,11 @@ payload = json.dumps({
"prerelease": False,
}).encode("utf-8")
import urllib.request, urllib.error
def api_call(method, path, data=None):
url = f"{api}/repos/{repo}/{path}"
print(f"API {method} {url}")
print(f"{method} {url}")
req = urllib.request.Request(
url, data=data,
headers={
@@ -109,20 +118,22 @@ def api_call(method, path, data=None):
try:
result = api_call("POST", "releases", payload)
print(f"Release created: {result.get('html_url', result.get('id', '?'))}")
print(f"Created: {result.get('html_url', result.get('id', '?'))}")
except urllib.error.HTTPError as e:
err_body = e.read().decode("utf-8")
print(f"POST error {e.code}: {err_body}")
err = e.read().decode("utf-8")
print(f"POST {e.code}: {err}")
if e.code == 409:
releases = api_call("GET", "releases")
for rel in releases:
if rel["tag_name"] == version:
result = api_call("PATCH", f"releases/{rel['id']}", payload)
print(f"Release updated: {result.get('html_url', result.get('id', '?'))}")
print(f"Updated: {result.get('html_url', result.get('id', '?'))}")
break
else:
print(f"ERROR: no existing release found for {version}")
raise
else:
raise
PYEOF
debug "=== RELEASE WORKFLOW END ==="
echo "Debug log: $DEBUG"