Refactor statistics page and enhance logging
- Updated the layout and styling of the statistics page for better responsiveness and visual appeal. - Introduced a new error page for 404 errors with user-friendly messaging and navigation options. - Enhanced logging functionality to capture detailed events related to asset uploads, deletions, and HTTP requests. - Implemented an AssetTracker to manage assets in memory, allowing for efficient tracking and retrieval. - Improved the API for uploading and retrieving assets, ensuring better error handling and response formatting. - Added auto-refresh functionality to the statistics page to keep data up-to-date.
This commit is contained in:
@@ -2,83 +2,11 @@ name: Build & Publish
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ["main"]
|
||||
paths:
|
||||
- "CHANGELOG.md"
|
||||
tags: ["v*"]
|
||||
workflow_dispatch: {}
|
||||
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
should_build: ${{ steps.version_check.outputs.should_build }}
|
||||
version: ${{ steps.version_check.outputs.version }}
|
||||
pkg_version: ${{ steps.version_check.outputs.pkg_version }}
|
||||
short_sha: ${{ steps.version_check.outputs.short_sha }}
|
||||
owner: ${{ steps.meta.outputs.owner }}
|
||||
repo: ${{ steps.meta.outputs.repo }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 2
|
||||
|
||||
- name: Repo meta (owner/repo)
|
||||
id: meta
|
||||
shell: bash
|
||||
run: |
|
||||
set -e
|
||||
# Gitea Actions is GitHub-compatible; this usually exists.
|
||||
FULL="${GITHUB_REPOSITORY:-}"
|
||||
if [ -z "$FULL" ]; then
|
||||
echo "GITHUB_REPOSITORY is empty. Set it in runner env or switch to explicit OWNER/REPO vars."
|
||||
exit 1
|
||||
fi
|
||||
OWNER="${FULL%%/*}"
|
||||
REPO="${FULL##*/}"
|
||||
echo "owner=$OWNER" >> "$GITHUB_OUTPUT"
|
||||
echo "repo=$REPO" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Check version change in CHANGELOG
|
||||
id: version_check
|
||||
shell: bash
|
||||
run: |
|
||||
set -e
|
||||
|
||||
OLD=$(git show HEAD~1:CHANGELOG.md | grep '^## \[' | head -1 || true)
|
||||
NEW=$(grep '^## \[' CHANGELOG.md | head -1 || true)
|
||||
|
||||
echo "Old: $OLD"
|
||||
echo "New: $NEW"
|
||||
|
||||
# Extract x.y.z from: ## [x.y.z] - YYYY-MM-DD
|
||||
VERSION=$(echo "$NEW" | sed -n 's/^## \[\([0-9]\+\.[0-9]\+\.[0-9]\+\)\].*$/\1/p')
|
||||
|
||||
if [ -z "$VERSION" ]; then
|
||||
echo "Could not parse version from CHANGELOG.md (expected: ## [x.y.z] - YYYY-MM-DD)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SHORT_SHA="$(git rev-parse --short=7 HEAD)"
|
||||
PKG_VERSION="${VERSION}+g${SHORT_SHA}"
|
||||
|
||||
echo "Parsed VERSION=$VERSION"
|
||||
echo "SHORT_SHA=$SHORT_SHA"
|
||||
echo "PKG_VERSION=$PKG_VERSION"
|
||||
|
||||
if [ "$OLD" = "$NEW" ]; then
|
||||
echo "should_build=false" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "should_build=true" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
||||
echo "short_sha=$SHORT_SHA" >> "$GITHUB_OUTPUT"
|
||||
echo "pkg_version=$PKG_VERSION" >> "$GITHUB_OUTPUT"
|
||||
|
||||
build_publish:
|
||||
needs: check
|
||||
if: needs.check.outputs.should_build == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: archlinux:latest
|
||||
@@ -93,13 +21,31 @@ jobs:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Read package name
|
||||
id: pkg_meta
|
||||
shell: bash
|
||||
run: |
|
||||
set -e
|
||||
PKG_NAME="$(sed -n 's/^name = \"\\(.*\\)\"/\\1/p' Cargo.toml | head -n 1)"
|
||||
if [ -z "$PKG_NAME" ]; then
|
||||
echo "Could not read package name from Cargo.toml"
|
||||
exit 1
|
||||
fi
|
||||
echo "pkg_name=$PKG_NAME" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Create source tarball (code)
|
||||
shell: bash
|
||||
run: |
|
||||
set -e
|
||||
OWNER="${{ needs.check.outputs.owner }}"
|
||||
REPO="${{ needs.check.outputs.repo }}"
|
||||
PKG_VERSION="${{ needs.check.outputs.pkg_version }}"
|
||||
FULL="${GITHUB_REPOSITORY:-}"
|
||||
if [ -z "$FULL" ]; then
|
||||
echo "GITHUB_REPOSITORY is empty. Set it in runner env or switch to explicit OWNER/REPO vars."
|
||||
exit 1
|
||||
fi
|
||||
OWNER="${FULL%%/*}"
|
||||
REPO="${FULL##*/}"
|
||||
VERSION="${GITHUB_REF_NAME#v}"
|
||||
PKG_VERSION="${VERSION}"
|
||||
|
||||
mkdir -p dist
|
||||
# Clean source snapshot of the repository at current commit
|
||||
@@ -121,11 +67,18 @@ jobs:
|
||||
shell: bash
|
||||
run: |
|
||||
set -e
|
||||
REPO="${{ needs.check.outputs.repo }}"
|
||||
PKG_VERSION="${{ needs.check.outputs.pkg_version }}"
|
||||
FULL="${GITHUB_REPOSITORY:-}"
|
||||
if [ -z "$FULL" ]; then
|
||||
echo "GITHUB_REPOSITORY is empty. Set it in runner env or switch to explicit OWNER/REPO vars."
|
||||
exit 1
|
||||
fi
|
||||
REPO="${FULL##*/}"
|
||||
VERSION="${GITHUB_REF_NAME#v}"
|
||||
PKG_VERSION="${VERSION}"
|
||||
BIN_NAME="${{ steps.pkg_meta.outputs.pkg_name }}"
|
||||
|
||||
mkdir -p dist
|
||||
cp "target/release/${REPO}" "dist/${REPO}-${PKG_VERSION}-linux-x86_64"
|
||||
cp "target/release/${BIN_NAME}" "dist/${REPO}-${PKG_VERSION}-linux-x86_64"
|
||||
|
||||
chmod +x "dist/${REPO}-${PKG_VERSION}-linux-x86_64"
|
||||
ls -lh dist
|
||||
@@ -137,9 +90,15 @@ jobs:
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
run: |
|
||||
set -e
|
||||
OWNER="${{ needs.check.outputs.owner }}"
|
||||
REPO="${{ needs.check.outputs.repo }}"
|
||||
PKG_VERSION="${{ needs.check.outputs.pkg_version }}"
|
||||
FULL="${GITHUB_REPOSITORY:-}"
|
||||
if [ -z "$FULL" ]; then
|
||||
echo "GITHUB_REPOSITORY is empty. Set it in runner env or switch to explicit OWNER/REPO vars."
|
||||
exit 1
|
||||
fi
|
||||
OWNER="${FULL%%/*}"
|
||||
REPO="${FULL##*/}"
|
||||
VERSION="${GITHUB_REF_NAME#v}"
|
||||
PKG_VERSION="${VERSION}"
|
||||
|
||||
if [ -z "${GITEA_BASE_URL:-}" ]; then
|
||||
echo "Missing vars.GITEA_BASE_URL (example: https://gitea.example.com)"
|
||||
|
||||
Reference in New Issue
Block a user