Local Build and Deploy / deploy (push) Successful in 1m26s
Bare git repo has no HEAD; git log without --all showed nothing. Now uses /var/www/atom-nexst (full checkout with proper HEAD). Also adds debug output and handles first-release edge case.
105 lines
3.1 KiB
YAML
105 lines
3.1 KiB
YAML
name: Create Release
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*"
|
|
jobs:
|
|
release:
|
|
runs-on: shell
|
|
steps:
|
|
- name: Checkout, build & release
|
|
env:
|
|
VERSION: ${{ gitea.ref_name }}
|
|
GITEA_API: ${{ gitea.api_url }}
|
|
GITEA_REPO: ${{ gitea.repository }}
|
|
run: |
|
|
set -e
|
|
|
|
# Use the local checkout (has full history + HEAD)
|
|
LOCAL="/var/www/atom-nexst"
|
|
|
|
# ── Generate changelog ────────────────────────────────────────
|
|
PREV_TAG="$(git -C "$LOCAL" tag --sort=-creatordate | head -2 | tail -1 || echo '')"
|
|
echo "=== Debug: VERSION=$VERSION PREV_TAG=$PREV_TAG ==="
|
|
|
|
if [ -n "$PREV_TAG" ] && [ "$PREV_TAG" != "$VERSION" ]; then
|
|
RANGE="${PREV_TAG}..${VERSION}"
|
|
echo "=== Range: $RANGE ==="
|
|
git -C "$LOCAL" log --oneline --no-decorate "${RANGE}" > /tmp/changelog.txt
|
|
else
|
|
# First release or only one tag — show all commits up to this tag
|
|
echo "=== First release or only one tag, showing all commits ==="
|
|
git -C "$LOCAL" log --oneline --no-decorate "${VERSION}" > /tmp/changelog.txt
|
|
fi
|
|
|
|
echo "=== Changelog ==="
|
|
cat /tmp/changelog.txt
|
|
echo "=== End changelog ==="
|
|
|
|
# ── Build ─────────────────────────────────────────────────────
|
|
SRC="/tmp/epicnext-release"
|
|
rm -rf "$SRC"
|
|
git clone --branch "${VERSION}" --depth 1 \
|
|
/docker/gitea/gitea/git/repositories/remco/epicnext-cms.git \
|
|
"$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 (Python handles JSON properly) ─────────────
|
|
python3 << 'PYEOF'
|
|
import json, os, urllib.request
|
|
|
|
version = os.environ['VERSION']
|
|
api = os.environ['GITEA_API']
|
|
repo = os.environ['GITEA_REPO']
|
|
token = "${{ secrets.GITEA_TOKEN }}"
|
|
|
|
with open('/tmp/changelog.txt') as f:
|
|
notes = f.read().strip()
|
|
|
|
if not notes:
|
|
notes = "Initial release"
|
|
|
|
body = f"""## EpicNext-CMS {version}
|
|
|
|
### Changes
|
|
{notes}
|
|
|
|
---
|
|
*Automated release from Gitea Actions*
|
|
"""
|
|
|
|
payload = json.dumps({
|
|
'tag_name': version,
|
|
'name': version,
|
|
'body': body,
|
|
'draft': False,
|
|
'prerelease': False,
|
|
}).encode('utf-8')
|
|
|
|
req = urllib.request.Request(
|
|
f'{api}/repos/{repo}/releases',
|
|
data=payload,
|
|
headers={
|
|
'Authorization': f'token {token}',
|
|
'Content-Type': 'application/json',
|
|
},
|
|
method='POST',
|
|
)
|
|
|
|
try:
|
|
resp = urllib.request.urlopen(req)
|
|
result = json.loads(resp.read().decode('utf-8'))
|
|
print(f"Release created: {result.get('html_url', result.get('id', '?'))}")
|
|
except urllib.error.HTTPError as e:
|
|
print(f"API error {e.code}: {e.read().decode('utf-8')}")
|
|
raise
|
|
PYEOF
|