debug: extensive logging in release workflow
Local Build and Deploy / deploy (push) Successful in 1m24s
Local Build and Deploy / deploy (push) Successful in 1m24s
This commit is contained in:
1 parent
323e2cd9d3
commit
02df513b18
1 file changed
+26
-10
@@ -7,7 +7,15 @@ jobs:
|
|||||||
release:
|
release:
|
||||||
runs-on: shell
|
runs-on: shell
|
||||||
steps:
|
steps:
|
||||||
- name: Build & release
|
- name: Debug - check bare repo
|
||||||
|
run: |
|
||||||
|
echo "=== DEBUG ==="
|
||||||
|
echo "PWD: $(pwd)"
|
||||||
|
echo "BARE exists: $(test -d /docker/gitea/gitea/git/repositories/remco/epicnext-cms.git && echo YES || echo NO)"
|
||||||
|
echo "Tags: $(git -C /docker/gitea/gitea/git/repositories/remco/epicnext-cms.git tag -l 2>&1)"
|
||||||
|
echo "Log: $(git -C /docker/gitea/gitea/git/repositories/remco/epicnext-cms.git log --oneline v1.0 2>&1 | head -3)"
|
||||||
|
echo "=== END ==="
|
||||||
|
- name: Create release
|
||||||
env:
|
env:
|
||||||
VERSION: ${{ gitea.ref_name }}
|
VERSION: ${{ gitea.ref_name }}
|
||||||
GITEA_API: ${{ gitea.api_url }}
|
GITEA_API: ${{ gitea.api_url }}
|
||||||
@@ -19,15 +27,20 @@ jobs:
|
|||||||
BARE="/docker/gitea/gitea/git/repositories/remco/epicnext-cms.git"
|
BARE="/docker/gitea/gitea/git/repositories/remco/epicnext-cms.git"
|
||||||
echo "=== START ${VERSION} ==="
|
echo "=== START ${VERSION} ==="
|
||||||
|
|
||||||
# Generate changelog from bare repo (always has full history)
|
echo "=== Tags in bare repo ==="
|
||||||
|
git -C "$BARE" tag -l
|
||||||
|
echo "=== Done ==="
|
||||||
|
|
||||||
|
echo "=== Log for ${VERSION} ==="
|
||||||
|
git -C "$BARE" log --oneline --no-decorate "${VERSION}" 2>&1 || echo "LOG FAILED"
|
||||||
|
echo "=== Done ==="
|
||||||
|
|
||||||
PREV_TAG="$(git -C "$BARE" tag --sort=-creatordate | head -2 | tail -1 || echo '')"
|
PREV_TAG="$(git -C "$BARE" tag --sort=-creatordate | head -2 | tail -1 || echo '')"
|
||||||
echo "Previous tag: ${PREV_TAG}"
|
echo "Previous tag: '${PREV_TAG}'"
|
||||||
|
|
||||||
if [ -n "$PREV_TAG" ] && [ "$PREV_TAG" != "$VERSION" ]; then
|
if [ -n "$PREV_TAG" ] && [ "$PREV_TAG" != "$VERSION" ]; then
|
||||||
echo "Range: ${PREV_TAG}..${VERSION}"
|
|
||||||
CHANGELOG="$(git -C "$BARE" log --oneline --no-decorate "${PREV_TAG}..${VERSION}" 2>&1)"
|
CHANGELOG="$(git -C "$BARE" log --oneline --no-decorate "${PREV_TAG}..${VERSION}" 2>&1)"
|
||||||
else
|
else
|
||||||
echo "First release or same tag"
|
|
||||||
CHANGELOG="$(git -C "$BARE" log --oneline --no-decorate "${VERSION}" 2>&1)"
|
CHANGELOG="$(git -C "$BARE" log --oneline --no-decorate "${VERSION}" 2>&1)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -37,10 +50,9 @@ jobs:
|
|||||||
echo "${CHANGELOG}"
|
echo "${CHANGELOG}"
|
||||||
echo "=== End ==="
|
echo "=== End ==="
|
||||||
|
|
||||||
# Write to file for API step
|
|
||||||
echo "$CHANGELOG" > /tmp/changelog.txt
|
echo "$CHANGELOG" > /tmp/changelog.txt
|
||||||
|
|
||||||
# Clone for build
|
# Build
|
||||||
SRC="/tmp/epicnext-release"
|
SRC="/tmp/epicnext-release"
|
||||||
rm -rf "$SRC"
|
rm -rf "$SRC"
|
||||||
git clone --branch "${VERSION}" --depth 1 "$BARE" "$SRC"
|
git clone --branch "${VERSION}" --depth 1 "$BARE" "$SRC"
|
||||||
@@ -54,9 +66,10 @@ jobs:
|
|||||||
export SKIP_ENV_VALIDATION=1
|
export SKIP_ENV_VALIDATION=1
|
||||||
pnpm build
|
pnpm build
|
||||||
|
|
||||||
# Create release via Gitea API
|
# Create release
|
||||||
echo "=== Creating/updating release ==="
|
echo "=== Creating release ==="
|
||||||
NOTES="$(cat /tmp/changelog.txt)"
|
NOTES="$(cat /tmp/changelog.txt)"
|
||||||
|
echo "NOTES length: ${#NOTES}"
|
||||||
BODY="## EpicNext-CMS ${VERSION}
|
BODY="## EpicNext-CMS ${VERSION}
|
||||||
|
|
||||||
### Changes
|
### Changes
|
||||||
@@ -65,17 +78,19 @@ ${NOTES}
|
|||||||
---
|
---
|
||||||
*Automated release from Gitea Actions*
|
*Automated release from Gitea Actions*
|
||||||
"
|
"
|
||||||
|
echo "BODY length: ${#BODY}"
|
||||||
|
|
||||||
PAYLOAD="$(echo "$BODY" | jq -Rs '{tag_name: $v, name: $v, body: ., draft: false, prerelease: false}' --arg v "${VERSION}" 2>&1)"
|
PAYLOAD="$(echo "$BODY" | jq -Rs '{tag_name: $v, name: $v, body: ., draft: false, prerelease: false}' --arg v "${VERSION}" 2>&1)"
|
||||||
echo "Payload: ${#PAYLOAD} bytes"
|
echo "Payload: ${#PAYLOAD} bytes"
|
||||||
|
echo "PAYLOAD: ${PAYLOAD:0:200}..."
|
||||||
|
|
||||||
# Try create, fallback to update
|
|
||||||
HTTP_CODE="$(curl -s -w '%{http_code}' -o /tmp/release-resp.json \
|
HTTP_CODE="$(curl -s -w '%{http_code}' -o /tmp/release-resp.json \
|
||||||
-X POST "${GITEA_API}/repos/${GITEA_REPO}/releases" \
|
-X POST "${GITEA_API}/repos/${GITEA_REPO}/releases" \
|
||||||
-H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
|
-H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "$PAYLOAD" 2>&1)"
|
-d "$PAYLOAD" 2>&1)"
|
||||||
echo "POST response: ${HTTP_CODE}"
|
echo "POST response: ${HTTP_CODE}"
|
||||||
|
echo "Response: $(cat /tmp/release-resp.json | head -5)"
|
||||||
|
|
||||||
if [ "${HTTP_CODE}" = "409" ]; then
|
if [ "${HTTP_CODE}" = "409" ]; then
|
||||||
echo "Release exists, updating..."
|
echo "Release exists, updating..."
|
||||||
@@ -94,6 +109,7 @@ ${NOTES}
|
|||||||
if [ "${HTTP_CODE:-0}" -ge 200 ] && [ "${HTTP_CODE:-0}" -lt 300 ]; then
|
if [ "${HTTP_CODE:-0}" -ge 200 ] && [ "${HTTP_CODE:-0}" -lt 300 ]; then
|
||||||
echo "SUCCESS"
|
echo "SUCCESS"
|
||||||
cat /tmp/release-resp.json | jq -r '.html_url // .id' 2>/dev/null || true
|
cat /tmp/release-resp.json | jq -r '.html_url // .id' 2>/dev/null || true
|
||||||
|
echo "BODY: $(cat /tmp/release-resp.json | jq -r '.body // "none"' | head -5)"
|
||||||
else
|
else
|
||||||
echo "FAILED with HTTP ${HTTP_CODE}"
|
echo "FAILED with HTTP ${HTTP_CODE}"
|
||||||
cat /tmp/release-resp.json 2>/dev/null || true
|
cat /tmp/release-resp.json 2>/dev/null || true
|
||||||
|
|||||||
Reference in new issue
Block a user