ci: build and push static download site Docker image on master
Asteria Qt CI / rebuild-images (linux-arm64) (push) Skipped
Asteria Qt CI / rebuild-images (linux-x86_64) (push) Skipped
Asteria Qt CI / rebuild-images (windows-arm64) (push) Skipped
Asteria Qt CI / rebuild-images (windows-x86_64) (push) Skipped
Asteria Qt CI / build-macos (push) Successful in 10s
Asteria Qt CI / test-macos (push) Successful in 39s
Asteria Qt CI / rebuild-images (linux-arm64) (pull_request) Skipped
Asteria Qt CI / rebuild-images (linux-x86_64) (pull_request) Skipped
Asteria Qt CI / rebuild-images (windows-arm64) (pull_request) Skipped
Asteria Qt CI / rebuild-images (windows-x86_64) (pull_request) Skipped
Asteria Qt CI / build-linux (push) Successful in 1m12s
Asteria Qt CI / build-linux (pull_request) Canceled after 0s
Asteria Qt CI / build-linux-arm64 (pull_request) Canceled after 0s
Asteria Qt CI / build-windows (pull_request) Canceled after 0s
Asteria Qt CI / build-windows-arm64 (pull_request) Canceled after 0s
Asteria Qt CI / build-macos (pull_request) Canceled after 0s
Asteria Qt CI / test-linux (pull_request) Canceled after 0s
Asteria Qt CI / test-macos (pull_request) Canceled after 0s
Asteria Qt CI / package-linux (pull_request) Canceled after 0s
Asteria Qt CI / package-linux-arm64 (pull_request) Canceled after 0s
Asteria Qt CI / package-windows (pull_request) Canceled after 0s
Asteria Qt CI / package-windows-arm64 (pull_request) Canceled after 0s
Asteria Qt CI / package-macos (pull_request) Canceled after 0s
Asteria Qt CI / release (pull_request) Canceled after 0s
Asteria Qt CI / build-site-image (pull_request) Canceled after 0s
Asteria Qt CI / package-windows (push) Successful in 23s
Asteria Qt CI / build-windows-arm64 (push) Successful in 1m29s
Asteria Qt CI / build-windows (push) Successful in 1m29s
Asteria Qt CI / build-linux-arm64 (push) Successful in 1m31s
Asteria Qt CI / package-windows-arm64 (push) Successful in 19s
Asteria Qt CI / package-macos (push) Successful in 56s
Asteria Qt CI / test-linux (push) Successful in 3m20s
Asteria Qt CI / package-linux-arm64 (push) Successful in 17s
Asteria Qt CI / package-linux (push) Successful in 17s
Asteria Qt CI / release (push) Skipped
Asteria Qt CI / build-site-image (push) Skipped

Instead of linking to ephemeral CI artifacts on a wiki, package each
master release's built binaries into a self-contained Nginx static site
container (`gitea.agel.dev/asteria/site:latest` and `:<version>`) via a
new `build-site-image` job in Gitea Actions.

Because the unprivileged `kaniko-builder` runner has no Node.js runtime
for artifact actions, the multi-stage `Dockerfile.site` fetches the
just-published `v<version>` release assets (permission-preserving Linux
`.AppImage.tar.gz` archives, Windows portable `.zip` packages, and
optional macOS `.dmg`) from the Gitea Release API inside a throwaway
Python builder stage and strips the temporary token file before copying
the static output into `nginx:1.27-alpine`.

HTML, CSS, and JS are kept as standalone static files under `site/`
with `{{PLACEHOLDER}}` tokens substituted by `generate-static-site.py`
alongside generated `manifest.json` and `downloads/SHA256SUMS`, allowing
the page layout and styling to be edited independently of the build
script.
This commit is contained in:
Agel committed 2026-11-23 20:10:35 +01:00
1 parent 9f82561098
commit 92f773aa8f
11 files changed
+953 -3

No files matched your search

