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 L62.C1-L64.C1: could not find expected ':'
openhands 26da114e0e
Local Build and Deploy / deploy (push) Successful in 1m27s
fix: use curl+jq instead of Python for release creation
Eliminates potential Python/heredoc issues in Gitea Actions runner.
Full clone guarantees git history is available for changelog.
2026-07-20 15:29:54 +02:00

96 lines
3.2 KiB
YAML

name: Create Release
on:
push:
tags:
- "v*"
jobs:
release:
runs-on: shell
steps:
- name: Build & release
env:
VERSION: ${{ gitea.ref_name }}
GITEA_API: ${{ gitea.api_url }}
GITEA_REPO: ${{ gitea.repository }}
run: |
set -e
exec 2>&1
echo "=== VERSION=${VERSION} ==="
echo "=== API=${GITEA_API} ==="
echo "=== REPO=${GITEA_REPO} ==="
SRC="/tmp/epicnext-release"
rm -rf "$SRC"
git clone --branch "${VERSION}" \
/docker/gitea/gitea/git/repositories/remco/epicnext-cms.git \
"$SRC" 2>&1
cd "$SRC"
echo "=== Cloned ==="
PREV_TAG="$(git tag --sort=-creatordate | head -2 | tail -1 || echo '')"
echo "=== Tags ==="
git tag --sort=-creatordate
echo "=== Previous=${PREV_TAG} ==="
if [ -n "$PREV_TAG" ] && [ "$PREV_TAG" != "$VERSION" ]; then
git log --oneline --no-decorate "${PREV_TAG}..${VERSION}" > /tmp/changelog.txt
else
git log --oneline --no-decorate "${VERSION}" > /tmp/changelog.txt
fi
echo "=== Changelog ==="
cat /tmp/changelog.txt
echo "=== End ==="
if [ -f /var/www/atom-nexst/.env ]; then
cp /var/www/atom-nexst/.env "$SRC/.env"
fi
pnpm install --frozen-lockfile 2>&1
pnpm prisma:generate 2>&1
export SKIP_ENV_VALIDATION=1
pnpm build 2>&1
echo "=== Creating release ==="
NOTES="$(cat /tmp/changelog.txt)"
[ -z "$NOTES" ] && NOTES="Initial release"
# Build JSON with jq, send with curl
BODY="## EpicNext-CMS ${VERSION}
### Changes
${NOTES}
---
*Automated release from Gitea Actions*
"
PAYLOAD="$(echo "$BODY" | jq -Rs '{tag_name: $v, name: $v, body: ., draft: false, prerelease: false}' --arg v "${VERSION}")"
echo "Payload length: ${#PAYLOAD}"
RESP="$(curl -s -w '\n%{http_code}' -X POST \
"${GITEA_API}/repos/${GITEA_REPO}/releases" \
-H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
-H "Content-Type: application/json" \
-d "$PAYLOAD")"
HTTP_CODE="$(echo "$RESP" | tail -1)"
RESP_BODY="$(echo "$RESP" | head -n -1)"
echo "HTTP ${HTTP_CODE}: ${RESP_BODY:0:200}"
if [ "$HTTP_CODE" = "409" ] || [ "$HTTP_CODE" = "409" ]; then
# Release exists — update it
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")"
if [ -n "$REL_ID" ] && [ "$REL_ID" != "null" ]; then
RESP2="$(curl -s -w '\n%{http_code}' -X PATCH \
"${GITEA_API}/repos/${GITEA_REPO}/releases/${REL_ID}" \
-H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
-H "Content-Type: application/json" \
-d "$PAYLOAD")"
echo "PATCH result: $(echo "$RESP2" | tail -1)"
fi
fi
echo "=== Done ==="