Prune dist cache before early exit and fix source logging

This commit is contained in:
2026-04-27 00:45:01 +02:00
parent b0e7f4a816
commit 1a64595ed2
2 changed files with 23 additions and 19 deletions
+19 -19
View File
@@ -5,33 +5,29 @@ set -e # Exit on error
# latest published GitHub release. The dl.gitea.com version JSON can lag
# behind actual releases, so it is only used as a fallback.
resolve_version() {
local version=""
if [[ -n "${1:-}" ]]; then
VERSION_SOURCE="command line argument"
echo "$1"
VERSION="$1"
return 0
fi
if [[ -n "${GITEA_VERSION:-}" ]]; then
VERSION_SOURCE="GITEA_VERSION environment variable"
echo "${GITEA_VERSION}"
VERSION="${GITEA_VERSION}"
return 0
fi
if version=$(curl -fsSL https://api.github.com/repos/go-gitea/gitea/releases/latest 2>/dev/null | jq -r '.tag_name // empty' 2>/dev/null); then
version="${version#v}"
if [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
if VERSION=$(curl -fsSL https://api.github.com/repos/go-gitea/gitea/releases/latest 2>/dev/null | jq -r '.tag_name // empty' 2>/dev/null); then
VERSION="${VERSION#v}"
if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
VERSION_SOURCE="GitHub releases API"
echo "$version"
return 0
fi
fi
if version=$(curl -fsSL https://dl.gitea.com/gitea/version.json 2>/dev/null | jq -r '.latest.version // empty' 2>/dev/null); then
if [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
if VERSION=$(curl -fsSL https://dl.gitea.com/gitea/version.json 2>/dev/null | jq -r '.latest.version // empty' 2>/dev/null); then
if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
VERSION_SOURCE="dl.gitea.com version.json fallback"
echo "$version"
return 0
fi
fi
@@ -40,18 +36,13 @@ resolve_version() {
exit 1
}
VERSION=$(resolve_version "${1:-}")
resolve_version "${1:-}"
DOWNLOAD_BASE_URL="${GITEA_DOWNLOAD_BASE_URL:-https://github.com/go-gitea/gitea/releases/download/v${VERSION}}"
BUILD_ROOT="build/${VERSION}"
DIST_ROOT="dist"
echo "Current version: ${VERSION}"
echo "Version source: ${VERSION_SOURCE}"
# Check if this version is already built
if [[ -f "../gitea-deb/gitea_${VERSION}_amd64.deb" ]] && [[ -f "../gitea-deb/gitea_${VERSION}_arm64.deb" ]]; then
echo "✅ Version ${VERSION} already built and present in release repo. Aborting."
exit 0
fi
ARCHS=("amd64" "arm64")
FILES=("xz" "xz.asc" "xz.sha256" "xz.sha256.asc")
@@ -66,11 +57,20 @@ prune_dist_cache() {
find "${dist_dir}" -maxdepth 1 -type f -name 'gitea-*' ! -name "${keep_prefix}*" -print -delete
}
for ARCH in "${ARCHS[@]}"; do
echo "Pruning old cache entries in ${DIST_ROOT}/${ARCH}"
prune_dist_cache "${ARCH}"
done
# Check if this version is already built
if [[ -f "../gitea-deb/gitea_${VERSION}_amd64.deb" ]] && [[ -f "../gitea-deb/gitea_${VERSION}_arm64.deb" ]]; then
echo "✅ Version ${VERSION} already built and present in release repo. Aborting."
exit 0
fi
# Download Gitea Binaries and Signatures
for ARCH in "${ARCHS[@]}"; do
echo "Downloading Gitea ${VERSION} for ${ARCH}"
echo "Pruning old cache entries in ${DIST_ROOT}/${ARCH}"
prune_dist_cache "${ARCH}"
for FILE in "${FILES[@]}"; do
FILE_NAME="gitea-${VERSION}-linux-${ARCH}.${FILE}"
FILE_URL="${DOWNLOAD_BASE_URL}/${FILE_NAME}"