+69
View File
@@ -388,3 +388,72 @@ jobs:
run: |
chmod +x scripts/bump-version.sh
./scripts/bump-version.sh --assets-dir dist
# ── Build and push static website Docker image with release binaries (master only) ──
build-site-image:
if: ${{ success() && (github.ref == 'refs/heads/master' || github.ref_name == 'master') && (github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && !inputs.rebuild_images)) }}
needs:
- release
runs-on: kaniko-builder
steps:
- name: Build and push static site image via Kaniko
shell: sh
env:
BUILD_TOKEN: ${{ secrets.BUILD_TOKEN }}
REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
REGISTRY: gitea.agel.dev
IMAGE_PREFIX: gitea.agel.dev/asteria
run: |
set -eu
export PATH="/kaniko:/busybox:/usr/local/bin"
cleanup() {
/busybox/mkdir -p /bin
/busybox/ln -sf /busybox/sh /bin/sh
rm -rf /kaniko/.docker/config.json src src.tar.gz || true
}
trap cleanup EXIT
if [ -z "${BUILD_TOKEN}" ]; then
echo "ERROR: BUILD_TOKEN secret is not set" >&2
exit 1
fi
LOGIN_USER="${REGISTRY_USER:-${GITHUB_ACTOR}}"
AUTH_B64="$(printf '%s:%s' "${LOGIN_USER}" "${BUILD_TOKEN}" | /busybox/base64 | /busybox/tr -d '\n\r')"
/busybox/mkdir -p /kaniko/.docker
printf '{"auths":{"%s":{"auth":"%s"}}}\n' "${REGISTRY}" "${AUTH_B64}" > /kaniko/.docker/config.json
rm -rf src src.tar.gz
/busybox/mkdir -p src
ARCHIVE_URL="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}/archive/${GITHUB_SHA}.tar.gz"
/busybox/wget -q --header="Authorization: token ${BUILD_TOKEN}" "${ARCHIVE_URL}" -O src.tar.gz
/busybox/tar -xzf src.tar.gz -C src --strip-components=1
rm -f src.tar.gz
BUILT_VERSION="$(/busybox/tr -d '[:space:]' < src/VERSION)"
SHORT_SHA="$(printf '%.7s' "${GITHUB_SHA}")"
SERVER_URL="${GITHUB_SERVER_URL%/}"
REPO_URL="${SERVER_URL}/${GITHUB_REPOSITORY}"
RUN_URL="${REPO_URL}/actions/runs/${GITHUB_RUN_ID:-0}"
/busybox/mkdir -p src/site-input
printf '%s' "${BUILD_TOKEN}" > src/site-input/.gitea_token
/kaniko/executor \
--dockerfile=src/docker/Dockerfile.site \
--context=src \
--build-arg="ASTERIA_VERSION=${BUILT_VERSION}" \
--build-arg="CI_COMMIT_SHORT_SHA=${SHORT_SHA}" \
--build-arg="CI_COMMIT_REF_NAME=${GITHUB_REF_NAME:-master}" \
--build-arg="CI_RUN_ID=${GITHUB_RUN_ID:-0}" \
--build-arg="CI_RUN_URL=${RUN_URL}" \
--build-arg="CI_REPO_URL=${REPO_URL}" \
--build-arg="GITEA_API_URL=${SERVER_URL}/api/v1" \
--build-arg="GITEA_REPO=${GITHUB_REPOSITORY}" \
--destination="${IMAGE_PREFIX}/site:latest" \
--destination="${IMAGE_PREFIX}/site:${BUILT_VERSION}" \
--cleanup \
--ignore-path=/kaniko \
--ignore-path=/busybox \
--ignore-path=/data \
--ignore-path=/builds
+4 -2
View File
@@ -128,8 +128,9 @@ The CI environment is split into 4 build targets on `ubuntu:24.04` sharing a com
| `gitea.agel.dev/asteria/build-linux-arm64:latest` | `linux-arm64` (`Dockerfile.build`) | `linux-arm64:host` | `build-linux-arm64`, `package-linux-arm64` |
| `gitea.agel.dev/asteria/build-windows-x86_64:latest` | `windows-x86_64` (`Dockerfile.build`) | `windows-x86_64:host` | `build-windows`, `package-windows` |
| `gitea.agel.dev/asteria/build-windows-arm64:latest` | `windows-arm64` (`Dockerfile.build`) | `windows-arm64:host` | `build-windows-arm64`, `package-windows-arm64` |
| `gitea.agel.dev/asteria/build-kaniko:latest` | `Dockerfile.kaniko` | `kaniko-builder:host` | `rebuild-images` (`workflow_dispatch`, unprivileged) |
Each container runs `docker/entrypoint.sh` (or `docker/kaniko-entrypoint.sh`), which auto-registers with Gitea (`GITEA_INSTANCE_URL`, `GITEA_RUNNER_REGISTRATION_TOKEN`, `GITEA_RUNNER_NAME`, `GITEA_RUNNER_LABELS`) on first boot when `/data/.runner` is absent, generates `/data/config.yaml`, and starts `act_runner daemon`. In `.gitea/workflows/ci.yml`, `workflow_dispatch` (`rebuild_images=true`) runs on `kaniko-builder` to rebuild and push all 4 `Dockerfile.build` images to `gitea.agel.dev/asteria` using `BUILD_TOKEN` with zero extra capabilities, zero `security_opt`, and no Docker socket.
| `gitea.agel.dev/asteria/build-kaniko:latest` | `Dockerfile.kaniko` | `kaniko-builder:host` | `rebuild-images` (`workflow_dispatch`, unprivileged), `build-site-image` (`master` only) |
| `gitea.agel.dev/asteria/site:latest` | `Dockerfile.site` | — (served runtime) | Static Nginx download website bundling built release binaries (`:latest` & `:<version>`) |
Each container runs `docker/entrypoint.sh` (or `docker/kaniko-entrypoint.sh`), which auto-registers with Gitea (`GITEA_INSTANCE_URL`, `GITEA_RUNNER_REGISTRATION_TOKEN`, `GITEA_RUNNER_NAME`, `GITEA_RUNNER_LABELS`) on first boot when `/data/.runner` is absent, generates `/data/config.yaml`, and starts `act_runner daemon`. In `.gitea/workflows/ci.yml`, `workflow_dispatch` (`rebuild_images=true`) runs on `kaniko-builder` to rebuild and push all 4 `Dockerfile.build` images to `gitea.agel.dev/asteria` using `BUILD_TOKEN` with zero extra capabilities, zero `security_opt`, and no Docker socket. After `release` on `master`, `build-site-image` also runs on `kaniko-builder` using `docker/Dockerfile.site` and `scripts/generate-static-site.py` to build and push `gitea.agel.dev/asteria/site:latest` and `:${ASTERIA_VERSION}`.
### macOS Build Environment
```bash
@@ -167,6 +168,7 @@ scripts/start-runner-macos.sh
1. Creates release tag `vX.Y.Z` and a Gitea Release at `GITHUB_SHA` via `/api/v1/repos/Asteria/asteria-qt/releases` (if absent).
2. Uploads packaged binaries (`Asteria-x86_64.AppImage.tar.gz`, `Asteria-arm64.AppImage.tar.gz`, `asteria-qt-windows-x86_64.zip`, `asteria-qt-windows-arm64.zip`, and `Asteria.dmg` when the optional `macos-qt` runner is active) as release assets.
3. Increments `PATCH` in `VERSION` (`X.Y.(Z+1)`), committing `chore: bump version to ... [skip ci]` on `master` via the Gitea Contents API (`PUT /api/v1/repos/Asteria/asteria-qt/contents/VERSION`). Tag pushes do not trigger `push` branch workflows.
- Following `release`, `build-site-image` runs on `kaniko-builder` (using `docker/Dockerfile.site`, `docker/nginx.conf`, `site/` static templates, and `scripts/generate-static-site.py`) to fetch the `vX.Y.Z` release assets, render the static download portal (`index.html`, `styles.css`, `app.js`, `manifest.json`, `downloads/SHA256SUMS`), and push `gitea.agel.dev/asteria/site:latest` and `gitea.agel.dev/asteria/site:X.Y.Z`.
### VS Code & CMake Presets
Pre-configured tasks, launch configurations, and CMake presets are available:
+1 -1
View File
@@ -1,6 +1,6 @@
# Multi-stage CI runner images for asteria-qt (all sharing the `base` layer).
# Targets:
# - linux-x86_64 : Native Linux x86_64 build, CTest, AppImage packaging, and wiki jobs
# - linux-x86_64 : Native Linux x86_64 build, CTest, AppImage packaging, and release jobs
# - linux-arm64 : Cross-compiled Linux ARM64 build and AppImage packaging
# - windows-x86_64 : Cross-compiled Windows x86_64 build and portable zip packaging
# - windows-arm64 : Cross-compiled Windows ARM64 build and portable zip packaging
+43
View File
@@ -0,0 +1,43 @@
# Multi-stage static website image serving built Asteria Qt release binaries.
# Target image: gitea.agel.dev/asteria/site:latest (and :<version>)
FROM python:3.12-alpine AS builder
ARG ASTERIA_VERSION=0.0.0
ARG CI_COMMIT_SHORT_SHA=unknown
ARG CI_COMMIT_REF_NAME=master
ARG CI_RUN_ID=0
ARG CI_RUN_URL=""
ARG CI_REPO_URL="https://gitea.agel.dev/Asteria/asteria-qt"
ARG GITEA_API_URL=""
ARG GITEA_REPO=""
WORKDIR /build
COPY scripts/generate-static-site.py /build/generate-static-site.py
COPY site/ /build/site/
COPY packaging/icons/128x128/asteria-qt.png /build/logo.png
COPY site-input/ /build/input/
RUN python3 /build/generate-static-site.py \
--input-dir /build/input \
--output-dir /site \
--template-dir /build/site \
--version "${ASTERIA_VERSION}" \
--commit-sha "${CI_COMMIT_SHORT_SHA}" \
--commit-branch "${CI_COMMIT_REF_NAME}" \
--run-id "${CI_RUN_ID}" \
--run-url "${CI_RUN_URL}" \
--repo-url "${CI_REPO_URL}" \
--gitea-api-url "${GITEA_API_URL}" \
--gitea-repo "${GITEA_REPO}" \
--gitea-token-file /build/input/.gitea_token \
--icon /build/logo.png \
--require-core && \
rm -f /build/input/.gitea_token
FROM nginx:1.27-alpine
COPY docker/nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=builder /site/ /usr/share/nginx/html/
EXPOSE 80
+37
View File
@@ -0,0 +1,37 @@
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
sendfile on;
tcp_nopush on;
gzip on;
gzip_vary on;
gzip_min_length 256;
gzip_types text/plain text/css application/json application/javascript text/html;
location = /healthz {
access_log off;
default_type text/plain;
return 200 "ok\n";
}
location /downloads/ {
add_header Content-Disposition "attachment";
add_header X-Content-Type-Options "nosniff";
expires 1h;
try_files $uri =404;
}
location = /manifest.json {
add_header Cache-Control "no-cache";
try_files $uri =404;
}
location / {
try_files $uri $uri/ =404;
}
}
+449
View File
@@ -0,0 +1,449 @@
#!/usr/bin/env python3
"""Generate the static download website for Asteria Qt releases.
Stages built platform packages under <output-dir>/downloads/, optionally
fetching missing assets from a Gitea Release, copies static resources from
--template-dir (default: <repo>/site), substitutes {{PLACEHOLDER}} tokens in
HTML templates, and writes manifest.json and downloads/SHA256SUMS.
"""
from __future__ import annotations
import argparse
import hashlib
import html
import json
import os
import shutil
import sys
import tarfile
import urllib.error
import urllib.request
import zipfile
from dataclasses import dataclass
from datetime import datetime, timezone
from pathlib import Path
from typing import Optional
@dataclass(frozen=True)
class ArtifactSpec:
id: str
platform: str
arch: str
label: str
archive_name: str
raw_names: tuple[str, ...]
required: bool
format_badge: str
install_hint: str
ARTIFACT_SPECS: tuple[ArtifactSpec, ...] = (
ArtifactSpec(
id="linux-x86_64",
platform="Linux",
arch="x86_64",
label="Linux (x86_64)",
archive_name="Asteria-x86_64.AppImage.tar.gz",
raw_names=("Asteria-x86_64.AppImage",),
required=True,
format_badge="AppImage (.tar.gz)",
install_hint="tar -xzf Asteria-x86_64.AppImage.tar.gz && ./Asteria-x86_64.AppImage",
),
ArtifactSpec(
id="linux-arm64",
platform="Linux",
arch="ARM64",
label="Linux (ARM64)",
archive_name="Asteria-arm64.AppImage.tar.gz",
raw_names=("Asteria-arm64.AppImage",),
required=True,
format_badge="AppImage (.tar.gz)",
install_hint="tar -xzf Asteria-arm64.AppImage.tar.gz && ./Asteria-arm64.AppImage",
),
ArtifactSpec(
id="windows-x86_64",
platform="Windows",
arch="x86_64",
label="Windows (x86_64)",
archive_name="asteria-qt-windows-x86_64.zip",
raw_names=("asteria-qt-windows",),
required=True,
format_badge="Portable ZIP",
install_hint="Extract archive and run asteria-qt.exe",
),
ArtifactSpec(
id="windows-arm64",
platform="Windows",
arch="ARM64",
label="Windows (ARM64)",
archive_name="asteria-qt-windows-arm64.zip",
raw_names=("asteria-qt-windows-arm64",),
required=True,
format_badge="Portable ZIP",
install_hint="Extract archive and run asteria-qt.exe",
),
ArtifactSpec(
id="macos",
platform="macOS",
arch="Universal / Apple Silicon",
label="macOS",
archive_name="Asteria.dmg",
raw_names=(),
required=False,
format_badge="Disk Image (.dmg)",
install_hint="Open Asteria.dmg and drag Asteria to Applications",
),
)
TEMPLATE_PARTIALS = {"card.html", "card-unavailable.html"}
def format_size(num_bytes: int) -> str:
size = float(num_bytes)
for unit in ("B", "KiB", "MiB", "GiB"):
if size < 1024.0 or unit == "GiB":
if unit == "B":
return f"{int(size)} B"
return f"{size:.1f} {unit}"
size /= 1024.0
return f"{num_bytes} B"
def sha256_file(path: Path) -> str:
digest = hashlib.sha256()
with path.open("rb") as fh:
for chunk in iter(lambda: fh.read(1024 * 1024), b""):
digest.update(chunk)
return digest.hexdigest()
def zip_directory(src_dir: Path, dest_zip: Path) -> None:
root_name = src_dir.name
with zipfile.ZipFile(dest_zip, "w", compression=zipfile.ZIP_DEFLATED, compresslevel=9) as zf:
for item in sorted(src_dir.rglob("*")):
if item.is_file():
arcname = Path(root_name) / item.relative_to(src_dir)
zf.write(item, arcname.as_posix())
def targz_appimage(src_file: Path, dest_targz: Path) -> None:
with tarfile.open(dest_targz, "w:gz") as tf:
info = tf.gettarinfo(str(src_file), arcname=src_file.name)
info.mode = 0o755
with src_file.open("rb") as fh:
tf.addfile(info, fh)
def read_token(token_file: Optional[Path]) -> str:
env_token = os.environ.get("BUILD_TOKEN") or os.environ.get("GITEA_TOKEN") or ""
if env_token.strip():
return env_token.strip()
if token_file and token_file.is_file():
return token_file.read_text(encoding="utf-8").strip()
return ""
def fetch_missing_from_gitea(
input_dir: Path,
api_url: str,
repo: str,
version: str,
token: str,
) -> None:
needed = {
spec.archive_name
for spec in ARTIFACT_SPECS
if not (input_dir / spec.archive_name).is_file()
and not any((input_dir / raw).exists() for raw in spec.raw_names)
}
if not needed:
return
tag = version if version.startswith("v") else f"v{version}"
release_url = f"{api_url.rstrip('/')}/repos/{repo}/releases/tags/{tag}"
headers = {"Accept": "application/json"}
if token:
headers["Authorization"] = f"token {token}"
req = urllib.request.Request(release_url, headers=headers)
try:
with urllib.request.urlopen(req, timeout=30) as resp:
release_data = json.loads(resp.read().decode("utf-8"))
except urllib.error.HTTPError as exc:
raise RuntimeError(
f"Failed to query Gitea release {tag} at {release_url}: HTTP {exc.code}"
) from exc
except urllib.error.URLError as exc:
raise RuntimeError(
f"Failed to connect to Gitea release API {release_url}: {exc.reason}"
) from exc
assets_by_name = {
asset.get("name"): asset
for asset in release_data.get("assets", [])
if asset.get("name")
}
for name in sorted(needed):
asset = assets_by_name.get(name)
if not asset:
continue
dl_url = asset.get("browser_download_url")
if not dl_url:
continue
dest = input_dir / name
dl_headers = {"Accept": "application/octet-stream"}
if token:
dl_headers["Authorization"] = f"token {token}"
dl_req = urllib.request.Request(dl_url, headers=dl_headers)
print(f"Downloading {name} from {dl_url}...")
with urllib.request.urlopen(dl_req, timeout=300) as resp, dest.open("wb") as out_fh:
shutil.copyfileobj(resp, out_fh, length=1024 * 1024)
def stage_artifact(spec: ArtifactSpec, input_dir: Path, downloads_dir: Path) -> Optional[dict]:
dest_path = downloads_dir / spec.archive_name
direct_src = input_dir / spec.archive_name
if direct_src.is_file():
shutil.copy2(direct_src, dest_path)
else:
staged = False
for raw_name in spec.raw_names:
raw_path = input_dir / raw_name
if raw_path.is_dir() and spec.archive_name.endswith(".zip"):
zip_directory(raw_path, dest_path)
staged = True
break
if raw_path.is_file() and spec.archive_name.endswith(".tar.gz"):
targz_appimage(raw_path, dest_path)
staged = True
break
if not staged:
return None
size_bytes = dest_path.stat().st_size
checksum = sha256_file(dest_path)
return {
"id": spec.id,
"platform": spec.platform,
"arch": spec.arch,
"label": spec.label,
"filename": spec.archive_name,
"url": f"downloads/{spec.archive_name}",
"format": spec.format_badge,
"install_hint": spec.install_hint,
"size_bytes": size_bytes,
"size_human": format_size(size_bytes),
"sha256": checksum,
"available": True,
}
def apply_placeholders(template: str, replacements: dict[str, str]) -> str:
rendered = template
for key, value in replacements.items():
rendered = rendered.replace(f"{{{{{key}}}}}", value)
return rendered
def copy_static_resources(template_dir: Path, output_dir: Path) -> None:
for item in template_dir.iterdir():
if item.name in TEMPLATE_PARTIALS or item.name == "index.html":
continue
dest = output_dir / item.name
if item.is_dir():
shutil.copytree(item, dest, dirs_exist_ok=True)
elif item.is_file():
shutil.copy2(item, dest)
def render_site_html(template_dir: Path, manifest: dict) -> str:
index_tpl = (template_dir / "index.html").read_text(encoding="utf-8")
card_tpl = (template_dir / "card.html").read_text(encoding="utf-8")
card_unavail_tpl = (template_dir / "card-unavailable.html").read_text(encoding="utf-8")
cards: list[str] = []
for item in manifest["artifacts"]:
if item["available"]:
cards.append(
apply_placeholders(
card_tpl,
{
"LABEL": html.escape(item["label"]),
"FORMAT": html.escape(item["format"]),
"SIZE": html.escape(item["size_human"]),
"INSTALL_HINT": html.escape(item["install_hint"]),
"URL": html.escape(item["url"]),
"FILENAME": html.escape(item["filename"]),
"SHA256": html.escape(item["sha256"]),
},
).rstrip("\n")
)
else:
cards.append(
apply_placeholders(
card_unavail_tpl,
{
"LABEL": html.escape(item["label"]),
"FORMAT": html.escape(item["format"]),
},
).rstrip("\n")
)
version = manifest["version"]
repo_url = manifest["repo_url"]
release_url = f"{repo_url.rstrip('/')}/releases/tag/v{version}"
run_url = manifest["run_url"] or release_url
return apply_placeholders(
index_tpl,
{
"VERSION": html.escape(version),
"BRANCH": html.escape(manifest["commit_branch"]),
"COMMIT_SHA": html.escape(manifest["commit_sha"]),
"BUILT_AT": html.escape(manifest["built_at"]),
"RUN_ID": html.escape(str(manifest["run_id"])),
"RUN_URL": html.escape(run_url),
"RELEASE_URL": html.escape(release_url),
"REPO_URL": html.escape(repo_url),
"PLATFORM_CARDS": "\n".join(cards),
},
)
def parse_args() -> argparse.Namespace:
default_root = Path(__file__).resolve().parent.parent
parser = argparse.ArgumentParser(description="Generate Asteria Qt static download website.")
parser.add_argument("--input-dir", required=True, type=Path, help="Directory containing built packages.")
parser.add_argument("--output-dir", required=True, type=Path, help="Output static site root directory.")
parser.add_argument(
"--template-dir",
type=Path,
default=default_root / "site",
help="Directory containing static HTML/CSS/JS templates (default: <repo>/site).",
)
parser.add_argument("--version", required=True, help="Asteria version string (e.g. 0.1.4).")
parser.add_argument("--commit-sha", default="unknown", help="Short commit SHA.")
parser.add_argument("--commit-branch", default="master", help="Git branch name.")
parser.add_argument("--run-id", default="0", help="CI workflow run ID.")
parser.add_argument("--run-url", default="", help="CI workflow run URL.")
parser.add_argument("--repo-url", default="https://gitea.agel.dev/Asteria/asteria-qt", help="Repository web URL.")
parser.add_argument(
"--icon",
type=Path,
default=default_root / "packaging" / "icons" / "128x128" / "asteria-qt.png",
help="PNG logo/favicon path copied to assets/logo.png.",
)
parser.add_argument("--gitea-api-url", default="", help="Optional Gitea API base URL for fetching release assets.")
parser.add_argument("--gitea-repo", default="", help="Optional owner/repo slug for Gitea Release API.")
parser.add_argument("--gitea-token-file", type=Path, default=None, help="Optional file containing Gitea API token.")
parser.add_argument("--require-core", action="store_true", help="Fail if any required Linux/Windows artifact is missing.")
return parser.parse_args()
def main() -> int:
args = parse_args()
input_dir: Path = args.input_dir
output_dir: Path = args.output_dir
template_dir: Path = args.template_dir
for required_tpl in ("index.html", *TEMPLATE_PARTIALS):
if not (template_dir / required_tpl).is_file():
print(f"ERROR: Missing static template file: {template_dir / required_tpl}", file=sys.stderr)
return 1
input_dir.mkdir(parents=True, exist_ok=True)
if args.gitea_api_url and args.gitea_repo:
token = read_token(args.gitea_token_file)
fetch_missing_from_gitea(
input_dir=input_dir,
api_url=args.gitea_api_url,
repo=args.gitea_repo,
version=args.version,
token=token,
)
if output_dir.exists():
shutil.rmtree(output_dir)
downloads_dir = output_dir / "downloads"
downloads_dir.mkdir(parents=True, exist_ok=True)
copy_static_resources(template_dir, output_dir)
if args.icon and args.icon.is_file():
assets_dir = output_dir / "assets"
assets_dir.mkdir(parents=True, exist_ok=True)
shutil.copy2(args.icon, assets_dir / "logo.png")
artifacts: list[dict] = []
missing_required: list[str] = []
checksum_lines: list[str] = []
for spec in ARTIFACT_SPECS:
entry = stage_artifact(spec, input_dir, downloads_dir)
if entry is None:
if spec.required:
missing_required.append(spec.archive_name)
artifacts.append(
{
"id": spec.id,
"platform": spec.platform,
"arch": spec.arch,
"label": spec.label,
"filename": spec.archive_name,
"url": None,
"format": spec.format_badge,
"install_hint": spec.install_hint,
"size_bytes": 0,
"size_human": None,
"sha256": None,
"available": False,
}
)
else:
artifacts.append(entry)
checksum_lines.append(f"{entry['sha256']} {entry['filename']}")
if args.require_core and missing_required:
print(
f"ERROR: Missing required core artifacts in {input_dir}: {', '.join(missing_required)}",
file=sys.stderr,
)
return 1
(downloads_dir / "SHA256SUMS").write_text(
("\n".join(checksum_lines) + "\n") if checksum_lines else "",
encoding="utf-8",
)
manifest = {
"name": "Asteria Qt",
"version": args.version,
"commit_sha": args.commit_sha,
"commit_branch": args.commit_branch,
"run_id": args.run_id,
"run_url": args.run_url,
"repo_url": args.repo_url,
"built_at": datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ"),
"artifacts": artifacts,
}
(output_dir / "manifest.json").write_text(
json.dumps(manifest, indent=2) + "\n",
encoding="utf-8",
)
(output_dir / "index.html").write_text(
render_site_html(template_dir, manifest),
encoding="utf-8",
)
available_count = sum(1 for a in artifacts if a["available"])
print(f"Generated static site in {output_dir} for v{args.version} ({available_count}/{len(artifacts)} packages).")
return 0
if __name__ == "__main__":
sys.exit(main())
+15
View File
@@ -0,0 +1,15 @@
document.querySelectorAll('.btn-copy').forEach((btn) => {
btn.addEventListener('click', async () => {
const value = btn.getAttribute('data-copy') || '';
try {
await navigator.clipboard.writeText(value);
const prev = btn.textContent;
btn.textContent = 'Copied';
setTimeout(() => {
btn.textContent = prev;
}, 1500);
} catch (_) {
// Clipboard API may be unavailable in non-HTTPS contexts
}
});
});
+10
View File
@@ -0,0 +1,10 @@
<article class="card card-unavailable">
<div class="card-header">
<div>
<h2>{{LABEL}}</h2>
<span class="badge">{{FORMAT}}</span>
</div>
<span class="size-pill muted">Unavailable</span>
</div>
<p class="hint">No package was produced by the optional runner for this build.</p>
</article>
+20
View File
@@ -0,0 +1,20 @@
<article class="card">
<div class="card-header">
<div>
<h2>{{LABEL}}</h2>
<span class="badge">{{FORMAT}}</span>
</div>
<span class="size-pill">{{SIZE}}</span>
</div>
<p class="hint"><code>{{INSTALL_HINT}}</code></p>
<div class="card-actions">
<a class="btn-download" href="{{URL}}" download="{{FILENAME}}">Download {{FILENAME}}</a>
</div>
<details class="checksum-box">
<summary>SHA-256 checksum</summary>
<div class="checksum-row">
<code>{{SHA256}}</code>
<button type="button" class="btn-copy" data-copy="{{SHA256}}">Copy</button>
</div>
</details>
</article>
+45
View File
@@ -0,0 +1,45 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Asteria Qt v{{VERSION}} — Downloads</title>
<link rel="icon" type="image/png" href="assets/logo.png">
<link rel="stylesheet" href="styles.css">
<script src="app.js" defer></script>
</head>
<body>
<main class="container">
<header class="hero">
<div class="brand">
<img class="brand-logo" src="assets/logo.png" alt="Asteria Qt logo" width="48" height="48">
<div>
<h1>Asteria Qt</h1>
<p class="subtitle">Cross-platform Qt6 book &amp; document reader builds</p>
</div>
</div>
<div class="version-pill">
<span class="dot"></span>
<span>v{{VERSION}}</span>
</div>
</header>
<section class="meta-bar" aria-label="Build metadata">
<span>Branch: <strong>{{BRANCH}}</strong></span>
<span>Commit: <code>{{COMMIT_SHA}}</code></span>
<span>Built: <time datetime="{{BUILT_AT}}">{{BUILT_AT}}</time></span>
<a href="{{RUN_URL}}" target="_blank" rel="noopener">Run #{{RUN_ID}}</a>
<a href="{{RELEASE_URL}}" target="_blank" rel="noopener">Gitea Release v{{VERSION}}</a>
</section>
<section class="grid" aria-label="Platform downloads">
{{PLATFORM_CARDS}}
</section>
<footer>
<span>Checksums: <a href="downloads/SHA256SUMS">SHA256SUMS</a> &middot; <a href="manifest.json">manifest.json</a></span>
<span><a href="{{REPO_URL}}" target="_blank" rel="noopener">Source Repository</a></span>
</footer>
</main>
</body>
</html>
+260
View File
@@ -0,0 +1,260 @@
:root {
--bg: #0f1218;
--surface: #171c25;
--surface-elevated: #1e2531;
--border: #2a3344;
--text: #e9edf5;
--dim: #9aa6ba;
--accent: #6c8cff;
--accent-hover: #839eff;
--success: #4cc38a;
--code-bg: #0b0e13;
}
* {
box-sizing: border-box;
}
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
background: radial-gradient(circle at top, #182032 0%, var(--bg) 55%);
color: var(--text);
line-height: 1.5;
min-height: 100vh;
}
.container {
max-width: 980px;
margin: 0 auto;
padding: 40px 20px 64px;
}
header.hero {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: 20px;
padding-bottom: 28px;
border-bottom: 1px solid var(--border);
margin-bottom: 28px;
}
.brand {
display: flex;
align-items: center;
gap: 16px;
}
.brand-logo {
border-radius: 12px;
background: var(--surface);
padding: 4px;
border: 1px solid var(--border);
}
h1 {
margin: 0;
font-size: 1.85rem;
letter-spacing: -0.02em;
}
.subtitle {
margin: 4px 0 0;
color: var(--dim);
font-size: 0.95rem;
}
.version-pill {
display: inline-flex;
align-items: center;
gap: 8px;
background: var(--surface-elevated);
border: 1px solid var(--border);
border-radius: 999px;
padding: 8px 16px;
font-weight: 600;
font-size: 0.95rem;
}
.dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--success);
}
.meta-bar {
display: flex;
flex-wrap: wrap;
gap: 12px 24px;
background: var(--surface);
border: 1px solid var(--border);
border-radius: 12px;
padding: 14px 18px;
margin-bottom: 28px;
font-size: 0.9rem;
color: var(--dim);
}
.meta-bar a {
color: var(--accent);
text-decoration: none;
}
.meta-bar a:hover {
text-decoration: underline;
}
.grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 18px;
}
.card {
background: var(--surface);
border: 1px solid var(--border);
border-radius: 14px;
padding: 20px;
display: flex;
flex-direction: column;
gap: 14px;
}
.card-unavailable {
opacity: 0.65;
}
.card-header {
display: flex;
justify-content: space-between;
align-items: flex-start;
gap: 12px;
}
.card h2 {
margin: 0 0 6px;
font-size: 1.15rem;
}
.badge {
display: inline-block;
font-size: 0.78rem;
color: var(--dim);
background: var(--surface-elevated);
border: 1px solid var(--border);
padding: 2px 8px;
border-radius: 6px;
}
.size-pill {
font-size: 0.85rem;
font-weight: 600;
color: var(--text);
background: var(--surface-elevated);
padding: 4px 10px;
border-radius: 8px;
white-space: nowrap;
}
.size-pill.muted {
color: var(--dim);
}
.hint {
margin: 0;
color: var(--dim);
font-size: 0.85rem;
}
.hint code,
.checksum-row code {
display: inline-block;
background: var(--code-bg);
border: 1px solid var(--border);
border-radius: 6px;
padding: 4px 8px;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
font-size: 0.8rem;
word-break: break-all;
color: #c8d3e6;
}
.card-actions {
margin-top: auto;
}
.btn-download {
display: inline-flex;
align-items: center;
justify-content: center;
width: 100%;
padding: 10px 14px;
border-radius: 10px;
background: var(--accent);
color: #0b0e14;
font-weight: 600;
font-size: 0.92rem;
text-decoration: none;
transition: background 0.15s ease;
}
.btn-download:hover {
background: var(--accent-hover);
}
.checksum-box summary {
cursor: pointer;
color: var(--dim);
font-size: 0.82rem;
user-select: none;
}
.checksum-row {
display: flex;
align-items: center;
gap: 8px;
margin-top: 8px;
}
.checksum-row code {
flex: 1;
font-size: 0.74rem;
}
.btn-copy {
background: var(--surface-elevated);
border: 1px solid var(--border);
color: var(--text);
border-radius: 6px;
padding: 5px 10px;
font-size: 0.78rem;
cursor: pointer;
}
.btn-copy:hover {
border-color: var(--accent);
}
footer {
margin-top: 36px;
padding-top: 20px;
border-top: 1px solid var(--border);
display: flex;
flex-wrap: wrap;
justify-content: space-between;
gap: 12px;
color: var(--dim);
font-size: 0.85rem;
}
footer a {
color: var(--accent);
text-decoration: none;
}
footer a:hover {
text-decoration: underline;
}