Files
EpicNext-Cms/.gitea/workflows/release.yaml
T
Workflow config file is invalid. Please check your config file: go-yaml load error in scanner (while scanning a simple key) at L76.C1-L78.C1: could not find expected ':'
openhands 02df513b18
Local Build and Deploy / deploy (push) Successful in 1m24s
debug: extensive logging in release workflow
2026-07-20 15:42:46 +02:00

120 lines
4.4 KiB
YAML

name: Create Release
on:
push:
tags:
- "v*"
jobs:
release:
runs-on: shell
steps:
- 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:
VERSION: ${{ gitea.ref_name }}
GITEA_API: ${{ gitea.api_url }}
GITEA_REPO: ${{ gitea.repository }}
run: |
set -e
exec 2>&1
BARE="/docker/gitea/gitea/git/repositories/remco/epicnext-cms.git"
echo "=== START ${VERSION} ==="
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 '')"
echo "Previous tag: '${PREV_TAG}'"
if [ -n "$PREV_TAG" ] && [ "$PREV_TAG" != "$VERSION" ]; then
CHANGELOG="$(git -C "$BARE" log --oneline --no-decorate "${PREV_TAG}..${VERSION}" 2>&1)"
else
CHANGELOG="$(git -C "$BARE" log --oneline --no-decorate "${VERSION}" 2>&1)"
fi
[ -z "$CHANGELOG" ] && CHANGELOG="Initial release"
echo "=== Changelog (${#CHANGELOG} chars) ==="
echo "${CHANGELOG}"
echo "=== End ==="
echo "$CHANGELOG" > /tmp/changelog.txt
# Build
SRC="/tmp/epicnext-release"
rm -rf "$SRC"
git clone --branch "${VERSION}" --depth 1 "$BARE" "$SRC"
cd "$SRC"
if [ -f /var/www/atom-nexst/.env ]; then
cp /var/www/atom-nexst/.env "$SRC/.env"
fi
pnpm install --frozen-lockfile
pnpm prisma:generate
export SKIP_ENV_VALIDATION=1
pnpm build
# Create release
echo "=== Creating release ==="
NOTES="$(cat /tmp/changelog.txt)"
echo "NOTES length: ${#NOTES}"
BODY="## EpicNext-CMS ${VERSION}
### Changes
${NOTES}
---
*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)"
echo "Payload: ${#PAYLOAD} bytes"
echo "PAYLOAD: ${PAYLOAD:0:200}..."
HTTP_CODE="$(curl -s -w '%{http_code}' -o /tmp/release-resp.json \
-X POST "${GITEA_API}/repos/${GITEA_REPO}/releases" \
-H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
-H "Content-Type: application/json" \
-d "$PAYLOAD" 2>&1)"
echo "POST response: ${HTTP_CODE}"
echo "Response: $(cat /tmp/release-resp.json | head -5)"
if [ "${HTTP_CODE}" = "409" ]; then
echo "Release exists, updating..."
RELEASES="$(curl -sf "${GITEA_API}/repos/${GITEA_REPO}/releases" \
-H "Authorization: token ${{ secrets.GITEA_TOKEN }}")"
REL_ID="$(echo "$RELEASES" | jq -r ".[] | select(.tag_name==\"${VERSION}\") | .id")"
echo "Release ID: ${REL_ID}"
HTTP_CODE="$(curl -s -w '%{http_code}' -o /tmp/release-resp.json \
-X PATCH "${GITEA_API}/repos/${GITEA_REPO}/releases/${REL_ID}" \
-H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
-H "Content-Type: application/json" \
-d "$PAYLOAD" 2>&1)"
echo "PATCH response: ${HTTP_CODE}"
fi
if [ "${HTTP_CODE:-0}" -ge 200 ] && [ "${HTTP_CODE:-0}" -lt 300 ]; then
echo "SUCCESS"
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
echo "FAILED with HTTP ${HTTP_CODE}"
cat /tmp/release-resp.json 2>/dev/null || true
exit 1
fi
echo "=== DONE ==="