Files
Khaemhat/scripts/build.sh
T
Alby96andClaude Opus 5.5 12277733f5
CI / Build and test (SQLite) (pull_request) Successful in 43s
CI / PostgreSQL 16 integration (pull_request) Skipped
CI / PostgreSQL 17 integration (pull_request) Skipped
CI / YAML check (pull_request) Successful in 15s
CI / Docker image (pull_request) Successful in 59s
feat: bootstrap solution, Docker image and Gitea pipelines (M0)
Start development with the skeleton every later milestone builds on, so
that code, image and release path exist and are verified from day one.

- Khaemhat.sln with the ten projects of SPEC section 3 and six MSTest
  projects; shared build rules with warnings as errors, analyzers and
  Central Package Management restricted to the allowlist.
- Architecture tests and scripts/check-packages.sh fail on any project
  reference or package that SPEC does not allow.
- Khaemhat.Web serves an Italian "under construction" page with the
  official icons and version, plus /health/live, /health/ready and
  /health (ADR 0012); honours KHAEMHAT_URLS and KHAEMHAT_LOG_LEVEL.
- docker/Dockerfile (non-root app user aligned to PUID/PGID by the
  entrypoint, pg_dump 17, healthcheck, OCI and Unraid labels) and
  compose files for PostgreSQL and a standalone SQLite demo.
- Gitea Actions: ci.yml (build, tests, image smoke test, PostgreSQL
  16/17 on tags, YAML check), release.yml (image and release from a
  vX.Y.Z tag, skipping versions already published) and wiki.yml.
- Development scripts, VS Code launch/tasks for debugging, and ADR
  0012-0017 deciding the M0 open points of docs/STATUS.md.

Closes #1, #2, #3, #4, #5, #114

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 11:53:39 +01:00

65 lines
2.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# Builds the solution with warnings as errors (SPEC §19).
# scripts/build.sh [-c Debug|Release] build
# scripts/build.sh --icon [X.Y] also generate the versioned icon (ADR 0016); X.Y from the last tag
set -euo pipefail
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$root"
configuration=Release
icon=""
while (( $# > 0 )); do
case "$1" in
-c | --configuration) configuration="${2:?manca la configurazione}"; shift 2 ;;
--icon)
if [[ "${2:-}" =~ ^[0-9]+\.[0-9]+$ ]]; then icon="$2"; shift 2; else icon="auto"; shift; fi ;;
-h | --help) sed -n '2,5p' "$0"; exit 0 ;;
*) echo "argomento sconosciuto: $1" >&2; exit 2 ;;
esac
done
# Generates assets/icon-v<X.Y>.svg from the template by string replacement, then the PNGs if a rasterizer exists.
generate_icon() {
local version="$1" svg png size tool=""
if [[ "$version" == "auto" ]]; then
version="$(git describe --tags --match 'v[0-9]*' --abbrev=0 2>/dev/null || true)"
[[ -n "$version" ]] || { echo "nessun tag vX.Y.Z: indica la versione, es. --icon 1.0" >&2; exit 2; }
version="${version#v}"
version="${version%.*}"
fi
svg="assets/icon-v${version}.svg"
if [[ "$version" != "1.0" ]]; then
sed "s/v 1\.0/v ${version}/" assets/icon-v1.0.svg > "$svg"
grep -q "v ${version}" "$svg" || { echo "il modello assets/icon-v1.0.svg non contiene il testo 'v 1.0'" >&2; exit 1; }
fi
echo "icona: $svg"
for candidate in rsvg-convert inkscape magick; do
if command -v "$candidate" > /dev/null 2>&1; then tool="$candidate"; break; fi
done
if [[ -z "$tool" ]]; then
echo "nessun rasterizzatore (rsvg-convert, inkscape, magick): genera i PNG su una macchina che ne ha uno (ADR 0016)." >&2
return 0
fi
for size in 128 256 512; do
png="assets/icon-v${version}-${size}.png"
case "$tool" in
rsvg-convert) rsvg-convert -w "$size" -h "$size" -o "$png" "$svg" ;;
inkscape) inkscape "$svg" --export-type=png --export-filename="$png" -w "$size" -h "$size" > /dev/null ;;
magick) magick -background none -density 384 "$svg" -resize "${size}x${size}" "$png" ;;
esac
echo "icona: $png ($tool)"
done
echo "Committa i file generati su main prima del tag che li usa (ADR 0016)."
}
bash scripts/check-packages.sh
dotnet build Khaemhat.sln -c "$configuration" -warnaserror
if [[ -n "$icon" ]]; then
generate_icon "$icon"
fi