fix: full clone instead of shallow for proper changelog
Local Build and Deploy / deploy (push) Successful in 1m29s
Local Build and Deploy / deploy (push) Successful in 1m29s
Shallow clone (--depth 1) prevented git log from seeing full history. Local bare repo clone is instant, so full clone adds no network delay.
This commit is contained in:
1 parent
25a8d6ab22
commit
8badcd9c92
1 file changed
+32
-55
@@ -15,58 +15,46 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
LOCAL="/var/www/atom-nexst"
|
SRC="/tmp/epicnext-release"
|
||||||
DEBUG="/tmp/release-debug.log"
|
rm -rf "$SRC"
|
||||||
: > "$DEBUG"
|
|
||||||
|
|
||||||
debug() { echo "[$(date '+%H:%M:%S')] $*" >> "$DEBUG"; }
|
# Full clone for changelog + build (local bare repo = instant)
|
||||||
|
git clone --branch "${VERSION}" \
|
||||||
|
/docker/gitea/gitea/git/repositories/remco/epicnext-cms.git \
|
||||||
|
"$SRC"
|
||||||
|
cd "$SRC"
|
||||||
|
|
||||||
debug "=== RELEASE WORKFLOW START ==="
|
# Generate changelog
|
||||||
debug "VERSION=${VERSION}"
|
PREV_TAG="$(git tag --sort=-creatordate | head -2 | tail -1 || echo '')"
|
||||||
debug "PWD=$(pwd)"
|
echo "=== Tags ==="
|
||||||
debug "LOCAL=${LOCAL}"
|
git tag --sort=-creatordate
|
||||||
debug "git -C ${LOCAL} tag list:"
|
echo "=== Version=${VERSION} Previous=${PREV_TAG} ==="
|
||||||
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
|
if [ -n "$PREV_TAG" ] && [ "$PREV_TAG" != "$VERSION" ]; then
|
||||||
RANGE="${PREV_TAG}..${VERSION}"
|
RANGE="${PREV_TAG}..${VERSION}"
|
||||||
debug "RANGE=${RANGE}"
|
echo "=== Range: ${RANGE} ==="
|
||||||
git -C "$LOCAL" log --oneline --no-decorate "${RANGE}" > /tmp/changelog.txt 2>>"$DEBUG"
|
git log --oneline --no-decorate "${RANGE}" > /tmp/changelog.txt
|
||||||
else
|
else
|
||||||
debug "First tag or same tag, using ${VERSION}"
|
echo "=== First release, showing all commits ==="
|
||||||
git -C "$LOCAL" log --oneline --no-decorate "${VERSION}" > /tmp/changelog.txt 2>>"$DEBUG"
|
git log --oneline --no-decorate "${VERSION}" > /tmp/changelog.txt
|
||||||
fi
|
fi
|
||||||
|
|
||||||
NOTES="$(cat /tmp/changelog.txt)"
|
echo "=== Changelog ==="
|
||||||
debug "NOTES length: ${#NOTES}"
|
cat /tmp/changelog.txt
|
||||||
debug "NOTES first 200 chars: ${NOTES:0:200}"
|
echo "=== End ==="
|
||||||
|
|
||||||
# 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" 2>>"$DEBUG"
|
|
||||||
cd "$SRC"
|
|
||||||
|
|
||||||
|
# Build
|
||||||
if [ -f /var/www/atom-nexst/.env ]; then
|
if [ -f /var/www/atom-nexst/.env ]; then
|
||||||
cp /var/www/atom-nexst/.env "$SRC/.env"
|
cp /var/www/atom-nexst/.env "$SRC/.env"
|
||||||
fi
|
fi
|
||||||
pnpm install --frozen-lockfile 2>>"$DEBUG"
|
pnpm install --frozen-lockfile
|
||||||
pnpm prisma:generate 2>>"$DEBUG"
|
pnpm prisma:generate
|
||||||
export SKIP_ENV_VALIDATION=1
|
export SKIP_ENV_VALIDATION=1
|
||||||
pnpm build 2>>"$DEBUG"
|
pnpm build
|
||||||
|
|
||||||
# Create release via API
|
# Create release via API
|
||||||
debug "Creating release..."
|
python3 << 'PYEOF'
|
||||||
python3 /dev/stdin << 'PYEOF' 2>>"$DEBUG"
|
import json, os, urllib.request, urllib.error
|
||||||
import json, os
|
|
||||||
|
|
||||||
version = os.environ["VERSION"]
|
version = os.environ["VERSION"]
|
||||||
api = os.environ["GITEA_API"]
|
api = os.environ["GITEA_API"]
|
||||||
@@ -74,19 +62,14 @@ repo = os.environ["GITEA_REPO"]
|
|||||||
token = "${{ secrets.GITEA_TOKEN }}"
|
token = "${{ secrets.GITEA_TOKEN }}"
|
||||||
|
|
||||||
with open("/tmp/changelog.txt") as f:
|
with open("/tmp/changelog.txt") as f:
|
||||||
notes_raw = f.read().strip()
|
notes = f.read().strip() or "Initial release"
|
||||||
|
|
||||||
print(f"Read {len(notes_raw)} chars from /tmp/changelog.txt")
|
print(f"Changelog: {len(notes)} chars")
|
||||||
print(f"Token set: {bool(token)}")
|
|
||||||
print(f"API URL: {api}")
|
|
||||||
|
|
||||||
if not notes_raw:
|
|
||||||
notes_raw = "Initial release"
|
|
||||||
|
|
||||||
body = f"""## EpicNext-CMS {version}
|
body = f"""## EpicNext-CMS {version}
|
||||||
|
|
||||||
### Changes
|
### Changes
|
||||||
{notes_raw}
|
{notes}
|
||||||
|
|
||||||
---
|
---
|
||||||
*Automated release from Gitea Actions*
|
*Automated release from Gitea Actions*
|
||||||
@@ -100,8 +83,6 @@ payload = json.dumps({
|
|||||||
"prerelease": False,
|
"prerelease": False,
|
||||||
}).encode("utf-8")
|
}).encode("utf-8")
|
||||||
|
|
||||||
import urllib.request, urllib.error
|
|
||||||
|
|
||||||
def api_call(method, path, data=None):
|
def api_call(method, path, data=None):
|
||||||
url = f"{api}/repos/{repo}/{path}"
|
url = f"{api}/repos/{repo}/{path}"
|
||||||
print(f"{method} {url}")
|
print(f"{method} {url}")
|
||||||
@@ -118,10 +99,10 @@ def api_call(method, path, data=None):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
result = api_call("POST", "releases", payload)
|
result = api_call("POST", "releases", payload)
|
||||||
print(f"Created: {result.get('html_url', result.get('id', '?'))}")
|
print(f"OK: {result.get('html_url', result.get('id', '?'))}")
|
||||||
except urllib.error.HTTPError as e:
|
except urllib.error.HTTPError as e:
|
||||||
err = e.read().decode("utf-8")
|
err_body = e.read().decode("utf-8")
|
||||||
print(f"POST {e.code}: {err}")
|
print(f"POST {e.code}")
|
||||||
if e.code == 409:
|
if e.code == 409:
|
||||||
releases = api_call("GET", "releases")
|
releases = api_call("GET", "releases")
|
||||||
for rel in releases:
|
for rel in releases:
|
||||||
@@ -129,11 +110,7 @@ except urllib.error.HTTPError as e:
|
|||||||
result = api_call("PATCH", f"releases/{rel['id']}", payload)
|
result = api_call("PATCH", f"releases/{rel['id']}", payload)
|
||||||
print(f"Updated: {result.get('html_url', result.get('id', '?'))}")
|
print(f"Updated: {result.get('html_url', result.get('id', '?'))}")
|
||||||
break
|
break
|
||||||
else:
|
|
||||||
raise
|
|
||||||
else:
|
else:
|
||||||
|
print(f"API ERROR: {err_body}")
|
||||||
raise
|
raise
|
||||||
PYEOF
|
PYEOF
|
||||||
|
|
||||||
debug "=== RELEASE WORKFLOW END ==="
|
|
||||||
echo "Debug log: $DEBUG"
|
|
||||||
Reference in new issue
Block a user