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
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>
71 lines
2.8 KiB
Bash
Executable File
71 lines
2.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Builds the image on this machine and pushes it to the Gitea package registry (ADR 0009, ADR 0015). The normal path
|
|
# is release.yml on a vX.Y.Z tag; use this when the runner is not available. It does NOT create git tags: pushing the
|
|
# tag later makes release.yml find the version in the registry and only create the release.
|
|
#
|
|
# scripts/publish-image.sh vX.Y.Z [--arm64] [--force]
|
|
#
|
|
# Environment: GITEA_TOKEN (required, scope write:package), GITEA_URL (https://gitea.encke-hake.ts.net),
|
|
# GITEA_OWNER (BalboSoft), GITEA_USER (login of the token owner; defaults to GITEA_OWNER).
|
|
set -euo pipefail
|
|
|
|
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
cd "$root"
|
|
|
|
tag="${1:-}"
|
|
[[ "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.]+)?$ ]] || { echo "uso: publish-image.sh vX.Y.Z [--arm64] [--force]" >&2; exit 2; }
|
|
shift
|
|
platforms="linux/amd64"
|
|
force=false
|
|
for arg in "$@"; do
|
|
case "$arg" in
|
|
--arm64) platforms="linux/amd64,linux/arm64" ;;
|
|
--force) force=true ;;
|
|
*) echo "argomento sconosciuto: $arg" >&2; exit 2 ;;
|
|
esac
|
|
done
|
|
|
|
gitea_url="${GITEA_URL:-https://gitea.encke-hake.ts.net}"
|
|
gitea_url="${gitea_url%/}"
|
|
registry="${gitea_url#https://}"
|
|
registry="${registry#http://}"
|
|
owner="${GITEA_OWNER:-BalboSoft}"
|
|
owner_lc="$(printf '%s' "$owner" | tr '[:upper:]' '[:lower:]')"
|
|
image="$registry/$owner_lc/khaemhat"
|
|
version="${tag#v}"
|
|
sha="$(git rev-parse --short HEAD)"
|
|
token="${GITEA_TOKEN:?imposta GITEA_TOKEN (permesso write:package)}"
|
|
|
|
if [[ -n "$(git status --porcelain)" ]]; then
|
|
echo "ATTENZIONE: ci sono modifiche non committate; l'immagine riporterà lo SHA $sha." >&2
|
|
fi
|
|
|
|
status="$(curl -s -o /dev/null -w '%{http_code}' -H "Authorization: token $token" \
|
|
"$gitea_url/api/v1/packages/$owner/container/khaemhat/$version")"
|
|
if [[ "$status" == "200" && "$force" != true ]]; then
|
|
echo "La versione $version è già nel registro: niente da fare (usa --force per sovrascriverla)." >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Versioned icon for Unraid if committed, otherwise the plain one (ADR 0016).
|
|
major_minor="${version%%-*}"
|
|
major_minor="${major_minor%.*}"
|
|
icon_url="$gitea_url/$owner/Khaemhat/raw/branch/main/assets/icon-256.png"
|
|
if git cat-file -e "origin/main:assets/icon-v${major_minor}-256.png" 2>/dev/null; then
|
|
icon_url="$gitea_url/$owner/Khaemhat/raw/branch/main/assets/icon-v${major_minor}-256.png"
|
|
fi
|
|
|
|
tags=(-t "$image:$version")
|
|
[[ "$version" == *-* ]] || tags+=(-t "$image:latest")
|
|
|
|
printf '%s' "$token" | docker login "$registry" -u "${GITEA_USER:-$owner}" --password-stdin
|
|
docker buildx build --platform "$platforms" -f docker/Dockerfile \
|
|
--build-arg VERSION="$version" \
|
|
--build-arg GIT_SHA="$sha" \
|
|
--build-arg CREATED="$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
|
|
--build-arg SOURCE_URL="$gitea_url/$owner/Khaemhat" \
|
|
--build-arg ICON_URL="$icon_url" \
|
|
"${tags[@]}" --push .
|
|
|
|
echo "Pubblicata $image:$version ($platforms)."
|