Publish the image on version tags and test what is delivered
A v* tag now builds, tries and publishes the image: the version must be the one of Directory.Build.props, latest only moves forward and the registry token is in one step, given to docker on its input. The same script works by hand. The image says its version and commit, and its health check also covers the engine loop and the live prices. The Unraid template is final: a test compares it with appendix E and with the variables the loader really reads, and another reads the workflow. refs #70 refs #71 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4d92a39fef
commit
3cd214ae78
16 files changed
+859
-27
No files matched your search
@@ -0,0 +1,47 @@
|
||||
#!/bin/sh
|
||||
# Publishes an image already built and tried (SPEC 15.5, ADR 0002 and 0020).
|
||||
# Usage: publish.sh <local image> <tag vX.Y.Z[-something]>
|
||||
# From the environment: REGISTRY, REGISTRY_USER, REGISTRY_TOKEN (write:package). The token reaches docker only on its
|
||||
# input and stays in a temporary folder removed at the end.
|
||||
set -eu
|
||||
|
||||
image="$1"
|
||||
tag="$2"
|
||||
root=$(cd "$(dirname "$0")/../.." && pwd)
|
||||
fail() {
|
||||
echo "Pubblicazione non riuscita: $1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
printf '%s\n' "$tag" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.]+)?$' || fail "il tag '$tag' non è una versione (vX.Y.Z)."
|
||||
version=${tag#v}
|
||||
expected=$(sed -n 's:.*<Version>\(.*\)</Version>.*:\1:p' "$root/Directory.Build.props")
|
||||
[ "${version%%-*}" = "$expected" ] || fail "il tag $tag non corrisponde alla versione $expected di Directory.Build.props."
|
||||
[ -n "${REGISTRY:-}" ] || fail "manca REGISTRY."
|
||||
[ -n "${REGISTRY_USER:-}" ] || fail "manca REGISTRY_USER."
|
||||
[ -n "${REGISTRY_TOKEN:-}" ] || fail "manca il segreto REGISTRY_TOKEN (token Gitea con il permesso write:package)."
|
||||
name="$REGISTRY/balbosoft/anubis"
|
||||
|
||||
# latest moves only for the highest plain version among the tags of the repository.
|
||||
latest=""
|
||||
case "$version" in
|
||||
*-*) ;;
|
||||
*)
|
||||
tags=$(git -C "$root" ls-remote --tags --refs origin 'v*') || fail "non riesco a leggere i tag del repository."
|
||||
newest=$(printf '%s\n' "$tags" "x refs/tags/$tag" | sed -n 's:.*refs/tags/v\([0-9]*\.[0-9]*\.[0-9]*\)$:\1:p' | sort -t. -k1,1n -k2,2n -k3,3n | tail -n 1)
|
||||
if [ "$newest" = "$version" ]; then latest=1; fi
|
||||
;;
|
||||
esac
|
||||
|
||||
DOCKER_CONFIG=$(mktemp -d)
|
||||
export DOCKER_CONFIG
|
||||
trap 'rm -rf "$DOCKER_CONFIG"' EXIT
|
||||
printf '%s' "$REGISTRY_TOKEN" | docker login "$REGISTRY" --username "$REGISTRY_USER" --password-stdin
|
||||
docker tag "$image" "$name:$version"
|
||||
docker push "$name:$version"
|
||||
if [ -n "$latest" ]; then
|
||||
docker tag "$image" "$name:latest"
|
||||
docker push "$name:latest"
|
||||
fi
|
||||
|
||||
echo "Pubblicata $name:$version${latest:+ (e latest)}."
|
||||
Reference in new issue
Block a user