Enhance documentation, update release process, and improve UI elements

This commit is contained in:
2026-09-26 17:27:21 +02:00
parent c8809e56b2
commit 3f4fccdba2
10 changed files with 80 additions and 23 deletions
+51 -4
View File
@@ -3,6 +3,24 @@ set -euo pipefail
image="gitea.faerro.it/andrea/faerro-kb"
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
bump="patch"
while [[ $# -gt 0 ]]; do
case "$1" in
--major|--minor)
if [[ "$bump" != "patch" ]]; then
echo "Choose only one of --major or --minor." >&2
exit 1
fi
bump="${1#--}"
;;
*)
echo "Usage: $0 [--major | --minor]" >&2
exit 1
;;
esac
shift
done
if ! command -v docker >/dev/null 2>&1; then
echo "Docker is required to build and publish the image." >&2
@@ -14,14 +32,43 @@ if ! command -v git >/dev/null 2>&1; then
exit 1
fi
tag="$(git -C "$repo_root" describe --tags --exact-match HEAD 2>/dev/null || true)"
version="${tag#v}"
latest_version=""
while IFS= read -r candidate; do
if [[ "$candidate" =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]]; then
latest_version="$candidate"
break
fi
done < <(git -C "$repo_root" tag --list --sort=-version:refname)
if [[ ! "$version" =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]]; then
echo "The checked-out commit must have a SemVer tag (for example, 0.0.2 or v0.0.2)." >&2
if [[ -z "$latest_version" ]]; then
echo "At least one MAJOR.MINOR.PATCH Git tag is required to determine the next version." >&2
exit 1
fi
IFS=. read -r major minor patch <<< "$latest_version"
case "$bump" in
major)
major=$((10#$major + 1))
minor=0
patch=0
;;
minor)
minor=$((10#$minor + 1))
patch=0
;;
patch)
patch=$((10#$patch + 1))
;;
esac
version="$major.$minor.$patch"
if git -C "$repo_root" show-ref --verify --quiet "refs/tags/$version"; then
echo "Git tag $version already exists; refusing to move it." >&2
exit 1
fi
git -C "$repo_root" tag "$version"
cd "$repo_root"
docker build --tag "$image:$version" --tag "$image:latest" .
registry_username="${GITEA_USERNAME:-${DOCKER_USERNAME:-}}"