Publish components through Gitea packages
Modular container CI / release-build (push) Failing after 17m56s

This commit is contained in:
faumaray committed 2026-07-29 23:45:09 +03:00
1 parent 0650d837d3
commit 2c8164584b
5 files changed
+136 -63

No files matched your search

+84 -27
View File
@@ -16,10 +16,10 @@ configuration=$(realpath -- "$1")
source "$script_dir/lib/component-ssh.sh"
required_commands=(
aws
cmake
cmp
ctest
curl
find
git
jq
@@ -46,7 +46,6 @@ required_environment=(
ECHOION_FEED_PRIVATE_KEY
ECHOION_FEED_REPOSITORY
ECHOION_FEED_SIGNING_KEY_ID
ECHOION_OBJECT_STORAGE_BUCKET
ECHOION_RELEASE_TAG_ALLOWED_SIGNERS
GITEA_API_URL
GITEA_RELEASE_TOKEN
@@ -59,6 +58,37 @@ for variable in "${required_environment[@]}"; do
fi
done
distribution_backend=${ECHOION_DISTRIBUTION_BACKEND:-s3}
case "$distribution_backend" in
gitea-generic)
if [[ $GITEA_API_URL != */api/v1 ]]; then
echo "release-component: GITEA_API_URL must end in /api/v1" >&2
exit 2
fi
gitea_root=${GITEA_API_URL%/api/v1}
if [[ $ECHOION_DISTRIBUTION_BASE_URL != \
"$gitea_root"/api/packages/*/generic ]]; then
echo "release-component: Gitea distribution URL must use the configured Gitea package registry" >&2
exit 2
fi
;;
s3)
command -v aws >/dev/null ||
{
echo "release-component: missing command: aws" >&2
exit 2
}
if [[ -z ${ECHOION_OBJECT_STORAGE_BUCKET:-} ]]; then
echo "release-component: ECHOION_OBJECT_STORAGE_BUCKET is required for the S3 backend" >&2
exit 2
fi
;;
*)
echo "release-component: unsupported distribution backend: $distribution_backend" >&2
exit 2
;;
esac
component_id=$(jq -er '
if .schemaVersion == 1 and
(.componentId | type == "string" and length > 0) and
@@ -258,35 +288,62 @@ archive=$(find "$dist" -maxdepth 1 -type f -name '*.tar.zst' -print)
exit 1
}
object_key="${ECHOION_OBJECT_STORAGE_PREFIX:-components}/$component_id/$component_version/$(basename "$archive")"
aws_arguments=()
if [[ -n ${ECHOION_OBJECT_STORAGE_ENDPOINT:-} ]]; then
aws_arguments+=(--endpoint-url "$ECHOION_OBJECT_STORAGE_ENDPOINT")
fi
set +e
aws "${aws_arguments[@]}" s3api put-object \
--bucket "$ECHOION_OBJECT_STORAGE_BUCKET" \
--key "$object_key" \
--body "$archive" \
--if-none-match '*' >/dev/null
upload_status=$?
set -e
if ((upload_status != 0)); then
existing="$work_root/existing-archive"
aws "${aws_arguments[@]}" s3api get-object \
--bucket "$ECHOION_OBJECT_STORAGE_BUCKET" \
--key "$object_key" "$existing" >/dev/null
cmp -- "$archive" "$existing" ||
artifact_name=$(basename "$archive")
verified="$work_root/verified-archive"
if [[ $distribution_backend == gitea-generic ]]; then
artifact_url="${ECHOION_DISTRIBUTION_BASE_URL%/}/$component_id/$component_version/$artifact_name"
upload_response="$work_root/gitea-package-upload-response"
upload_status=$(
curl --silent --show-error \
--output "$upload_response" \
--write-out '%{http_code}' \
--header "Authorization: token $GITEA_RELEASE_TOKEN" \
--upload-file "$archive" \
"$artifact_url"
)
if [[ $upload_status != 201 && $upload_status != 409 ]]; then
echo "release-component: Gitea package upload failed with HTTP $upload_status" >&2
exit 1
fi
curl --fail --silent --show-error \
--header "Authorization: token $GITEA_RELEASE_TOKEN" \
--output "$verified" \
"$artifact_url"
cmp -- "$archive" "$verified" ||
{
echo "release-component: immutable object conflict: $object_key" >&2
echo "release-component: immutable package conflict: $artifact_url" >&2
exit 1
}
else
object_key="${ECHOION_OBJECT_STORAGE_PREFIX:-components}/$component_id/$component_version/$artifact_name"
aws_arguments=()
if [[ -n ${ECHOION_OBJECT_STORAGE_ENDPOINT:-} ]]; then
aws_arguments+=(--endpoint-url "$ECHOION_OBJECT_STORAGE_ENDPOINT")
fi
set +e
aws "${aws_arguments[@]}" s3api put-object \
--bucket "$ECHOION_OBJECT_STORAGE_BUCKET" \
--key "$object_key" \
--body "$archive" \
--if-none-match '*' >/dev/null
upload_status=$?
set -e
if ((upload_status != 0)); then
existing="$work_root/existing-archive"
aws "${aws_arguments[@]}" s3api get-object \
--bucket "$ECHOION_OBJECT_STORAGE_BUCKET" \
--key "$object_key" "$existing" >/dev/null
cmp -- "$archive" "$existing" ||
{
echo "release-component: immutable object conflict: $object_key" >&2
exit 1
}
fi
aws "${aws_arguments[@]}" s3api get-object \
--bucket "$ECHOION_OBJECT_STORAGE_BUCKET" \
--key "$object_key" "$verified" >/dev/null
cmp -- "$archive" "$verified"
fi
verified="$work_root/verified-archive"
aws "${aws_arguments[@]}" s3api get-object \
--bucket "$ECHOION_OBJECT_STORAGE_BUCKET" \
--key "$object_key" "$verified" >/dev/null
cmp -- "$archive" "$verified"
if [[ $channel == nightly ]]; then
printf 'Automated %s nightly from %s.\n' "$component_id" "$source_sha" \